[gatein-commits] gatein SVN: r4383 - components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Sep 24 10:16:27 EDT 2010


Author: alain_defrance
Date: 2010-09-24 10:16:26 -0400 (Fri, 24 Sep 2010)
New Revision: 4383

Modified:
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AbstractAuthentication.java
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationListener.java
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Ticket.java
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/TicketService.java
   components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/WCICredentials.java
Log:
login feature in progress

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AbstractAuthentication.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AbstractAuthentication.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AbstractAuthentication.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -26,31 +26,41 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public abstract class AbstractAuthentication implements Authentication {
-  protected enum EventType {
+public abstract class AbstractAuthentication implements Authentication
+{
+  protected enum EventType
+  {
     LOGIN, LOGOUT
   }
 
   private List<AuthenticationListener> authenticationListeners = new ArrayList<AuthenticationListener>();
 
-  public void addAuthenticationListener(AuthenticationListener listener) {
+  public void addAuthenticationListener(AuthenticationListener listener)
+  {
     authenticationListeners.add(listener);
   }
 
-  protected List<AuthenticationListener> getAuthenticationListeners() {
+  protected List<AuthenticationListener> getAuthenticationListeners()
+  {
     return authenticationListeners;
   }
 
-  protected void fireEvent(EventType type, AuthenticationEvent ae) {
+  protected void fireEvent(EventType type, AuthenticationEvent ae)
+  {
     String methodName = String.format(
       "on%1%2",
       type.toString().substring(0, 1).toUpperCase(),
       type.toString().substring(1)
     );
-    for (AuthenticationListener currentListener : authenticationListeners) {
-      try {
+    for (AuthenticationListener currentListener : authenticationListeners)
+    {
+      try
+      {
         currentListener.getClass().getMethod(methodName, AuthenticationEvent.class).invoke(currentListener, ae);
-      } catch (Exception ignore) {}
+      }
+      catch (Exception ignore)
+      {
+      }
     }
   }
 }

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -23,7 +23,8 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public interface Authentication {
+public interface Authentication
+{
   public WCICredentials login(String login, char[] password);
   public void logout();
   public void addAuthenticationListener(AuthenticationListener listener);

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -23,5 +23,32 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public interface AuthenticationEvent {
+public class AuthenticationEvent
+{
+  private String username;
+  private char[] password;
+
+  public AuthenticationEvent(String username, char[] password)
+  {
+    if (username == null)
+    {
+      throw new IllegalArgumentException("username is null");
+    }
+    if (password == null)
+    {
+      throw new IllegalArgumentException("password is null");
+    }
+    this.username = username;
+    this.password = password;
+  }
+
+  public String getUsername()
+  {
+    return username;
+  }
+
+  public char[] getPassword()
+  {
+    return password;
+  }
 }

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationListener.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationListener.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/AuthenticationListener.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -23,7 +23,8 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public interface AuthenticationListener {
+public interface AuthenticationListener
+{
   void onLogin(AuthenticationEvent ae);
   void onLogout(AuthenticationEvent ae);
 }

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -23,16 +23,19 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public class GenericAuthentication extends AbstractAuthentication {
+public class GenericAuthentication extends AbstractAuthentication
+{
   public static final TicketService TICKET_SERVICE = new TicketService();
   
-  public WCICredentials login(String login, char[] password) {
+  public WCICredentials login(String login, char[] password)
+  {
     WCICredentials credentials = TICKET_SERVICE.validateToken(new String(password), true);
-    fireEvent(EventType.LOGIN, null); // TODO : create parameter
+    fireEvent(EventType.LOGIN, new AuthenticationEvent(login, password));
     return credentials;
   }
 
-  public void logout() {
-    fireEvent(EventType.LOGOUT, null); // TODO : create parameter
+  public void logout()
+  {
+    fireEvent(EventType.LOGOUT, new AuthenticationEvent("", new char[1]));
   }
 }

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Ticket.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Ticket.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Ticket.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -23,7 +23,8 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public class Ticket {
+public class Ticket
+{
    //public static String EXPIRE_MILI = "expirationMilis";
 
    //public static String USERNAME = "userName"

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/TicketService.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/TicketService.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/TicketService.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -26,7 +26,8 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public class TicketService {
+public class TicketService
+{
   
   protected long validityMillis = 1000 * 60; // TODO : Init from confguration
 
@@ -34,7 +35,7 @@
 
   protected final Random random = new Random();
 
-  public String createToken(WCICredentials credentials)
+  public String createTicket(WCICredentials credentials)
   {
     if (validityMillis < 0)
     {
@@ -92,6 +93,6 @@
   }
 
   private String nextTicketId() {
-    return "ticket" + random.nextInt(); // TODO : maybe change this token from configuration
+    return "wci-ticket-" + random.nextInt();
   }
 }

Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/WCICredentials.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/WCICredentials.java	2010-09-24 12:37:38 UTC (rev 4382)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/WCICredentials.java	2010-09-24 14:16:26 UTC (rev 4383)
@@ -25,7 +25,8 @@
  * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
  * @version $Revision$
  */
-public class WCICredentials implements Serializable {
+public class WCICredentials implements Serializable
+{
    /** . */
    private final String username;
 



More information about the gatein-commits mailing list