private static void initRoleMapperFactory() //throws Exception { Object o = null; Class c = null; // this should never fail. try { c = Class.forName("com.sun.enterprise.security.acl.RoleMapperFactory"); if (c != null) { o = c.newInstance(); if (o != null && o instanceof SecurityRoleMapperFactory) { SecurityRoleMapperFactoryMgr.registerFactory((SecurityRoleMapperFactory) o); } } if (o == null) { // _logger.log(Level.SEVERE,_localStrings.getLocalString("j2ee.norolemapper", "Cannot instantiate the SecurityRoleMapperFactory")); } } catch (Exception cnfe) { // _logger.log(Level.SEVERE, // _localStrings.getLocalString("j2ee.norolemapper", "Cannot instantiate the SecurityRoleMapperFactory"), // cnfe); // cnfe.printStackTrace(); // throw new RuntimeException(cnfe); // throw cnfe; } } }
/** * Sets the registration name for this application. This name is used * while deploying the application. The deployment process gurantees * that this name is unique. * * @param appId the registration name used for this application */ public void setRegistrationName(String appId) { // at his point we need to swap our RoleMapper, if we have one... SecurityRoleMapper roleMapper = null; try { roleMapper = getRoleMapper(); } catch (IllegalArgumentException ignore) { } if (roleMapper != null) { SecurityRoleMapperFactory factory = habitat.getComponent(SecurityRoleMapperFactory.class); if (factory == null) { throw new IllegalArgumentException(localStrings.getLocalString( "enterprise.deployment.norolemapperfactorydefine", "This application has no role mapper factory defined")); } factory.removeRoleMapper(getName()); roleMapper.setName(appId); factory.setRoleMapper(appId, roleMapper); } this.registrationName = appId; }
private void postConstruct() { SecurityRoleMapperFactoryGen.getSecurityRoleMapperFactory().setAppNameForContext(getAppId(), CONTEXT_ID); }
jndiName = mailResource.getName(); description = mailResource.getDescription(); enabled = mailResource.isEnabled(); storeProtocol = mailResource.getStoreProtocol(); storeProtocolClass = mailResource.getStoreProtocolClass(); transportProtocol = mailResource.getTransportProtocol(); transportProtocolClass = mailResource.getTransportProtocolClass(); mailHost = mailResource.getMailHost(); username = mailResource.getUsername(); mailFrom = mailResource.getMailFrom(); debug = mailResource.isDebug(); Set properties = mailResource.getProperties(); ResourceProperty property = null; String name = null;
private String getRoleName(Principal callerPrincipal) { String roleName = null; WebBundleDescriptor wbd = (WebBundleDescriptor) getComponentEnvManager().getCurrentJndiNameEnvironment(); SecurityRoleMapperFactory securityRoleMapperFactory = getSecurityRoleMapperFactory(); SecurityRoleMapper securityRoleMapper = securityRoleMapperFactory.getRoleMapper(wbd.getModuleID()); Map<String, Subject> map = securityRoleMapper.getRoleToSubjectMapping(); for (Map.Entry<String, Subject> entry : map.entrySet()) { roleName = entry.getKey(); Subject subject = entry.getValue(); Set principalSet = subject.getPrincipals(); if (principalSet.contains(callerPrincipal)) { return roleName; } } return ""; }
/** * Return my mapping of rolename to users and groups on a particular * server. */ public SecurityRoleMapper getRoleMapper() { if (this.roleMapper == null) { SecurityRoleMapperFactory factory = habitat.getComponent(SecurityRoleMapperFactory.class); if (factory == null) { _logger.log(Level.FINE, "SecurityRoleMapperFactory NOT set."); } else { this.roleMapper = factory.getRoleMapper(this.getName()); } } return this.roleMapper; }
String roleName = runAs.getRoleName(); final Subject fs = (Subject)application.getRoleMapper().getRoleToSubjectMapping().get(roleName); if (fs != null) { principalName = (String)AccessController.doPrivileged(new PrivilegedAction() {
public void destroy() throws PolicyContextException { boolean wasInService = getPolicyFactory().inService(CONTEXT_ID); //getPolicyFactory().getPolicyConfiguration(CONTEXT_ID,true); if (wasInService) { policy.refresh(); } PermissionCacheFactory.removePermissionCache(uncheckedPermissionCache); uncheckedPermissionCache = null; SecurityRoleMapperFactoryGen.getSecurityRoleMapperFactory().removeAppNameForContext(CONTEXT_ID); wsmf.getManager(CONTEXT_ID,null,true); }
public static void removeRoleMapper(DeploymentContext dc) { OpsParams params = dc.getCommandParameters(OpsParams.class); if (params.origin != OpsParams.Origin.undeploy) { return; } String appName = params.name(); SecurityRoleMapperFactory factory = SecurityRoleMapperFactoryGen.getSecurityRoleMapperFactory(); if (factory == null) { throw new IllegalArgumentException("This application has no role mapper factory defined"); } factory.removeRoleMapper(appName); } }
/** * Adds a new DOL descriptor instance to the descriptor instance associated with * this XMLNode * * @param mewDescriptor the new descriptor */ public void addDescriptor(Object newDescriptor) { if (newDescriptor instanceof SecurityRoleMapping) { SecurityRoleMapping roleMap = (SecurityRoleMapping) newDescriptor; descriptor.addSecurityRoleMapping(roleMap); if (descriptor!=null && !descriptor.isVirtual()) { Role role = new Role(roleMap.getRoleName()); SecurityRoleMapper rm = descriptor.getRoleMapper(); if (rm != null) { List<PrincipalNameDescriptor> principals = roleMap.getPrincipalNames(); for (int i = 0; i < principals.size(); i++) { rm.assignRole(principals.get(i).getPrincipal(), role, descriptor); } List<String> groups = roleMap.getGroupNames(); for (int i = 0; i < groups.size(); i++) { rm.assignRole(new Group(groups.get(i)), role, descriptor); } } } } }
/** * Reset the display name of this application. * * @param name the display name of the application. */ public void setName(String name) { name = name.replace('/', '-'); name = name.replace('\\', '-'); // for deploying from NT to solaris & vice versa. This will // need to be cleaned when we clean up the backend for registering apps super.setName(name); if (this.getRoleMapper() != null) { this.getRoleMapper().setName(name); } }
private String generateKey(IASEjbCMPFinder finder, QueryParser parser) { StringBuffer key = new StringBuffer(); key.append(finder.getMethodName()).append(LIST_START); String queryParams = finder.getQueryParameterDeclaration(); Iterator iter = parser.parameterTypeIterator(queryParams); while ( iter.hasNext() ) { String type = ( String ) iter.next() ; key.append(getFullyQualifiedType(type)) ; if( iter.hasNext() ) { key.append(LIST_SEPARATOR); } } key.append(LIST_END); return key.toString().intern(); }
jndiName = mailResource.getName(); description = mailResource.getDescription(); enabled = mailResource.isEnabled(); storeProtocol = mailResource.getStoreProtocol(); storeProtocolClass = mailResource.getStoreProtocolClass(); transportProtocol = mailResource.getTransportProtocol(); transportProtocolClass = mailResource.getTransportProtocolClass(); mailHost = mailResource.getMailHost(); username = mailResource.getUsername(); mailFrom = mailResource.getMailFrom(); debug = mailResource.isDebug(); if (_logger.isLoggable(Level.FINE)) { _logger.fine("storeProtocol " + storeProtocol); Set properties = mailResource.getProperties();
SecurityRoleMapper srm = factory.getRoleMapper(CONTEXT_ID); if (srm != null) { roleToSubjectMap = srm.getRoleToSubjectMapping(); String contextId = (String)it.next(); if (!CONTEXT_ID.equals(contextId)) { SecurityRoleMapper otherSrm = factory.getRoleMapper(contextId); Map otherRoleToSubjectMap = null; otherRoleToSubjectMap = otherSrm.getRoleToSubjectMapping();
private SecurityRoleMapper getRoleMapper(){ Habitat habitat = Globals.getDefaultHabitat(); SecurityRoleMapper srm = null; if(habitat != null){ SecurityRoleMapperFactory srmf = habitat.getComponent(SecurityRoleMapperFactory.class); if(srmf != null){ srm = srmf.getRoleMapper(descriptor.getModuleDescriptor().getModuleName()); } } return srm; } public void addDescriptor(Object newDescriptor) {
roleMapperFactory.setAppNameForContext(appName, contextId); codesource = getApplicationCodeSource(contextId); ejbName = deploymentDescriptor.getName();
private static void initRoleMapperFactory() //throws Exception { Object o = null; Class c = null; // this should never fail. try { c = Class.forName("com.sun.enterprise.security.acl.RoleMapperFactory"); if (c != null) { o = c.newInstance(); if (o != null && o instanceof SecurityRoleMapperFactory) { SecurityRoleMapperFactoryMgr.registerFactory((SecurityRoleMapperFactory) o); } } if (o == null) { // _logger.log(Level.SEVERE,_localStrings.getLocalString("j2ee.norolemapper", "Cannot instantiate the SecurityRoleMapperFactory")); } } catch (Exception cnfe) { // _logger.log(Level.SEVERE, // _localStrings.getLocalString("j2ee.norolemapper", "Cannot instantiate the SecurityRoleMapperFactory"), // cnfe); // cnfe.printStackTrace(); // throw new RuntimeException(cnfe); // throw cnfe; } } }
public void destroy() { try { boolean wasInService = getPolicyFactory().inService(this.contextId); if (wasInService) { policy.refresh(); } /* * all ejbs of module share same policy context, but each has its own * permission cache, which must be unregistered from factory to * avoid leak. */ PermissionCacheFactory.removePermissionCache(uncheckedMethodPermissionCache); uncheckedMethodPermissionCache = null; roleMapperFactory.removeAppNameForContext(this.contextId); } catch (PolicyContextException pce) { String msg = "ejbsm.could_not_delete"; // Just log it. _logger.log(Level.WARNING, msg, pce); } probeProvider.securityManagerDestructionStartedEvent(ejbName); ejbSFM.getManager(contextId,ejbName,true); probeProvider.securityManagerDestructionEndedEvent(ejbName); probeProvider.securityManagerDestructionEvent(ejbName); }
/** * Adds a new DOL descriptor instance to the descriptor instance associated with * this XMLNode * * @param descriptor the new descriptor */ public void addDescriptor(Object newDescriptor) { if (newDescriptor instanceof SecurityRoleMapping) { SecurityRoleMapping roleMap = (SecurityRoleMapping)newDescriptor; descriptor.addSecurityRoleMapping(roleMap); Application app = descriptor.getApplication(); if (app!=null) { Role role = new Role(roleMap.getRoleName()); SecurityRoleMapper rm = app.getRoleMapper(); if (rm != null) { List<PrincipalNameDescriptor> principals = roleMap.getPrincipalNames(); for (int i = 0; i < principals.size(); i++) { rm.assignRole(principals.get(i).getPrincipal(), role, descriptor); } List<String> groups = roleMap.getGroupNames(); for (int i = 0; i < groups.size(); i++) { rm.assignRole(new Group(groups.get(i)), role, descriptor); } } } } }
if (rm != null) { if(roleMap.isExternallyDefined()){ rm.assignRole(new Group(roleMap.getRoleName()), role, descriptor); } else { List<String> principals = roleMap.getPrincipalNames(); for (int i = 0; i < principals.size(); i++) { rm.assignRole(new PrincipalImpl(principals.get(i)), role, descriptor);