[jboss-cvs] JBossAS SVN: r72640 - projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 23 17:40:17 EDT 2008


Author: anil.saldhana at jboss.com
Date: 2008-04-23 17:40:17 -0400 (Wed, 23 Apr 2008)
New Revision: 72640

Added:
   projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentity.java
   projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentityFactory.java
Modified:
   projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentity.java
   projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentityFactory.java
Log:
SECURITY-202: certificate identity as an extension of credential identity

Added: projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentity.java
===================================================================
--- projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentity.java	                        (rev 0)
+++ projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentity.java	2008-04-23 21:40:17 UTC (rev 72640)
@@ -0,0 +1,34 @@
+/*
+  * 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.extensions;
+
+import java.security.cert.X509Certificate;
+ 
+/**
+ *  Represents an Identity using X509 certificates
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Apr 23, 2008 
+ *  @version $Revision$
+ */
+public interface CertificateIdentity extends CredentialIdentity<X509Certificate[]>
+{  
+}
\ No newline at end of file

Added: projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentityFactory.java
===================================================================
--- projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentityFactory.java	                        (rev 0)
+++ projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CertificateIdentityFactory.java	2008-04-23 21:40:17 UTC (rev 72640)
@@ -0,0 +1,89 @@
+/*
+  * 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.extensions;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.security.cert.X509Certificate;
+
+import org.jboss.security.identity.IdentityFactory;
+import org.jboss.security.identity.Role;
+ 
+/**
+ *  Factory to create Certificate Identities
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Apr 23, 2008 
+ *  @version $Revision$
+ */
+public class CertificateIdentityFactory extends IdentityFactory
+{
+   private static CertificateIdentityFactory _instance = null;
+   
+   protected CertificateIdentityFactory()
+   {   
+   }
+   
+   public static CertificateIdentityFactory getInstance()
+   {
+      if(_instance == null)
+         _instance = new CertificateIdentityFactory();
+      return _instance;
+   }
+   
+   public CertificateIdentity createIdentity(final Principal principal,
+         final X509Certificate[] certs, final Role roles)
+   {
+      return new CertificateIdentity()
+      { 
+         private static final long serialVersionUID = 1L;
+
+         public X509Certificate[] getCredential()
+         { 
+            return certs;
+         }
+
+         public void setCredential(X509Certificate[] certs)
+         {
+         }
+
+         public Group asGroup()
+         { 
+            return null;
+         }
+
+         public Principal asPrincipal()
+         {
+            return principal;
+         }
+
+         public String getName()
+         {
+            return principal.getName();
+         }
+
+         public Role getRole()
+         {
+            return roles;
+         } 
+      };  
+   } 
+}
\ No newline at end of file

Modified: projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentity.java
===================================================================
--- projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentity.java	2008-04-23 21:38:39 UTC (rev 72639)
+++ projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentity.java	2008-04-23 21:40:17 UTC (rev 72640)
@@ -29,17 +29,17 @@
  *  @since  Feb 25, 2008 
  *  @version $Revision$
  */
-public interface CredentialIdentity extends Identity
+public interface CredentialIdentity<T> extends Identity
 {
    /**
     * Return a credential
     * @return
     */
-   Object getCredential();
+   T getCredential();
    
    /**
     * Set a credential
     * @param credential
     */
-   void setCredential(Object credential); 
+   void setCredential(T credential); 
 }

Modified: projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentityFactory.java
===================================================================
--- projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentityFactory.java	2008-04-23 21:38:39 UTC (rev 72639)
+++ projects/security/security-spi/trunk/identity/src/main/org/jboss/security/identity/extensions/CredentialIdentityFactory.java	2008-04-23 21:40:17 UTC (rev 72640)
@@ -24,6 +24,7 @@
 import java.security.Principal;
 import java.security.acl.Group;
 
+import org.jboss.security.identity.IdentityFactory;
 import org.jboss.security.identity.Role;
  
 /**
@@ -32,19 +33,34 @@
  *  @since  Feb 25, 2008 
  *  @version $Revision$
  */
-public class CredentialIdentityFactory
+public class CredentialIdentityFactory extends IdentityFactory
 {
-   public static CredentialIdentity createIdentity(final Principal principal, 
+   private static CredentialIdentityFactory _instance = null;
+   
+   protected CredentialIdentityFactory()
+   { 
+   }
+   
+   public static CredentialIdentityFactory getInstance()
+   {
+      if(_instance == null)
+         _instance = new CredentialIdentityFactory();
+      return _instance;
+   }
+   
+   public static CredentialIdentity<Object> createIdentity(final Principal principal, 
          final Object cred)
    {
       return createIdentity(principal,cred, null);
    }
    
-   public static CredentialIdentity createIdentity(final Principal principal, 
+   public static CredentialIdentity<Object> createIdentity(final Principal principal, 
          final Object cred, final Role roles)
    {
-      return new CredentialIdentity()
+      return new CredentialIdentity<Object>()
       {
+         private static final long serialVersionUID = 1L;
+
          public Object getCredential()
          {
             return cred;




More information about the jboss-cvs-commits mailing list