You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by sb...@apache.org on 2012/02/28 10:23:14 UTC

git commit: DELTASPIKE-76 Identity implementation

Updated Branches:
  refs/heads/master 2001de19d -> 3edae619c


DELTASPIKE-76 Identity implementation

Submitted on behalf of a third party: Red Hat, Inc. under the terms of the ALv2


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/3edae619
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/3edae619
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/3edae619

Branch: refs/heads/master
Commit: 3edae619c13c1661906d901ef2819975f53175c2
Parents: 2001de1
Author: Shane Bryzak <sb...@gmail.com>
Authored: Tue Feb 28 19:22:36 2012 +1000
Committer: Shane Bryzak <sb...@gmail.com>
Committed: Tue Feb 28 19:22:36 2012 +1000

----------------------------------------------------------------------
 .../security/api/AuthenticationException.java      |   37 +++
 .../apache/deltaspike/security/api/Credential.java |   27 ++
 .../deltaspike/security/api/CredentialType.java    |   27 ++
 .../deltaspike/security/api/Credentials.java       |   41 +++
 .../apache/deltaspike/security/api/Identity.java   |   16 +-
 .../security/api/events/AlreadyLoggedInEvent.java  |   28 ++
 .../api/events/AuthorizationCheckEvent.java        |   60 ++++
 .../api/events/CredentialsInitializedEvent.java    |   46 +++
 .../api/events/CredentialsUpdatedEvent.java        |   29 ++
 .../api/events/DeferredAuthenticationEvent.java    |   40 +++
 .../security/api/events/LoggedInEvent.java         |   40 +++
 .../security/api/events/LoginFailedEvent.java      |   38 +++
 .../security/api/events/NotAuthorizedEvent.java    |   28 ++
 .../security/api/events/NotLoggedInEvent.java      |   28 ++
 .../security/api/events/PostAuthenticateEvent.java |   28 ++
 .../security/api/events/PostLoggedOutEvent.java    |   39 +++
 .../security/api/events/PreAuthenticateEvent.java  |   27 ++
 .../security/api/events/PreLoggedOutEvent.java     |   27 ++
 .../security/api/events/QuietLoginEvent.java       |   27 ++
 .../api/events/UserAuthenticatedEvent.java         |   37 +++
 .../deltaspike/security/impl/CredentialsImpl.java  |  157 ++++++++++
 .../deltaspike/security/impl/IdentityImpl.java     |  237 +++++++++++++++
 .../security/impl/PasswordCredential.java          |  122 ++++++++
 .../security/impl/RequestSecurityState.java        |   62 ++++
 .../security/impl/SimpleCredentialType.java        |   36 +++
 .../impl/secured/SecuredBeanWithStereotype.java    |    2 +-
 .../test/util/ShrinkWrapArchiveUtil.java           |    3 +-
 27 files changed, 1278 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/AuthenticationException.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/AuthenticationException.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/AuthenticationException.java
