KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > security > jacc > ApplicationPrincipalRoleConfigurationManager


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.security.jacc;
18
19 import java.security.Permission JavaDoc;
20 import java.security.PermissionCollection JavaDoc;
21 import java.security.Policy JavaDoc;
22 import java.util.Enumeration JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.Map JavaDoc;
26 import java.util.Set JavaDoc;
27 import javax.security.auth.Subject JavaDoc;
28 import javax.security.jacc.PolicyConfiguration JavaDoc;
29 import javax.security.jacc.PolicyConfigurationFactory JavaDoc;
30 import javax.security.jacc.PolicyContextException JavaDoc;
31
32 import org.apache.geronimo.gbean.GBeanInfo;
33 import org.apache.geronimo.gbean.GBeanInfoBuilder;
34 import org.apache.geronimo.gbean.GBeanLifecycle;
35 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
36 import org.apache.geronimo.security.ContextManager;
37 import org.apache.geronimo.security.IdentificationPrincipal;
38 import org.apache.geronimo.security.SubjectId;
39
40 /**
41  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
42  */

43 public class ApplicationPrincipalRoleConfigurationManager implements PrincipalRoleMapper {
44
45     private final Map JavaDoc principalRoleMap;
46
47     public ApplicationPrincipalRoleConfigurationManager(Map JavaDoc principalRoleMap) throws PolicyContextException JavaDoc, ClassNotFoundException JavaDoc {
48         this.principalRoleMap = principalRoleMap;
49     }
50
51
52     public void install(Set JavaDoc contextIds) throws PolicyContextException JavaDoc {
53         GeronimoPolicyConfigurationFactory roleMapperFactory = GeronimoPolicyConfigurationFactory.getSingleton();
54         if (roleMapperFactory == null) {
55             throw new IllegalStateException JavaDoc("Inconsistent security setup. GeronimoPolicyConfigurationFactory is not being used");
56         }
57
58         for (Iterator JavaDoc iterator = contextIds.iterator(); iterator.hasNext();) {
59             String JavaDoc contextID = (String JavaDoc) iterator.next();
60
61             GeronimoPolicyConfiguration geronimoPolicyConfiguration = roleMapperFactory.getGeronimoPolicyConfiguration(contextID);
62             geronimoPolicyConfiguration.setPrincipalRoleMapping(principalRoleMap);
63         }
64
65     }
66
67
68     public void uninstall() throws PolicyContextException JavaDoc {
69     }
70
71
72     public static final GBeanInfo GBEAN_INFO;
73
74     static {
75         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(ApplicationPrincipalRoleConfigurationManager.class, NameFactory.JACC_MANAGER);
76         infoBuilder.addAttribute("principalRoleMap", Map JavaDoc.class, true);
77         infoBuilder.addInterface(PrincipalRoleMapper.class);
78         infoBuilder.setConstructor(new String JavaDoc[] {"principalRoleMap"});
79         GBEAN_INFO = infoBuilder.getBeanInfo();
80     }
81
82     public GBeanInfo getGBeanInfo() {
83         return GBEAN_INFO;
84     }
85 }
86
Popular Tags