[jboss-cvs] jboss-seam/src/main/org/jboss/seam/security ...
Shane Bryzak
Shane_Bryzak at symantec.com
Sun Jan 7 21:55:40 EST 2007
User: sbryzak2
Date: 07/01/07 21:55:40
Modified: src/main/org/jboss/seam/security Identity.java
Added: src/main/org/jboss/seam/security SimpleGroup.java
SimplePrincipal.java
Removed: src/main/org/jboss/seam/security
UsernamePasswordToken.java
Log:
changed the role of the Identity class
Revision Changes Path
1.7 +26 -11 jboss-seam/src/main/org/jboss/seam/security/Identity.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Identity.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/Identity.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Identity.java 2 Jan 2007 07:42:57 -0000 1.6
+++ Identity.java 8 Jan 2007 02:55:40 -0000 1.7
@@ -6,6 +6,8 @@
import java.io.Serializable;
import java.security.Principal;
+import javax.security.auth.Subject;
+
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.Seam;
@@ -17,12 +19,21 @@
@Name("org.jboss.seam.security.identity")
@Scope(SESSION)
@Install(precedence = BUILT_IN, dependencies = "org.jboss.seam.securityManager")
-public abstract class Identity implements Principal, Serializable
+public class Identity implements Serializable
{
protected boolean authenticated;
protected boolean valid;
+ protected Principal principal;
+
+ protected Subject subject;
+
+ public Identity()
+ {
+ subject = new Subject();
+ }
+
public static Identity instance()
{
if (!Contexts.isSessionContextActive())
@@ -47,11 +58,15 @@
Seam.getComponentName(Identity.class));
}
- public abstract Role[] getRoles();
-
- public abstract Object getCredentials();
+ public Principal getPrincipal()
+ {
+ return principal;
+ }
- public abstract Object getPrincipal();
+ public Subject getSubject()
+ {
+ return subject;
+ }
public final boolean isAuthenticated()
{
@@ -77,11 +92,11 @@
*/
public boolean isUserInRole(String role)
{
- for (Role r : getRoles())
- {
- if (r.getName().equals(role))
- return true;
- }
+// for (Role r : getRoles())
+// {
+// if (r.getName().equals(role))
+// return true;
+// }
return false;
}
}
1.1 date: 2007/01/08 02:55:40; author: sbryzak2; state: Exp;jboss-seam/src/main/org/jboss/seam/security/SimpleGroup.java
Index: SimpleGroup.java
===================================================================
package org.jboss.seam.security;
import java.io.Serializable;
import java.security.Principal;
import java.security.acl.Group;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
/**
* Implementation of the Group interface, used for holding roles etc.
*
* @author Shane Bryzak
*/
public class SimpleGroup implements Group, Serializable
{
private static final long serialVersionUID = 5766373925836425908L;
/**
* The name of the group
*/
private String name;
/**
* The members of this group
*/
private Set<Principal> members = new HashSet<Principal>();
public SimpleGroup(String name)
{
this.name = name;
}
public boolean addMember(Principal user)
{
return members.add(user);
}
public boolean isMember(Principal member)
{
if (members.contains(member))
return true;
else
{
for (Principal m : members)
{
if (m instanceof Group && ((Group) m).isMember(member))
return true;
}
}
return false;
}
public Enumeration<? extends Principal> members()
{
return Collections.enumeration(members);
}
public boolean removeMember(Principal user)
{
return members.remove(user);
}
public String getName()
{
return name;
}
public boolean equals(Object obj)
{
if (!(obj instanceof SimpleGroup))
return false;
SimpleGroup other = (SimpleGroup) obj;
return other.name.equals(name);
}
public int hashCode()
{
return name.hashCode();
}
}
1.1 date: 2007/01/08 02:55:40; author: sbryzak2; state: Exp;jboss-seam/src/main/org/jboss/seam/security/SimplePrincipal.java
Index: SimplePrincipal.java
===================================================================
package org.jboss.seam.security;
import java.security.Principal;
/**
* Simple implementation of the Principal interface, supporting a named user.
*
* @author Shane Bryzak
*/
public class SimplePrincipal implements Principal
{
private String name;
public SimplePrincipal(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
More information about the jboss-cvs-commits
mailing list