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); } }
/** * 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; }