[jboss-cvs] JBossAS SVN: r67197 - in projects/security/security-jboss-sx/trunk: identity and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 16 14:37:25 EST 2007
Author: anil.saldhana at jboss.com
Date: 2007-11-16 14:37:25 -0500 (Fri, 16 Nov 2007)
New Revision: 67197
Added:
projects/security/security-jboss-sx/trunk/identity/
projects/security/security-jboss-sx/trunk/identity/.classpath
projects/security/security-jboss-sx/trunk/identity/.project
projects/security/security-jboss-sx/trunk/identity/bin/
projects/security/security-jboss-sx/trunk/identity/bin/org/
projects/security/security-jboss-sx/trunk/identity/bin/org/jboss/
projects/security/security-jboss-sx/trunk/identity/bin/org/jboss/security/
projects/security/security-jboss-sx/trunk/identity/bin/org/jboss/security/identity/
projects/security/security-jboss-sx/trunk/identity/bin/org/jboss/security/identity/plugins/
projects/security/security-jboss-sx/trunk/identity/pom.xml
projects/security/security-jboss-sx/trunk/identity/src/
projects/security/security-jboss-sx/trunk/identity/src/etc/
projects/security/security-jboss-sx/trunk/identity/src/main/
projects/security/security-jboss-sx/trunk/identity/src/main/org/
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/AnybodyPrincipal.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/NobodyPrincipal.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimpleGroup.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimplePrincipal.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java
projects/security/security-jboss-sx/trunk/identity/src/resources/
projects/security/security-jboss-sx/trunk/identity/src/tests/
Modified:
projects/security/security-jboss-sx/trunk/pom.xml
Log:
SECURITY-93:identity simple impl
Added: projects/security/security-jboss-sx/trunk/identity/.classpath
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/.classpath (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/.classpath 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="src" path="src/resources"/>
+ <classpathentry excluding="resources/" kind="src" output="target/test-classes" path="src/tests"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.0.2-SNAPSHOT/jboss-security-spi-2.0.2-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/security/jboss-security-spi/2.0.2-SNAPSHOT/spi-2.0.2-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-test/1.0.3.GA/jboss-test-1.0.3.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.1.GA/jboss-common-core-2.2.1.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar"/>
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>
Added: projects/security/security-jboss-sx/trunk/identity/.project
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/.project (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/.project 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>identity</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/security/security-jboss-sx/trunk/identity/pom.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/pom.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/pom.xml 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,211 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-aggregator</artifactId>
+ <version>2.0.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>identity-impl</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Security Identity Implementation</name>
+ <url>http://labs.jboss.org/portal/jbosssecurity/</url>
+ <description>JBoss Security is a cross cutting project that handles security for the JEMS projects</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <profiles>
+ <!-- mvn install -Psecurity-manager -->
+ <profile>
+ <id>security-manager</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <test.env>-Dtest.basedir=${basedir}/target/test-classes</test.env>
+ <policy.file>${basedir}/src/tests/resources/java.policy</policy.file>
+ <surefire.jvm.args>-Djava.security.manager -Djava.security.policy=${policy.file} ${test.env}</surefire.jvm.args>
+ </properties>
+ </profile>
+ <!-- mvn install -Psecurity-manager-debug -->
+ <!-- Best Practice: mvn install -Psecurity-manager-debug 2>&1 > logfile2>&1 > logfile -->
+ <profile>
+ <id>security-manager-debug</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <test.env>-Dtest.basedir=${basedir}/target/test-classes</test.env>
+ <policy.file>${basedir}/src/tests/resources/java.policy</policy.file>
+ <surefire.jvm.args>-Djava.security.manager -Djava.security.policy=${policy.file} -Djava.security.debug=failure,access ${test.env}</surefire.jvm.args>
+ </properties>
+ </profile>
+ </profiles>
+ <build>
+ <sourceDirectory>src/main</sourceDirectory>
+ <testSourceDirectory>src/tests</testSourceDirectory>
+ <testOutputDirectory>target/test-classes</testOutputDirectory>
+ <finalName>${artifactId}</finalName>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>JBossORG-EULA.txt</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/resources</directory>
+ <includes>
+ <include>**/*.dtd</include>
+ <include>**/*.xsd</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>target/generated-sources/javacc</directory>
+ <includes>
+ <include>**/*.class</include>
+ </includes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/tests/resources/</directory>
+ </testResource>
+ <testResource>
+ <directory>src/main</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <!-- define that we wish to create src jars -->
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.0</version>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <printSummary>true</printSummary>
+ <disableXmlReport>false</disableXmlReport>
+ <testFailureIgnore>true</testFailureIgnore>
+ <includes>
+ <include>**/**TestCase.java</include>
+ </includes>
+ <forkMode>pertest</forkMode>
+ <argLine>${surefire.jvm.args}</argLine>
+ <useFile>false</useFile>
+ <trimStackTrace>false</trimStackTrace>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jboss-deploy-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jboss-deploy</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <groupId>jboss</groupId>
+ <license>lgpl</license>
+ <jbossDeployRoot>${jboss.repository.root}</jbossDeployRoot>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-classpath</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build-classpath</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.1.GA</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.0.2.GA</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>2.0.2.GA</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-security-spi</artifactId>
+ <version>2.0.2-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>1.0.3.GA</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/AnybodyPrincipal.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/AnybodyPrincipal.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/AnybodyPrincipal.java 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security;
+
+import java.security.Principal;
+
+/** An implementation of Principal and Comparable that represents any role.
+Any Principal or name of a Principal when compared to an AnybodyPrincipal
+using {@link #equals(Object) equals} or {@link #compareTo(Object) compareTo}
+will always be found equals to the AnybodyPrincipal.
+
+Note that this class is not likely to operate correctly in a collection
+since the hashCode() and equals() methods are not correlated.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 40069 $
+*/
+public class AnybodyPrincipal implements Comparable, Principal
+{
+ public static final String ANYBODY = "<ANYBODY>";
+ public static final AnybodyPrincipal ANYBODY_PRINCIPAL = new AnybodyPrincipal();
+
+ public int hashCode()
+ {
+ return ANYBODY.hashCode();
+ }
+
+ /**
+ @return "<ANYBODY>"
+ */
+ public String getName()
+ {
+ return ANYBODY;
+ }
+
+ public String toString()
+ {
+ return ANYBODY;
+ }
+
+ /** This method always returns 0 to indicate equality for any argument.
+ This is only meaningful when comparing against other Principal objects
+ or names of Principals.
+
+ @return true to indicate equality for any argument.
+ */
+ public boolean equals(Object another)
+ {
+ return true;
+ }
+
+ /** This method always returns 0 to indicate equality for any argument.
+ This is only meaningful when comparing against other Principal objects
+ or names of Principals.
+
+ @return 0 to indicate equality for any argument.
+ */
+ public int compareTo(Object o)
+ {
+ return 0;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/NobodyPrincipal.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/NobodyPrincipal.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/NobodyPrincipal.java 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security;
+
+import java.security.Principal;
+
+/** An implementation of Principal and Comparable that represents no role.
+Any Principal or name of a Principal when compared to an NobodyPrincipal
+using {@link #equals(Object) equals} or {@link #compareTo(Object) compareTo}
+will always be found not equal to the NobodyPrincipal.
+
+Note that this class is not likely to operate correctly in a collection
+since the hashCode() and equals() methods are not correlated.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 40069 $
+*/
+public class NobodyPrincipal implements Comparable, Principal
+{
+ public static final String NOBODY = "<NOBODY>";
+ public static final NobodyPrincipal NOBODY_PRINCIPAL = new NobodyPrincipal();
+
+ public int hashCode()
+ {
+ return NOBODY.hashCode();
+ }
+
+ /**
+ @return "<NOBODY>"
+ */
+ public String getName()
+ {
+ return NOBODY;
+ }
+
+ public String toString()
+ {
+ return NOBODY;
+ }
+
+ /** This method always returns 0 to indicate equality for any argument.
+ This is only meaningful when comparing against other Principal objects
+ or names of Principals.
+
+ @return false to indicate inequality for any argument.
+ */
+ public boolean equals(Object another)
+ {
+ return false;
+ }
+
+ /** This method always returns 1 to indicate inequality for any argument.
+ This is only meaningful when comparing against other Principal objects
+ or names of Principals.
+
+ @return 1 to indicate inequality for any argument.
+ */
+ public int compareTo(Object o)
+ {
+ return 1;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimpleGroup.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimpleGroup.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimpleGroup.java 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,147 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.HashMap;
+
+/** An implementation of Group that manages a collection of Principal
+objects based on their hashCode() and equals() methods. This class
+is not thread safe.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 67182 $
+*/
+public class SimpleGroup extends SimplePrincipal implements Group, Cloneable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 6051859639378507247L;
+
+ private HashMap members;
+
+ public SimpleGroup(String groupName)
+ {
+ super(groupName);
+ members = new HashMap(3);
+ }
+
+ /** Adds the specified member to the group.
+ @param user the principal to add to this group.
+ @return true if the member was successfully added,
+ false if the principal was already a member.
+ */
+ public boolean addMember(Principal user)
+ {
+ boolean isMember = members.containsKey(user);
+ if( isMember == false )
+ members.put(user, user);
+ return isMember == false;
+ }
+ /** Returns true if the passed principal is a member of the group.
+ This method does a recursive search, so if a principal belongs to a
+ group which is a member of this group, true is returned.
+
+ A special check is made to see if the member is an instance of
+ org.jboss.security.AnybodyPrincipal or org.jboss.security.NobodyPrincipal
+ since these classes do not hash to meaningful values.
+ @param member the principal whose membership is to be checked.
+ @return true if the principal is a member of this group,
+ false otherwise.
+ */
+ public boolean isMember(Principal member)
+ {
+ // First see if there is a key with the member name
+ boolean isMember = members.containsKey(member);
+ if( isMember == false )
+ { // Check the AnybodyPrincipal & NobodyPrincipal special cases
+ isMember = (member instanceof org.jboss.security.AnybodyPrincipal);
+ if( isMember == false )
+ {
+ if( member instanceof org.jboss.security.NobodyPrincipal )
+ return false;
+ }
+ }
+ if( isMember == false )
+ { // Check any Groups for membership
+ Collection values = members.values();
+ Iterator iter = values.iterator();
+ while( isMember == false && iter.hasNext() )
+ {
+ Object next = iter.next();
+ if( next instanceof Group )
+ {
+ Group group = (Group) next;
+ isMember = group.isMember(member);
+ }
+ }
+ }
+ return isMember;
+ }
+
+ /** Returns an enumeration of the members in the group.
+ The returned objects can be instances of either Principal
+ or Group (which is a subinterface of Principal).
+ @return an enumeration of the group members.
+ */
+ public Enumeration<Principal> members()
+ {
+ return Collections.enumeration(members.values());
+ }
+
+ /** Removes the specified member from the group.
+ @param user the principal to remove from this group.
+ @return true if the principal was removed, or
+ false if the principal was not a member.
+ */
+ public boolean removeMember(Principal user)
+ {
+ Object prev = members.remove(user);
+ return prev != null;
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer(getName());
+ tmp.append("(members:");
+ Iterator iter = members.keySet().iterator();
+ while( iter.hasNext() )
+ {
+ tmp.append(iter.next());
+ tmp.append(',');
+ }
+ tmp.setCharAt(tmp.length()-1, ')');
+ return tmp.toString();
+ }
+
+ public synchronized Object clone() throws CloneNotSupportedException
+ {
+ SimpleGroup clone = (SimpleGroup) super.clone();
+ if(clone != null)
+ clone.members = (HashMap)this.members.clone();
+ return clone;
+ }
+}
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimplePrincipal.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimplePrincipal.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/SimplePrincipal.java 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security;
+
+import java.security.Principal;
+
+/** A simple String based implementation of Principal. Typically
+a SimplePrincipal is created given a userID which is used
+as the Principal name.
+
+ at author <a href="on at ibis.odessa.ua">Oleg Nitz</a>
+ at author Scott.Stark at jboss.org
+*/
+public class SimplePrincipal implements Principal, java.io.Serializable
+{
+ private static final long serialVersionUID = 1L;
+ private String name;
+
+ public SimplePrincipal(String name)
+ {
+ this.name = name;
+ }
+
+ /** Compare this SimplePrincipal's name against another Principal
+ @return true if name equals another.getName();
+ */
+ public boolean equals(Object another)
+ {
+ if( !(another instanceof Principal) )
+ return false;
+ String anotherName = ((Principal)another).getName();
+ boolean equals = false;
+ if( name == null )
+ equals = anotherName == null;
+ else
+ equals = name.equals(anotherName);
+ return equals;
+ }
+
+ public int hashCode()
+ {
+ return (name == null ? 0 : name.hashCode());
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.identity.plugins;
+
+import java.io.Serializable;
+import java.security.Principal;
+import java.security.acl.Group;
+
+import org.jboss.security.SimpleGroup;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.security.identity.Identity;
+import org.jboss.security.identity.Role;
+
+//$Id$
+
+/**
+ * Simple Identity
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 16, 2007
+ * @version $Revision$
+ */
+public class SimpleIdentity implements Identity, Serializable
+{
+ private static final long serialVersionUID = 1L;
+ private String name;
+ private Role role;
+
+ public SimpleIdentity(String name)
+ {
+ this.name = name;
+ }
+
+ public SimpleIdentity(String name, String roleName)
+ {
+ this.name = name;
+ this.role = new SimpleRole(roleName);
+ }
+
+ public SimpleIdentity(String name, Role role)
+ {
+ this.name = name;
+ this.role = role;
+ }
+
+ public Group asGroup()
+ {
+ SimpleGroup sg = new SimpleGroup("Roles");
+ sg.addMember(new SimplePrincipal(role.getRoleName()));
+ return sg;
+ }
+
+ public Principal asPrincipal()
+ {
+ return new SimplePrincipal(name);
+ }
+
+ public String getName()
+ {
+ return this.name;
+ }
+
+ public Role getRole()
+ {
+ return this.role;
+ }
+}
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.identity.plugins;
+
+import java.io.Serializable;
+
+import org.jboss.security.identity.Role;
+import org.jboss.security.identity.RoleType;
+
+//$Id$
+
+/**
+ * Simple Role
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 16, 2007
+ * @version $Revision$
+ */
+public class SimpleRole implements Role, Serializable, Cloneable
+{
+ private static final long serialVersionUID = 1L;
+ private String roleName;
+
+ public SimpleRole(String roleName)
+ {
+ this.roleName = roleName;
+ }
+
+ public String getRoleName()
+ {
+ return this.roleName;
+ }
+
+ public RoleType getType()
+ {
+ return RoleType.simple;
+ }
+}
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java 2007-11-16 19:37:25 UTC (rev 67197)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.identity.plugins;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.security.identity.Role;
+import org.jboss.security.identity.RoleGroup;
+import org.jboss.security.identity.RoleType;
+
+//$Id$
+
+/**
+ * Simple Role Group
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 16, 2007
+ * @version $Revision$
+ */
+public class SimpleRoleGroup extends SimpleRole implements RoleGroup
+{
+ private static final long serialVersionUID = 1L;
+ private ArrayList<Role> roles;
+
+ public SimpleRoleGroup(String roleName)
+ {
+ super(roleName);
+ }
+
+ public SimpleRoleGroup(String roleName, List<Role> roles)
+ {
+ super(roleName);
+ if(this.roles == null)
+ this.roles = new ArrayList<Role>();
+ this.roles.addAll(roles);
+ }
+
+ @Override
+ public RoleType getType()
+ {
+ return RoleType.group;
+ }
+
+ public List<Role> getRoles()
+ {
+ return roles;
+ }
+
+ public synchronized Object clone() throws CloneNotSupportedException
+ {
+ SimpleRoleGroup clone = (SimpleRoleGroup) super.clone();
+ if(clone != null)
+ clone.roles = (ArrayList<Role>)this.roles.clone();
+ return clone;
+ }
+}
\ No newline at end of file
Modified: projects/security/security-jboss-sx/trunk/pom.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/pom.xml 2007-11-16 19:32:46 UTC (rev 67196)
+++ projects/security/security-jboss-sx/trunk/pom.xml 2007-11-16 19:37:25 UTC (rev 67197)
@@ -23,6 +23,7 @@
<url>http://www.jboss.org</url>
</organization>
<modules>
+ <module>identity</module>
<module>jbosssx</module>
<module>jbosssx-client</module>
<module>acl</module>
More information about the jboss-cvs-commits
mailing list