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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Apr 21 02:25:40 EDT 2007


Author: anil.saldhana at jboss.com
Date: 2007-04-21 02:25:40 -0400 (Sat, 21 Apr 2007)
New Revision: 62452

Modified:
   projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContext.java
   projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java
Log:
RunAs changes, utility methods and util class aware of securitycontext

Modified: projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContext.java
===================================================================
--- projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContext.java	2007-04-20 22:23:01 UTC (rev 62451)
+++ projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContext.java	2007-04-21 06:25:40 UTC (rev 62452)
@@ -9,8 +9,7 @@
 import java.io.Serializable;
 import java.util.Map; 
  
-import org.jboss.security.audit.SecurityAuditManager;
-import org.jboss.security.mapping.MappingContext;
+import org.jboss.security.audit.SecurityAuditManager; 
 import org.jboss.security.mapping.MappingManager;
  
 
@@ -54,14 +53,39 @@
    
    /**
     * Subject Info
+    * 
+    * @see SecurityContextUtil#getSubject()
+    * @see SecurityContextUtil#createSubjectInfo(Principal, Object, Subject)
     */
-   public SubjectInfo getSubjectInfo(); 
-   public void setSubjectInfo(SubjectInfo si);
+   SubjectInfo getSubjectInfo(); 
    
    /**
+    * Subject Info
+    * 
+    * @see SecurityContextUtil#getSubject()
+    * @see SecurityContextUtil#createSubjectInfo(Principal, Object, Subject)
+    */
+   void setSubjectInfo(SubjectInfo si); 
+   
+   /**
     * RunAs Representation
+    * 
+    * @see #setRunAs(RunAs)
     */
    public RunAs getRunAs();
+   
+   /**
+    * Set the current RunAs for the security context that will be
+    * propagated out to other security context.
+    * 
+    * RunAs coming into this security context needs to be done
+    * from SecurityContextUtil.getCallerRunAs/setCallerRunAs
+    * 
+    * @see SecurityContextUtil#getCallerRunAs()
+    * @see SecurityContextUtil#setCallerRunAs(RunAs)
+    * 
+    * @param runAs
+    */
    public void setRunAs(RunAs runAs);
    
    /**
@@ -72,5 +96,5 @@
     * roles etc in an implementation specific way
     * @return
     */
-   public SecurityContextUtil getUtil();
+   public SecurityContextUtil getUtil(); 
 }

Modified: projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java
===================================================================
--- projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java	2007-04-20 22:23:01 UTC (rev 62451)
+++ projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java	2007-04-21 06:25:40 UTC (rev 62452)
@@ -23,6 +23,8 @@
 
 import java.security.Principal;
 
+import javax.security.auth.Subject;
+
 //$Id$
 
 /**
@@ -33,21 +35,80 @@
  */
 public abstract class SecurityContextUtil
 {
+   protected SecurityContext securityContext = null;
+   
+   public void setSecurityContext(SecurityContext sc)
+   {
+      this.securityContext = sc;
+   }
+   
    /**
-    * Get the username from the subject info
-    * @param si subject info
+    * Get the username from the security context
     * @return username
     */
-   public abstract String getUserName(SubjectInfo si);
+   public abstract String getUserName();
    
    /**
-    * Get the user principal from the subject info
-    * @param si
+    * Get the user principal the security context
     * @return user principal
     */
-   public abstract Principal getUserPrincipal(SubjectInfo si); 
+   public abstract Principal getUserPrincipal(); 
    
    /**
+    * Get the credential
+    * @return
+    */
+   public abstract Object getCredential();
+   
+   /**
+    * Get the subject the security context
+    * @return
+    */
+   public abstract Subject getSubject();
+   
+   /**
+    * Get the RunAs that was passed into the current security context
+    * The security context RunAs is the RunAs that will be propagated out of it
+    * @return
+    */
+   public abstract RunAs getCallerRunAs();
+   
+   /**
+    * Set the Caller RunAs in the security context
+    * Security Context implementations are free to store
+    * the caller runas in any manner
+    * @param runAs
+    */
+   public abstract void setCallerRunAs(RunAs runAs);
+   
+   /**
+    * Get the Roles associated with the user for the
+    * current security context
+    * @param <T>
+    * @return
+    */
+   public abstract <T>  T getRoles();
+   
+   /**
+    * Set the roles for the user for the current security context
+    * @param <T>
+    * @param roles
+    */
+   public abstract <T>  void setRoles(T roles);
+   
+   /**
+    * Create SubjectInfo and set it in the current security context
+    * @param principal
+    * @param credential
+    * @param subject
+    */
+   public void createSubjectInfo(Principal principal, Object credential,Subject subject)
+   {
+      SubjectInfo si = new SubjectInfo(principal, credential, subject);
+      this.securityContext.setSubjectInfo(si);
+   }
+   
+   /**
     * Set an object on the Security Context
     * The context implementation may place the object in its internal
     * data structures (like the Data Map)
@@ -56,7 +117,7 @@
     * @param key Key representing the object being set
     * @param obj
     */
-   public abstract <T> void set(SecurityContext sc, String key, T obj);
+   public abstract <T> void set(String key, T obj);
    
    /**
     * Return an object from the Security Context
@@ -65,7 +126,7 @@
     * @param key key identifies the type of object we are requesting
     * @return
     */
-   public abstract <T> T get(SecurityContext sc, String key);
+   public abstract <T> T get(String key);
    
    /**
     * Remove an object represented by the key from the security context
@@ -74,5 +135,5 @@
     * @param key key identifies the type of object we are requesting
     * @return the removed object
     */
-   public abstract <T> T remove(SecurityContext sc, String key);
+   public abstract <T> T remove(String key);
 }




More information about the jboss-cvs-commits mailing list