geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r704181 - /geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ContextManager.java
Date Mon, 13 Oct 2008 17:45:15 GMT
Author: djencks
Date: Mon Oct 13 10:45:14 2008
New Revision: 704181

URL: http://svn.apache.org/viewvc?rev=704181&view=rev
Log:
GERONIMO-3417 new method to help with jaspi implementation

Modified:
    geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ContextManager.java

Modified: geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ContextManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ContextManager.java?rev=704181&r1=704180&r2=704181&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ContextManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ContextManager.java
Mon Oct 13 10:45:14 2008
@@ -246,6 +246,39 @@
 
         return context.id;
     }
+    public static synchronized AccessControlContext registerSubjectShort(Subject subject)
{
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) sm.checkPermission(SET_CONTEXT);
+
+        if (subject == null) throw new IllegalArgumentException("Subject must not be null");
+        
+        Context test = subjectContexts.get(subject);
+        if (test != null) {
+            return test.context;
+        }
+
+        AccessControlContext acc = (AccessControlContext) Subject.doAsPrivileged(subject,
new PrivilegedAction() {
+            public Object run() {
+                return AccessController.getContext();
+            }
+        }, null);
+
+        Context context = new Context();
+        context.subject = subject;
+        context.context = acc;
+        Long id = nextSubjectId++;
+        try {
+            context.id = new SubjectId(id, hash(id));
+        } catch (NoSuchAlgorithmException e) {
+            throw new ProviderException("No such algorithm: " + algorithm + ".  This can
be caused by a misconfigured java.ext.dirs, JAVA_HOME or JRE_HOME environment variable");
+        } catch (InvalidKeyException e) {
+            throw new ProviderException("Invalid key: " + key.toString());
+        }
+        subjectIds.put(context.id, subject);
+        subjectContexts.put(subject, context);
+
+        return acc;
+    }
 
     public static synchronized void unregisterSubject(Subject subject) {
         SecurityManager sm = System.getSecurityManager();



Mime
View raw message