[seam-commits] Seam SVN: r10556 - in modules/trunk/security: src/main/java/org/jboss/seam/security and 3 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Apr 21 21:16:58 EDT 2009
Author: shane.bryzak at jboss.com
Date: 2009-04-21 21:16:58 -0400 (Tue, 21 Apr 2009)
New Revision: 10556
Added:
modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsInitializedEvent.java
modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsUpdatedEvent.java
Removed:
modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java
Modified:
modules/trunk/security/
modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java
modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java
modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java
modules/trunk/security/src/main/java/org/jboss/seam/security/events/LoginFailedEvent.java
modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
Log:
port credentials, security events
Property changes on: modules/trunk/security
___________________________________________________________________
Name: svn:ignore
- target
.settings
+ .classpath
.project
.settings
target
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java 2009-04-21 23:49:06 UTC (rev 10555)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -1,36 +1,36 @@
package org.jboss.seam.security;
-import static org.jboss.seam.ScopeType.SESSION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
import java.io.IOException;
import java.io.Serializable;
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.core.Events;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import org.jboss.seam.security.events.CredentialsInitializedEvent;
+import org.jboss.seam.security.events.CredentialsUpdatedEvent;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
- at Name("org.jboss.seam.security.credentials")
- at Scope(SESSION)
- at Install(precedence = BUILT_IN)
- at BypassInterceptors
+ at Named
+ at SessionScoped
public class Credentials implements Serializable
{
+ private static final long serialVersionUID = -2271248957776488426L;
+
public static final String EVENT_INIT_CREDENTIALS = "org.jboss.seam.security.initCredentials";
public static final String EVENT_CREDENTIALS_UPDATED = "org.jboss.seam.security.credentialsUpdated";
private static final LogProvider log = Logging.getLogProvider(Credentials.class);
+ @Current Manager manager;
+
private String username;
private String password;
@@ -50,10 +50,10 @@
public String getUsername()
{
- if (!isInitialized() && Events.exists())
+ if (!isInitialized())
{
setInitialized(true);
- Events.instance().raiseEvent(EVENT_INIT_CREDENTIALS, this);
+ manager.fireEvent(new CredentialsInitializedEvent(this));
}
return username;
@@ -65,7 +65,7 @@
{
this.username = username;
invalid = false;
- if (Events.exists()) Events.instance().raiseEvent(EVENT_CREDENTIALS_UPDATED);
+ manager.fireEvent(new CredentialsUpdatedEvent());
}
}
@@ -80,7 +80,7 @@
{
this.password = password;
invalid = false;
- if (Events.exists()) Events.instance().raiseEvent(EVENT_CREDENTIALS_UPDATED);
+ manager.fireEvent(new CredentialsUpdatedEvent());
}
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java 2009-04-21 23:49:06 UTC (rev 10555)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -1,18 +1,16 @@
package org.jboss.seam.security;
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
+import javax.context.ApplicationScoped;
+import javax.event.Observes;
import javax.security.auth.login.LoginException;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.international.StatusMessages;
import org.jboss.seam.international.StatusMessage.Severity;
+import org.jboss.seam.security.events.AlreadyLoggedInEvent;
+import org.jboss.seam.security.events.LoggedInEvent;
+import org.jboss.seam.security.events.LoginFailedEvent;
+import org.jboss.seam.security.events.NotLoggedInEvent;
+import org.jboss.seam.security.events.PostAuthenticateEvent;
/**
* Produces FacesMessages in response of certain security events, and helps to decouple the
@@ -20,28 +18,22 @@
*
* @author Shane Bryzak
*/
- at Name("org.jboss.seam.security.facesSecurityEvents")
- at Scope(APPLICATION)
- at Install(precedence = BUILT_IN, classDependencies = "javax.faces.context.FacesContext")
- at BypassInterceptors
- at Startup
+ at ApplicationScoped
public class FacesSecurityEvents
{
- @Observer(Identity.EVENT_POST_AUTHENTICATE)
- public void postAuthenticate(Identity identity)
+ public void postAuthenticate(@Observes PostAuthenticateEvent event)
{
//org.jboss.security.saml.SSOManager.processManualLoginNotification(
//ServletContexts.instance().getRequest(), identity.getPrincipal().getName());
}
- @Observer(Identity.EVENT_LOGIN_FAILED)
- public void addLoginFailedMessage(LoginException ex)
+ public void addLoginFailedMessage(@Observes LoginFailedEvent event)
{
StatusMessages.instance().addFromResourceBundleOrDefault(
getLoginFailedMessageSeverity(),
getLoginFailedMessageKey(),
getLoginFailedMessage(),
- ex);
+ event.getLoginException());
}
public String getLoginFailedMessage()
@@ -59,8 +51,7 @@
return "org.jboss.seam.loginFailed";
}
- @Observer(Identity.EVENT_LOGIN_SUCCESSFUL)
- public void addLoginSuccessfulMessage()
+ public void addLoginSuccessfulMessage(@Observes LoggedInEvent event)
{
StatusMessages.instance().addFromResourceBundleOrDefault(
getLoginSuccessfulMessageSeverity(),
@@ -69,8 +60,7 @@
Identity.instance().getCredentials().getUsername());
}
- @Observer(Identity.EVENT_NOT_LOGGED_IN)
- public void addNotLoggedInMessage()
+ public void addNotLoggedInMessage(@Observes NotLoggedInEvent event)
{
StatusMessages.instance().addFromResourceBundleOrDefault(
Severity.WARN,
@@ -94,8 +84,7 @@
return "org.jboss.seam.loginSuccessful";
}
- @Observer(Identity.EVENT_ALREADY_LOGGED_IN)
- public void addAlreadyLoggedInMessage()
+ public void addAlreadyLoggedInMessage(@Observes AlreadyLoggedInEvent event)
{
StatusMessages.instance().addFromResourceBundleOrDefault (
Severity.WARN,
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-04-21 23:49:06 UTC (rev 10555)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -214,7 +214,7 @@
log.debug("Login failed for: " + credentials, ex);
}
- manager.fireEvent(new LoginFailedEvent());
+ manager.fireEvent(new LoginFailedEvent(ex));
}
return null;
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java 2009-04-21 23:49:06 UTC (rev 10555)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -1,4 +1,4 @@
-package org.jboss.seam.annotations.security;
+package org.jboss.seam.security.annotations;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
Deleted: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java 2009-04-21 23:49:06 UTC (rev 10555)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -1,7 +0,0 @@
-/**
- * Annotations (well, one annotation) for use with Seam security.
- *
- * @see org.jboss.seam.security.Identity
- */
-package org.jboss.seam.annotations.security;
-
Added: modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsInitializedEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsInitializedEvent.java (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsInitializedEvent.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -0,0 +1,28 @@
+package org.jboss.seam.security.events;
+
+import org.jboss.seam.security.Credentials;
+
+/**
+ * This event is raised when credentials are initialized
+ *
+ * @author Shane Bryzak
+ */
+public class CredentialsInitializedEvent
+{
+ private Credentials credentials;
+
+ public CredentialsInitializedEvent(Credentials credentials)
+ {
+ this.credentials = credentials;
+ }
+
+ public Credentials getCredentials()
+ {
+ return credentials;
+ }
+
+ public void setCredentials(Credentials credentials)
+ {
+ this.credentials = credentials;
+ }
+}
Added: modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsUpdatedEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsUpdatedEvent.java (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/CredentialsUpdatedEvent.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -0,0 +1,11 @@
+package org.jboss.seam.security.events;
+
+/**
+ * This event is raised when credentials are updated
+ *
+ * @author Shane Bryzak
+ */
+public class CredentialsUpdatedEvent
+{
+
+}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/events/LoginFailedEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/LoginFailedEvent.java 2009-04-21 23:49:06 UTC (rev 10555)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/LoginFailedEvent.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -1,5 +1,7 @@
package org.jboss.seam.security.events;
+import javax.security.auth.login.LoginException;
+
/**
* This event is fired when an authentication attempt fails
*
@@ -7,5 +9,15 @@
*/
public class LoginFailedEvent
{
-
+ private LoginException loginException;
+
+ public LoginFailedEvent(LoginException loginException)
+ {
+ this.loginException = loginException;
+ }
+
+ public LoginException getLoginException()
+ {
+ return loginException;
+ }
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java 2009-04-21 23:49:06 UTC (rev 10555)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java 2009-04-22 01:16:58 UTC (rev 10556)
@@ -7,6 +7,7 @@
import java.util.Map;
import java.util.Set;
+import javax.inject.manager.Manager;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
@@ -15,9 +16,8 @@
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
-import org.jboss.seam.core.Expressions.MethodExpression;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.SimpleGroup;
import org.jboss.seam.security.SimplePrincipal;
More information about the seam-commits
mailing list