[seam-commits] Seam SVN: r12734 - in modules/security/trunk: api/src/main/java/org/jboss/seam/security and 2 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sun May 16 04:19:19 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-05-16 04:19:18 -0400 (Sun, 16 May 2010)
New Revision: 12734
Added:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Attribute.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialType.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Group.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/RoleType.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PicketLinkIdentityStore.java
Removed:
modules/security/trunk/api/src/main/java/org/jboss/seam/security/api/
Modified:
modules/security/trunk/api/pom.xml
modules/security/trunk/api/src/main/java/org/jboss/seam/security/Credentials.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Role.java
Log:
refactored
Modified: modules/security/trunk/api/pom.xml
===================================================================
--- modules/security/trunk/api/pom.xml 2010-05-15 18:38:06 UTC (rev 12733)
+++ modules/security/trunk/api/pom.xml 2010-05-16 08:19:18 UTC (rev 12734)
@@ -21,6 +21,12 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.picketlink.idm</groupId>
+ <artifactId>picketlink-idm-api</artifactId>
+ <version>1.1.2.CR01</version>
+ </dependency>
+
</dependencies>
<build>
Modified: modules/security/trunk/api/src/main/java/org/jboss/seam/security/Credentials.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/Credentials.java 2010-05-15 18:38:06 UTC (rev 12733)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/Credentials.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -1,5 +1,7 @@
package org.jboss.seam.security;
+import org.picketlink.idm.api.Credential;
+
/**
* Represents the credentials the current user will use to authenticate
*
@@ -12,9 +14,9 @@
void setUsername(String username);
- String getPassword();
+ Credential getCredential();
- void setPassword(String password);
+ void setCredential(Credential credential);
boolean isSet();
Copied: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Attribute.java (from rev 12710, modules/security/trunk/api/src/main/java/org/jboss/seam/security/api/Attribute.java)
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Attribute.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Attribute.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -0,0 +1,43 @@
+package org.jboss.seam.security;
+
+import java.util.Collection;
+
+/**
+ * Seam implementation of the PicketLink Attribute interface
+ *
+ * @author Shane Bryzak
+ */
+public class Attribute implements org.picketlink.idm.api.Attribute
+{
+
+ public void addValue(Object arg0)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getValue()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Collection<?> getValues()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Copied: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialType.java (from rev 12710, modules/security/trunk/api/src/main/java/org/jboss/seam/security/api/CredentialType.java)
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialType.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialType.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -0,0 +1,23 @@
+package org.jboss.seam.security;
+
+/**
+ * Seam implementation of the PicketLink CredentialType interface. A
+ * CredentialType represents a type of credential, e.g. password, certificate, etc.
+ *
+ * @author Shane Bryzak
+ */
+public class CredentialType implements org.picketlink.idm.api.CredentialType
+{
+ private String name;
+
+ public CredentialType(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java 2010-05-15 18:38:06 UTC (rev 12733)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -9,8 +9,16 @@
import org.jboss.seam.security.events.CredentialsInitializedEvent;
import org.jboss.seam.security.events.CredentialsUpdatedEvent;
+import org.picketlink.idm.api.Credential;
- at Named//("org.jboss.seam.security.credentials")
+/**
+ * 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.
+ *
+ * @author Shane Bryzak
+ */
+ at Named
@SessionScoped
public class CredentialsImpl implements Credentials, Serializable
{
@@ -19,7 +27,7 @@
@Inject BeanManager manager;
private String username;
- private String password;
+ private Credential credential;
private boolean invalid;
@@ -48,6 +56,16 @@
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)))
@@ -60,14 +78,23 @@
public String getPassword()
{
- return password;
+ return credential != null && credential instanceof PasswordCredential ?
+ ((PasswordCredential) credential).getPassword() : null;
}
public void setPassword(String password)
{
- if (this.password != password && (this.password == null || !this.password.equals(password)))
+ if (this.credential == null)
{
- this.password = password;
+ this.credential = new PasswordCredential();
+ ((PasswordCredential) this.credential).setPassword(password);
+ }
+ else if (this.credential != null && this.credential instanceof PasswordCredential &&
+ ((PasswordCredential) this.credential).getPassword() != password &&
+ ((PasswordCredential) this.credential).getPassword() == null ||
+ !((PasswordCredential) this.credential).getPassword().equals(password))
+ {
+ ((PasswordCredential) this.credential).setPassword(password);
invalid = false;
manager.fireEvent(new CredentialsUpdatedEvent());
}
@@ -75,7 +102,8 @@
public boolean isSet()
{
- return getUsername() != null && password != null;
+ return getUsername() != null && this.credential != null &&
+ ((PasswordCredential) this.credential).getPassword() != null;
}
public boolean isInvalid()
@@ -91,7 +119,7 @@
public void clear()
{
username = null;
- password = null;
+ this.credential = null;
initialized = false;
}
Copied: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Group.java (from rev 12710, modules/security/trunk/api/src/main/java/org/jboss/seam/security/api/Group.java)
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Group.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Group.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -0,0 +1,33 @@
+package org.jboss.seam.security;
+
+/**
+ * Seam implementation of the PicketLink Group interface.
+ *
+ * @author Shane Bryzak
+ */
+public class Group implements org.picketlink.idm.api.Group
+{
+ private String groupType;
+ private String name;
+
+ public Group(String groupType, String name)
+ {
+ this.groupType = groupType;
+ this.name = name;
+ }
+
+ public String getGroupType()
+ {
+ return groupType;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getKey()
+ {
+ return String.format("jbpid_group_id_._._%s_._._%s", groupType, name);
+ }
+}
Copied: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java (from rev 12710, modules/security/trunk/api/src/main/java/org/jboss/seam/security/api/PasswordCredential.java)
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -0,0 +1,32 @@
+package org.jboss.seam.security;
+
+import javax.enterprise.context.RequestScoped;
+
+
+/**
+ * Seam implementation of the PicketLink Credential interface
+ *
+ * @author Shane Bryzak
+ */
+ at RequestScoped
+public class PasswordCredential implements org.picketlink.idm.api.Credential
+{
+ private static final CredentialType CREDENTIAL_TYPE = new CredentialType("password");
+
+ private String password;
+
+ public org.picketlink.idm.api.CredentialType getType()
+ {
+ return CREDENTIAL_TYPE;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Role.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Role.java 2010-05-15 18:38:06 UTC (rev 12733)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Role.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -1,30 +1,49 @@
package org.jboss.seam.security;
+import org.picketlink.idm.api.Group;
+import org.picketlink.idm.api.RoleType;
+import org.picketlink.idm.api.User;
+
/**
- * Represents a user role. A conditional role is a special type of role that is assigned to a user
- * based on the contextual state of a permission check.
+ * Seam implementation of the PicketLink Role interface. Each role is a direct
+ * one-to-one mapping between User and Group.
*
* @author Shane Bryzak
*/
-public class Role extends SimplePrincipal
+public class Role implements org.picketlink.idm.api.Role
{
private static final long serialVersionUID = 1187276024036531700L;
private boolean conditional;
- public Role(String name)
- {
- super(name);
- }
+ private Group group;
+ private RoleType roleType;
+ private User user;
- public Role(String name, boolean conditional)
+ public Role(Group group, RoleType roleType, User user)
{
- this(name);
- this.conditional = conditional;
+ this.group = group;
+ this.roleType = roleType;
+ this.user = user;
}
-
+
public boolean isConditional()
{
return conditional;
}
+
+ public Group getGroup()
+ {
+ return group;
+ }
+
+ public RoleType getRoleType()
+ {
+ return roleType;
+ }
+
+ public User getUser()
+ {
+ return user;
+ }
}
Copied: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/RoleType.java (from rev 12710, modules/security/trunk/api/src/main/java/org/jboss/seam/security/api/RoleType.java)
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/RoleType.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/RoleType.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -0,0 +1,23 @@
+package org.jboss.seam.security;
+
+/**
+ * Seam implementation of the PicketLink RoleType interface. A RoleType is
+ * essentially the name of a particular role. E.g. manager, user, superuser, etc.
+ *
+ * @author Shane Bryzak
+ */
+public class RoleType implements org.picketlink.idm.api.RoleType
+{
+ private String name;
+
+ public RoleType(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+}
Added: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PicketLinkIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PicketLinkIdentityStore.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PicketLinkIdentityStore.java 2010-05-16 08:19:18 UTC (rev 12734)
@@ -0,0 +1,160 @@
+package org.jboss.seam.security.management;
+
+import java.security.Principal;
+import java.util.List;
+
+public class PicketLinkIdentityStore implements IdentityStore
+{
+
+ public boolean addRoleToGroup(String role, String group)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean authenticate(String username, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean changePassword(String name, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createRole(String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createUser(String username, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createUser(String username, String password,
+ String firstname, String lastname)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteRole(String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteUser(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean disableUser(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean enableUser(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public List<String> getGrantedRoles(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> getImpliedRoles(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> getRoleGroups(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean grantRole(String name, String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isUserEnabled(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public List<String> listGrantableRoles()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Principal> listMembers(String role)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> listRoles()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> listUsers()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> listUsers(String filter)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean removeRoleFromGroup(String role, String group)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean revokeRole(String name, String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean roleExists(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean supportsFeature(Feature feature)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean userExists(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
More information about the seam-commits
mailing list