new file mode 100644
index 0000000..edb1731
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/AuthenticationException.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api;
+
+/**
+ * Thrown if there is an error during the authentication process
+ */
+public class AuthenticationException extends SecurityException 
+{
+    private static final long serialVersionUID = -7486433031372506270L;
+
+    public AuthenticationException(String message) 
+    {
+        super(message);
+    }
+
+    public AuthenticationException(String message, Throwable cause) 
+    {
+        super(message, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credential.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credential.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credential.java
new file mode 100644
index 0000000..910101e
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credential.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api;
+
+/**
+ * Contains a single credential, such as a password
+ */
+public interface Credential
+{
+    CredentialType getType();
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/CredentialType.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/CredentialType.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/CredentialType.java
new file mode 100644
index 0000000..779504b
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/CredentialType.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api;
+
+/**
+ * Represents a single credential type 
+ */
+public interface CredentialType
+{
+    String getName();
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credentials.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credentials.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credentials.java
new file mode 100644
index 0000000..3d5fb7f
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Credentials.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api;
+
+/**
+ * Represents the credentials the current user will use to authenticate
+ */
+public interface Credentials 
+{
+    String getUsername();
+
+    void setUsername(String username);
+
+    Credential getCredential();
+
+    void setCredential(Credential credential);
+
+    boolean isSet();
+
+    boolean isInvalid();
+
+    void invalidate();
+
+    void clear();
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Identity.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Identity.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Identity.java
index aa47d97..b8ec720 100644
--- a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Identity.java
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/Identity.java
@@ -61,9 +61,8 @@ public interface Identity
      * This method is intended to be used primarily as an internal API call, however has been made 
      * public for convenience.
      *
-     * @return true if the user is logged in, false otherwise
      */
-    boolean quietLogin();
+    void quietLogin();
 
     /**
      * Returns the currently authenticated user
@@ -81,15 +80,14 @@ public interface Identity
      * org.jboss.seam.security.events.LoginFailedEvent - raised when authentication fails
      * org.jboss.seam.security.events.AlreadyLoggedInEvent - raised if the user is already authenticated
      *
-     * @return String returns RESPONSE_LOGIN_SUCCESS if user is authenticated, 
-     * RESPONSE_LOGIN_FAILED if authentication failed, or
-     * RESPONSE_LOGIN_EXCEPTION if an exception occurred during authentication. These response
-     * codes may be used to control user navigation.  For deferred authentication methods, such as Open ID
-     * the login() method will return an immediate result of RESPONSE_LOGIN_FAILED (and subsequently fire
+     * @return AuthenticationResult returns success if user is authenticated, 
+     * failed if authentication failed, or
+     * exception if an exception occurred during authentication. These response
+     * values may be used to control user navigation.  For deferred authentication methods, such as Open ID
+     * the login() method will return an immediate result of failed (and subsequently fire
      * a LoginFailedEvent) however in these conditions it is the responsibility of the Authenticator
      * implementation to take over the authentication process, for example by redirecting the user to
-     * another authentication service.
-     * 
+     * a third party authentication service such as an OpenID provider.
      */
     AuthenticationResult login();
 

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AlreadyLoggedInEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AlreadyLoggedInEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AlreadyLoggedInEvent.java
new file mode 100644
index 0000000..b47c2d6
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AlreadyLoggedInEvent.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is fired when an already authenticated user attempts to authenticate again
+ */
+public class AlreadyLoggedInEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AuthorizationCheckEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AuthorizationCheckEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AuthorizationCheckEvent.java
new file mode 100644
index 0000000..6d8cd7a
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/AuthorizationCheckEvent.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+/**
+ * This event may be used to perform an authorization check.  The constructor
+ * should be provided with one or more annotation literal values representing the
+ * security binding types to be checked.  After firing the event, the isPassed()
+ * method should be used to determine whether the authorization check was
+ * successful.
+ * <p/>
+ * WARNING - This event should only be fired and observed synchronously.
+ * Unpredictable results may occur otherwise.
+ */
+public class AuthorizationCheckEvent 
+{
+    private boolean passed;
+    
+    private List<? extends Annotation> bindings;
+
+    public AuthorizationCheckEvent(List<? extends Annotation> bindings) 
+    {
+        this.bindings = bindings;
+    }
+
+    public List<? extends Annotation> getBindings() 
+    {
+        return bindings;
+    }
+
+    public void setPassed(boolean value) 
+    {
+        this.passed = value;
+    }
+
+    public boolean isPassed() 
+    {
+        return passed;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsInitializedEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsInitializedEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsInitializedEvent.java
new file mode 100644
index 0000000..f01cf66
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsInitializedEvent.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+import org.apache.deltaspike.security.api.Credentials;
+
+/**
+ * This event is raised when credentials are initialized
+ *
+ */
+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;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsUpdatedEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsUpdatedEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsUpdatedEvent.java
new file mode 100644
index 0000000..3445734
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/CredentialsUpdatedEvent.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised when credentials are updated
+ *
+ */
+public class CredentialsUpdatedEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/DeferredAuthenticationEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/DeferredAuthenticationEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/DeferredAuthenticationEvent.java
new file mode 100644
index 0000000..118c9fe
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/DeferredAuthenticationEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event should be fired when a deferred authentication process has completed
+ *
+ */
+public class DeferredAuthenticationEvent 
+{
+    
+    private boolean success = false;
+    
+    public DeferredAuthenticationEvent(boolean success) 
+    {
+        this.success = success;
+    }
+    
+    public boolean isSuccess() 
+    {
+        return success;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoggedInEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoggedInEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoggedInEvent.java
new file mode 100644
index 0000000..00dc389
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoggedInEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+import org.apache.deltaspike.security.api.User;
+
+/**
+ * This event is raised when user successfully logs in.
+ */
+public class LoggedInEvent 
+{
+    private User user;
+
+    public LoggedInEvent(User user) 
+    {
+        this.user = user;
+    }
+
+    public User getUser() 
+    {
+        return user;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoginFailedEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoginFailedEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoginFailedEvent.java
new file mode 100644
index 0000000..ba20a79
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/LoginFailedEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is fired when an authentication attempt fails
+ */
+public class LoginFailedEvent 
+{
+    private Exception loginException;
+
+    public LoginFailedEvent(Exception loginException) 
+    {
+        this.loginException = loginException;
+    }
+
+    public Exception getLoginException() 
+    {
+        return loginException;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotAuthorizedEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotAuthorizedEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotAuthorizedEvent.java
new file mode 100644
index 0000000..214a296
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotAuthorizedEvent.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised when the user is not authorized to perform an operation
+ */
+public class NotAuthorizedEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotLoggedInEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotLoggedInEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotLoggedInEvent.java
new file mode 100644
index 0000000..ec269cc
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/NotLoggedInEvent.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised when an unauthenticated user attempts to performed a privileged operation
+ */
+public class NotLoggedInEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostAuthenticateEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostAuthenticateEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostAuthenticateEvent.java
new file mode 100644
index 0000000..665be30
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostAuthenticateEvent.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised just after authentication
+ */
+public class PostAuthenticateEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostLoggedOutEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostLoggedOutEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostLoggedOutEvent.java
new file mode 100644
index 0000000..99f5152
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PostLoggedOutEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api.events;
+
+import org.apache.deltaspike.security.api.User;
+
+/**
+ * This event is raised just after the user un-authenticates
+ */
+public class PostLoggedOutEvent 
+{
+    private User user;
+
+    public PostLoggedOutEvent(User user) 
+    {
+        this.user = user;
+    }
+
+    public User getUser() 
+    {
+        return user;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreAuthenticateEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreAuthenticateEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreAuthenticateEvent.java
new file mode 100644
index 0000000..80cd215
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreAuthenticateEvent.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised just before authentication.
+ */
+public class PreAuthenticateEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreLoggedOutEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreLoggedOutEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreLoggedOutEvent.java
new file mode 100644
index 0000000..d901794
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/PreLoggedOutEvent.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised just before the user un-authenticates
+ */
+public class PreLoggedOutEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/QuietLoginEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/QuietLoginEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/QuietLoginEvent.java
new file mode 100644
index 0000000..74038f4
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/QuietLoginEvent.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised when the user performs a quiet login
+ */
+public class QuietLoginEvent 
+{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/UserAuthenticatedEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/UserAuthenticatedEvent.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/UserAuthenticatedEvent.java
new file mode 100644
index 0000000..4c7bb61
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/events/UserAuthenticatedEvent.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.api.events;
+
+/**
+ * This event is raised when a user is authenticated
+ */
+public class UserAuthenticatedEvent 
+{
+    private Object user;
+
+    public UserAuthenticatedEvent(Object user) 
+    {
+        this.user = user;
+    }
+
+    public Object getUser() 
+    {
+        return user;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/CredentialsImpl.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/CredentialsImpl.java b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/CredentialsImpl.java
new file mode 100644
index 0000000..a7bbaf9
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/CredentialsImpl.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.impl;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.deltaspike.security.api.Credential;
+import org.apache.deltaspike.security.api.Credentials;
+import org.apache.deltaspike.security.api.events.CredentialsInitializedEvent;
+import org.apache.deltaspike.security.api.events.CredentialsUpdatedEvent;
+import org.apache.deltaspike.security.api.events.LoginFailedEvent;
+
+/**
+ * The default Credentials implementation.  This implementation allows for a
+ * username and plain text password to be set, and uses the PasswordCredential
+ * implementation of the Credential interface for authentication.
+ */
+@Named("credentials")
+@SessionScoped
+public class CredentialsImpl implements Credentials, Serializable 
+{
+    private static final long serialVersionUID = -2271248957776488426L;
+
+    @Inject
+    BeanManager manager;
+
+    private String username;
+    private Credential credential;
+
+    private boolean invalid;
+
+    private boolean initialized;
+
+    public CredentialsImpl() 
+    {
+    }
+
+    public boolean isInitialized() 
+    {
+        return initialized;
+    }
+
+    public void setInitialized(boolean initialized) 
+    {
+        this.initialized = initialized;
+    }
+
+    public String getUsername() 
+    {
+        if (!isInitialized()) 
+        {
+            setInitialized(true);
+            manager.fireEvent(new CredentialsInitializedEvent(this));
+        }
+
+        return username;
+    }
+
+    public Credential getCredential() 
+    {
+        return credential;
+    }
+
+    public void setCredential(Credential credential) 
+    {
+        this.credential = credential;
+    }
+
+    public void setUsername(String username) 
+    {
+        if (this.username != username && (this.username == null || !this.username.equals(username))) 
+        {
+            this.username = username;
+            invalid = false;
+            manager.fireEvent(new CredentialsUpdatedEvent());
+        }
+    }
+
+    public String getPassword() 
+    {
+        return credential != null && credential instanceof PasswordCredential ?
+                ((PasswordCredential) credential).getValue() : null;
+    }
+
+    public void setPassword(String password) 
+    {
+        if (this.credential == null) 
+        {
+            this.credential = new PasswordCredential(password);
+        } 
+        else if (this.credential != null && this.credential instanceof PasswordCredential &&
+                ((PasswordCredential) this.credential).getValue() != password &&
+                ((PasswordCredential) this.credential).getValue() == null ||
+                !((PasswordCredential) this.credential).getValue().equals(password)) 
+        {
+            this.credential = new PasswordCredential(password);
+            invalid = false;
+            manager.fireEvent(new CredentialsUpdatedEvent());
+        }
+    }
+
+    public boolean isSet() 
+    {
+        return getUsername() != null && this.credential != null &&
+                ((PasswordCredential) this.credential).getValue() != null;
+    }
+
+    public boolean isInvalid() 
+    {
+        return invalid;
+    }
+
+    public void invalidate() 
+    {
+        invalid = true;
+    }
+
+    public void clear() 
+    {
+        username = null;
+        this.credential = null;
+        initialized = false;
+    }
+
+    public void loginFailed(@Observes LoginFailedEvent event) 
+    {
+        invalidate();
+    }
+
+    @Override
+    public String toString() 
+    {
+        return "Credentials[" + username + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/IdentityImpl.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/IdentityImpl.java b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/IdentityImpl.java
new file mode 100644
index 0000000..d098710
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/IdentityImpl.java
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.impl;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.apache.deltaspike.security.Group;
+import org.apache.deltaspike.security.api.AuthenticationException;
+import org.apache.deltaspike.security.api.Credentials;
+import org.apache.deltaspike.security.api.Identity;
+import org.apache.deltaspike.security.api.Role;
+import org.apache.deltaspike.security.api.User;
+import org.apache.deltaspike.security.api.events.AlreadyLoggedInEvent;
+import org.apache.deltaspike.security.api.events.LoggedInEvent;
+import org.apache.deltaspike.security.api.events.LoginFailedEvent;
+import org.apache.deltaspike.security.api.events.PostLoggedOutEvent;
+import org.apache.deltaspike.security.api.events.PreLoggedOutEvent;
+import org.apache.deltaspike.security.api.events.QuietLoginEvent;
+import org.apache.deltaspike.security.spi.Authenticator;
+
+/**
+ * Default Identity implementation
+ */
+public class IdentityImpl implements Identity
+{
+    @Inject 
+    private BeanManager beanManager;
+    
+    @Inject
+    private Credentials credentials;
+    
+    @Inject 
+    private Instance<RequestSecurityState> requestSecurityState;
+    
+    private User user;
+    
+    private Class<? extends Authenticator> authenticatorClass;
+    
+    private String authenticatorName;    
+    
+    private Set<Role> userRoles = new HashSet<Role>();
+
+    private Set<Group> userGroups = new HashSet<Group>();    
+
+    public boolean isLoggedIn() 
+    {
+        // If there is a user set, then the user is logged in.
+        return user != null;
+    }    
+
+    public boolean isVerified() 
+    {
+        // TODO Discuss user verification requirements
+        return false;
+    }
+    
+    public User getUser() 
+    {
+        return user;
+    }    
+
+    public void quietLogin() 
+    {
+        try 
+        {
+            beanManager.fireEvent(new QuietLoginEvent());
+
+            // Ensure that we haven't been authenticated as a result of the EVENT_QUIET_LOGIN event
+            if (!isLoggedIn()) 
+            {
+                if (credentials.isSet()) 
+                {
+                    authenticate();
+
+                    if (isLoggedIn()) 
+                    {
+                        requestSecurityState.get().setSilentLogin(true);
+                    }
+                }
+            }
+        } 
+        catch (Exception ex) 
+        {
+            //log.error("Error while authenticating", ex);
+            credentials.invalidate();
+        }
+    }
+
+    @Override
+    public AuthenticationResult login() 
+    {
+        try 
+        {
+            if (isLoggedIn()) 
+            {
+                // If authentication has already occurred during this request via a silent login,
+                // and login() is explicitly called then we still want to raise the LOGIN_SUCCESSFUL event,
+                // and then return.
+                if (requestSecurityState.get().isSilentLogin()) 
+                {
+                    beanManager.fireEvent(new LoggedInEvent(user));
+                    return AuthenticationResult.success;
+                }
+
+                beanManager.fireEvent(new AlreadyLoggedInEvent());
+                return AuthenticationResult.success;
+            }
+
+            boolean success = authenticate();
+
+            if (success) 
+            {
+                //if (log.isDebugEnabled()) 
+                //{
+                //    log.debug("Login successful");
+                //}
+                beanManager.fireEvent(new LoggedInEvent(user));
+                return AuthenticationResult.success;
+            }
+
+            beanManager.fireEvent(new LoginFailedEvent(null));
+            return AuthenticationResult.failed;
+        } 
+        catch (Exception ex) 
+        {
+            //log.error("Login failed", ex);
+
+            beanManager.fireEvent(new LoginFailedEvent(ex));
+
+            return AuthenticationResult.exception;
+        }
+    }
+    
+    protected boolean authenticate() throws AuthenticationException 
+    {
+        // TODO discuss authentication API
+        return false;
+    }    
+
+    @Override
+    public void logout() 
+    {
+        if (isLoggedIn()) 
+        {
+            PostLoggedOutEvent loggedOutEvent = new PostLoggedOutEvent(user);
+
+            beanManager.fireEvent(new PreLoggedOutEvent());
+            unAuthenticate();
+
+            // TODO invalidate the session
+            //session.invalidate();
+
+            beanManager.fireEvent(loggedOutEvent);
+        }        
+    }
+    
+    /**
+     * Resets all security state and credentials
+     */
+    public void unAuthenticate() 
+    {    
+        user = null;
+        credentials.clear();
+        userRoles.clear();
+        userGroups.clear();
+    }    
+
+    public boolean hasRole(String role, String group, String groupType) 
+    {
+        // TODO discuss user/role/group API
+        return false;
+    }
+
+    public boolean inGroup(String name, String groupType) 
+    {
+        // TODO discuss user/role/group API
+        return false;
+    }
+
+    public boolean hasPermission(Object resource, String permission) 
+    {
+        // TODO discuss user/role/group API
+        return false;
+    }
+
+    public Set<Role> getRoles() 
+    {
+        return Collections.unmodifiableSet(userRoles);
+    }
+
+    public Set<Group> getGroups() 
+    {
+        return Collections.unmodifiableSet(userGroups);
+    }
+
+    public Class<? extends Authenticator> getAuthenticatorClass() 
+    {
+        return authenticatorClass;
+    }
+
+    public void setAuthenticatorClass(Class<? extends Authenticator> authenticatorClass) 
+    {
+        this.authenticatorClass = authenticatorClass;
+    }
+
+    public String getAuthenticatorName() 
+    {
+        return authenticatorName;
+    }
+
+    public void setAuthenticatorName(String authenticatorName) 
+    {
+        this.authenticatorName = authenticatorName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/PasswordCredential.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/PasswordCredential.java b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/PasswordCredential.java
new file mode 100644
index 0000000..d5c27d9
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/PasswordCredential.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.impl;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import org.apache.deltaspike.security.api.Credential;
+import org.apache.deltaspike.security.api.CredentialType;
+
+/**
+ * A credential that represents a plain text password.
+ */
+public class PasswordCredential implements Credential 
+{
+    public static final SimpleCredentialType TYPE  = new SimpleCredentialType("PASSWORD");
+    
+    private final String value;
+       
+    public PasswordCredential(String value)
+    {
+        this.value = value;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+    
+    public CredentialType getType() 
+    {
+        return TYPE;
+    }
+
+    public Object getEncodedValue()
+    {
+        if (value != null)
+        {
+            return md5AsHexString(getValue());
+        }
+        return null;
+    }
+    
+    /**
+     * Computes an md5 hash of a string.
+     *
+     * @param text the hashed string
+     * @return the string hash
+     * @throws NullPointerException if text is null
+     */
+    public static byte[] md5(String text)
+    {
+        // arguments check
+        if (text == null)
+        {
+            throw new NullPointerException("null text");
+        }
+
+        try
+        {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            md.update(text.getBytes());
+            return md.digest();
+        }
+        catch (NoSuchAlgorithmException e)
+        {
+            throw new RuntimeException("Cannot find MD5 algorithm");
+        }
+    }
+
+    /**
+     * Computes an md5 hash and returns the result as a string in hexadecimal format.
+     *
+     * @param text the hashed string
+     * @return the string hash
+     * @throws NullPointerException if text is null
+     */
+    public static String md5AsHexString(String text)
+    {
+        return toHexString(md5(text));
+    }
+
+    /**
+     * Returns a string in the hexadecimal format.
+     *
+     * @param bytes the converted bytes
+     * @return the hexadecimal string representing the bytes data
+     * @throws IllegalArgumentException if the byte array is null
+     */
+    public static String toHexString(byte[] bytes)
+    {
+        if (bytes == null)
+        {
+            throw new IllegalArgumentException("byte array must not be null");
+        }
+        
+        StringBuffer hex = new StringBuffer(bytes.length * 2);
+        for (int i = 0; i < bytes.length; i++)
+        {
+            hex.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16));
+            hex.append(Character.forDigit((bytes[i] & 0X0F), 16));
+        }
+        
+        return hex.toString();
+    }    
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/RequestSecurityState.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/RequestSecurityState.java b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/RequestSecurityState.java
new file mode 100644
index 0000000..6997f8c
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/RequestSecurityState.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.impl;
+
+import javax.enterprise.context.RequestScoped;
+
+/**
+ * Contains the authentication state of the current request
+ */
+@RequestScoped
+public class RequestSecurityState 
+{
+    private boolean silentLogin;
+    private boolean loginTried;
+    private boolean authenticating;
+
+    public boolean isSilentLogin() 
+    {
+        return silentLogin;
+    }
+
+    public void setSilentLogin(boolean silentLogin) 
+    {
+        this.silentLogin = silentLogin;
+    }
+
+    public boolean isLoginTried() 
+    {
+        return loginTried;
+    }
+
+    public void setLoginTried(boolean loginTried) 
+    {
+        this.loginTried = loginTried;
+    }
+    
+    public boolean isAuthenticating() 
+    {
+        return authenticating;
+    }
+    
+    public void setAuthenticating(boolean authenticating)
+    {
+        this.authenticating = authenticating;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/SimpleCredentialType.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/SimpleCredentialType.java b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/SimpleCredentialType.java
new file mode 100644
index 0000000..4665407
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/SimpleCredentialType.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.security.impl;
+
+import org.apache.deltaspike.security.api.CredentialType;
+
+public class SimpleCredentialType implements CredentialType 
+{
+    private final String name;
+
+    public SimpleCredentialType(String name)
+    {
+        this.name = name;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/secured/SecuredBeanWithStereotype.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/secured/SecuredBeanWithStereotype.java b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/secured/SecuredBeanWithStereotype.java
index 2d65bb9..0e1a215 100644
--- a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/secured/SecuredBeanWithStereotype.java
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/secured/SecuredBeanWithStereotype.java
@@ -31,7 +31,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
 @Stereotype
 
 @Retention(value = RUNTIME)
-@Target({TYPE, METHOD})
+@Target({TYPE, METHOD} )
 
 @Secured(TestAccessDecisionVoter.class)
 public @interface SecuredBeanWithStereotype

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3edae619/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
index 6bc2cec..fb93c2f 100644
--- a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
@@ -120,7 +120,8 @@ public class ShrinkWrapArchiveUtil
     private static JavaArchive addJarArchive(InputStream inputStream,
                                              String[] includeIfPackageExists,
                                              String[] excludeIfPackageExists)
-            throws IOException {
+        throws IOException 
+    {
         JavaArchive ret = null;
         JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class);