geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r154684 - geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/RoleMappingConfigurationFactory.java
Date Mon, 21 Feb 2005 16:08:18 GMT
Author: jgenender
Date: Mon Feb 21 08:08:16 2005
New Revision: 154684

URL: http://svn.apache.org/viewcvs?view=rev&rev=154684
Log:
New RoleMappingConfigurationFactory

Added:
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/RoleMappingConfigurationFactory.java

Added: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/RoleMappingConfigurationFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/RoleMappingConfigurationFactory.java?view=auto&rev=154684
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/RoleMappingConfigurationFactory.java
(added)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/RoleMappingConfigurationFactory.java
Mon Feb 21 08:08:16 2005
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.security.jacc;
+
+import org.apache.geronimo.security.GeronimoSecurityPermission;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+import java.security.SecurityPermission;
+import java.util.HashMap;
+import java.util.Map;
+
+public class RoleMappingConfigurationFactory {
+
+    private final static RoleMappingConfigurationFactory factory = new RoleMappingConfigurationFactory();
+
+    private Map configurations = new HashMap();
+
+    private RoleMappingConfigurationFactory() {
+    }
+
+    public static RoleMappingConfigurationFactory getRoleMappingFactory() {
+
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) sm.checkPermission(new SecurityPermission("setPolicy"));
+
+        if (factory != null) return factory;
+
+        return factory;
+    }
+
+    public void setRoleMappingConfiguration(String contextID, RoleMappingConfiguration configuration)
{
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) sm.checkPermission(new GeronimoSecurityPermission("setPolicyConfiguration"));
+
+        configurations.put(contextID, configuration);
+    }
+
+    public RoleMappingConfiguration getRoleMappingConfiguration(String contextID, boolean
remove) throws PolicyContextException {
+
+        RoleMappingConfiguration configuration = (RoleMappingConfiguration) configurations.get(contextID);
+
+        if (configuration == null) {
+
+            GeronimoPolicyConfigurationFactory gpcf = GeronimoPolicyConfigurationFactory.getSingleton();
+            PolicyConfiguration policyConfiguration = gpcf.getGeronimoPolicyConfiguration(contextID);
+
+            configuration = new RoleMappingConfiguration(policyConfiguration);
+            configurations.put(contextID, configuration);
+        } else {
+            configuration.open(remove);
+        }
+
+        return configuration;
+    }
+}



Mime
View raw message