[Skabacca-developer] SF.net SVN: skabacca:[15] trunk
Status: Pre-Alpha
Brought to you by:
triathlon98
|
From: <tri...@us...> - 2010-01-21 14:42:19
|
Revision: 15
http://skabacca.svn.sourceforge.net/skabacca/?rev=15&view=rev
Author: triathlon98
Date: 2010-01-21 14:42:00 +0000 (Thu, 21 Jan 2010)
Log Message:
-----------
Assure login works (though not yet on "/" which seems to fail in chenillekit-access)
Modified Paths:
--------------
trunk/gui/src/main/java/org/skabacca/gui/pages/Login.java
trunk/gui/src/main/resources/org/skabacca/gui/pages/Login.tml
Added Paths:
-----------
trunk/core/src/main/java/org/skabacca/dm/server/HTUser.java
Removed Paths:
-------------
trunk/core/src/main/java/org/skabacca/dm/server/UserMediator.java
Added: trunk/core/src/main/java/org/skabacca/dm/server/HTUser.java
===================================================================
--- trunk/core/src/main/java/org/skabacca/dm/server/HTUser.java (rev 0)
+++ trunk/core/src/main/java/org/skabacca/dm/server/HTUser.java 2010-01-21 14:42:00 UTC (rev 15)
@@ -0,0 +1,63 @@
+/*
+ * This file is part of skabacca.
+ *
+ * Copyright belongs to the respective authors, see subversion.
+ *
+ * skabacca is free software: you can redistribute it and/or modify it under the terms of the
+ * Affero GNU General Public License as published by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Skabacca is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * For the full text of the license, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.skabacca.dm.server;
+
+import org.apache.log4j.Logger;
+import org.equanda.client.EquandaException;
+import org.equanda.persistence.SelectorsState;
+import org.skabacca.dm.client.Organization;
+import org.skabacca.dm.server.pm.DMEquandaUser;
+
+/**
+ * Table helper for User object
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class HTUser
+ extends HTUserBase
+{
+
+ private static final Logger log = Logger.getLogger( HTUser.class );
+
+ /**
+ * Log in to organization
+ *
+ * @throws EquandaException oops
+ */
+ @Override
+ public void login( DMEquandaUser entity )
+ throws EquandaException
+ {
+ Organization org = null; // @todo
+ SelectorsState.setFilter( "Organization", org == null ? null : org.getReference() );
+ SelectorsState.setFilter( "OrganizationOne",
+ org == null ? null : "o.organization.reference='" + org.getReference() + "'" );
+ SelectorsState.setFilter( "OrganizationMul",
+ org == null ? null : "'" + org.getReference() + "' in o.organizations.reference" );
+ }
+
+ /**
+ * Log out from organization
+ *
+ * @throws EquandaException oops
+ */
+ @Override
+ public void logout( DMEquandaUser entity )
+ throws EquandaException
+ {
+ SelectorsState.setFilter( "Organization", null );
+ }
+}
Deleted: trunk/core/src/main/java/org/skabacca/dm/server/UserMediator.java
===================================================================
--- trunk/core/src/main/java/org/skabacca/dm/server/UserMediator.java 2010-01-21 09:05:43 UTC (rev 14)
+++ trunk/core/src/main/java/org/skabacca/dm/server/UserMediator.java 2010-01-21 14:42:00 UTC (rev 15)
@@ -1,59 +0,0 @@
-/*
- * This file is part of skabacca.
- *
- * Copyright belongs to the respective authors, see subversion.
- *
- * skabacca is free software: you can redistribute it and/or modify it under the terms of the
- * Affero GNU General Public License as published by the Free Software Foundation, either version 3 of the License,
- * or (at your option) any later version.
- *
- * Skabacca is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * For the full text of the license, see <http://www.gnu.org/licenses/>.
- */
-
-package org.skabacca.dm.server;
-
-import org.skabacca.dm.client.Organization;
-import org.equanda.client.EquandaException;
-import org.equanda.persistence.SelectorsState;
-import org.apache.log4j.Logger;
-
-/**
- * Mediator for User object
- *
- * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
- */
-public class UserMediator
-{
- private static final Logger log = Logger.getLogger( UserMediator.class );
-
- /**
- * Log in to organization
- *
- * @throws EquandaException oops
- */
- public void login()
- throws EquandaException
- {
- Organization org = null; // @todo
- SelectorsState.setFilter( "Organization", org == null ? null : org.getReference() );
- SelectorsState.setFilter( "OrganizationOne",
- org == null ? null : "o.organization.reference='" + org.getReference() + "'" );
- SelectorsState.setFilter( "OrganizationMul",
- org == null ? null : "'" + org.getReference() + "' in o.organizations.reference" );
- }
-
- /**
- * Log out from organization
- *
- * @throws EquandaException oops
- */
- public void logout()
- throws EquandaException
- {
- SelectorsState.setFilter( "Organization", null );
- }
-}
-
Modified: trunk/gui/src/main/java/org/skabacca/gui/pages/Login.java
===================================================================
--- trunk/gui/src/main/java/org/skabacca/gui/pages/Login.java 2010-01-21 09:05:43 UTC (rev 14)
+++ trunk/gui/src/main/java/org/skabacca/gui/pages/Login.java 2010-01-21 14:42:00 UTC (rev 15)
@@ -16,19 +16,19 @@
package org.skabacca.gui.pages;
import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.EventContext;
-import org.apache.tapestry5.annotations.ApplicationState;
+import org.apache.tapestry5.ValidationTracker;
+import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.annotations.Local;
import org.apache.tapestry5.services.ContextValueEncoder;
import org.apache.tapestry5.services.Cookies;
import org.chenillekit.access.ChenilleKitAccessConstants;
-import org.chenillekit.access.internal.ChenillekitAccessInternalUtils;
+import org.chenillekit.access.WebSessionUser;
import org.chenillekit.access.services.AuthenticationService;
-import org.skabacca.gui.data.EquandaWebSessionUser;
import org.slf4j.Logger;
/**
@@ -50,8 +50,8 @@
@Property
private String password;
- @ApplicationState
- private EquandaWebSessionUser webSessionUser;
+ @SessionState
+ private WebSessionUser webSessionUser;
@Inject
private Messages messages;
@@ -66,7 +66,7 @@
@Persist
private int loginAttempts;
- private EquandaWebSessionUser tmpUser;
+ private WebSessionUser tmpUser;
@Inject
private Cookies cookies;
@@ -74,6 +74,9 @@
@Inject
private ContextValueEncoder valueEncoder;
+ @Environmental
+ private ValidationTracker validationTracker;
+
final public boolean isLoginAllowed()
{
return loginAttempts < MAX_LOGIN_ATTEMPTS;
@@ -81,41 +84,29 @@
void onValidateForm()
{
+ logger.debug( "login validate start user = " + userName );
loginAttempts++;
- tmpUser = (EquandaWebSessionUser) authenticationService.doAuthenticate( userName, password );
+ tmpUser = authenticationService.doAuthenticate( userName, password );
+ logger.debug( "login validate start res = " + tmpUser );
+ if ( tmpUser == null )
+ {
+ validationTracker
+ .recordError( messages.format( ChenilleKitAccessConstants.NOT_AUTHENTICATED_ERROR_MESSAGE, userName ) );
+ }
}
- Object onSuccess()
+ void onSuccess()
{
// @todo return page handling should be implicit
if ( null != tmpUser ) resources.discardPersistentFieldChanges();
+ logger.debug( "login successful" );
webSessionUser = tmpUser;
- /*
- if ( null != tmpUser )
- {
- //asoManager.set( );
- String prevPage = cookies.readCookieValue( ChenilleKitAccessConstants.REQUESTED_PAGENAME_COOKIE );
- String prevContext = cookies.readCookieValue( ChenilleKitAccessConstants.REQUESTED_EVENTCONTEXT_COOKIE );
- if ( prevPage != null )
- {
- cookies.removeCookieValue( ChenilleKitAccessConstants.REQUESTED_EVENTCONTEXT_COOKIE );
- cookies.removeCookieValue( ChenilleKitAccessConstants.REQUESTED_PAGENAME_COOKIE );
- if ( prevContext != null && prevContext.length() > 0 )
- {
- EventContext context =
- ChenillekitAccessInternalUtils.getContextFromString( valueEncoder, prevContext );
- Object[] contextArray = new Object[context.getCount()];
- for ( int i = 0; i < context.getCount() ; i++ ) contextArray[ i ] = context.get( Object.class, i );
- return resources.createPageLink( prevPage, true, contextArray );
- }
- else
- {
- return resources.createPageLink( prevPage, false );
- }
- }
- }
- */
- return null;
+ cookies.writeCookieValue( ChenilleKitAccessConstants.LOGIN_SUCCESSFUL_COOKIE_NAME, "OK", 300 );
}
+
+ void onFailure()
+ {
+ cookies.writeCookieValue( ChenilleKitAccessConstants.LOGIN_SUCCESSFUL_COOKIE_NAME, "KO", 300 );
+ }
}
Modified: trunk/gui/src/main/resources/org/skabacca/gui/pages/Login.tml
===================================================================
--- trunk/gui/src/main/resources/org/skabacca/gui/pages/Login.tml 2010-01-21 09:05:43 UTC (rev 14)
+++ trunk/gui/src/main/resources/org/skabacca/gui/pages/Login.tml 2010-01-21 14:42:00 UTC (rev 15)
@@ -15,7 +15,7 @@
<h1 style="text-align:center;">${equanda-message:title.Login}</h1>
- <t:form action="#">
+ <t:form action="#" clientValidation="false">
<t:errors/>
<t:if test="isLoginAllowed()">
<t:parameter name="else">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|