use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class DelegationPolicyImpl method initialize.
/**
* Initialize (or configure) the <code>DelegationInterface</code>
* object. Usually it will be initialized with the environmrnt
* parameters set by the system administrator via Service management service.
*
* @param token <code>SSOToken</code> of an administrator
* @param configParams configuration parameters as a <code>Map</code>.
* The values in the <code>Map</code> is <code>java.util.Set</code>,
* which contains one or more configuration parameters.
*
* @throws DelegationException if an error occurred during
* initialization of <code>DelegationInterface</code> instance
*/
public void initialize(SSOToken token, Map configParams) throws DelegationException {
this.appToken = token;
try {
maxCacheSize = SystemProperties.getAsInt(CONFIGURED_CACHE_SIZE, DEFAULT_CACHE_SIZE);
// specifying cache size as 0 would virtually disable the delegation cache.
if (maxCacheSize < 0) {
maxCacheSize = DEFAULT_CACHE_SIZE;
}
delegationCache = new Cache(maxCacheSize);
if (DelegationManager.debug.messageEnabled()) {
DelegationManager.debug.message("DelegationPolicyImpl.initialize(): cache size=" + maxCacheSize);
}
pe = new PolicyEvaluator(POLICY_REPOSITORY_REALM, DelegationManager.DELEGATION_SERVICE);
// listen on delegation policy changes. once there is
// delegation policy change, we need to update the cache.
pe.addPolicyListener(this);
// listen on root realm subject changes.
AMIdentityRepository idRepo = new AMIdentityRepository(appToken, "/");
idRepo.addEventListener(this);
if (DelegationManager.debug.messageEnabled()) {
DelegationManager.debug.message("DelegationPolicyImpl: IdRepo event listener added " + "for root realm.");
}
// listen on sub realm subject changes.
OrganizationConfigManager ocm = new OrganizationConfigManager(appToken, "/");
Set orgNames = ocm.getSubOrganizationNames("*", true);
if ((orgNames != null) && (!orgNames.isEmpty())) {
Iterator it = orgNames.iterator();
while (it.hasNext()) {
String org = (String) it.next();
AMIdentityRepository idr = new AMIdentityRepository(appToken, org);
idr.addEventListener(this);
idRepoListeners.put(org, idRepo);
if (DelegationManager.debug.messageEnabled()) {
DelegationManager.debug.message("DelegationPolicyImpl: IdRepo event listener " + "added for realm (" + org + ").");
}
}
}
scm = new ServiceConfigManager(PolicyConfig.POLICY_CONFIG_SERVICE, token);
//DelegationManager.DELEGATION_SERVICE, token);
/**
* listen on org config changes. once there is realm added,
* or removed, we need to add or remove listeners on the
* affected realm accordingly.
*/
scm.addListener(this);
} catch (Exception e) {
DelegationManager.debug.error("DelegationPolicyImpl: initialize() failed");
throw new DelegationException(e);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class Gateway method addGWServletUtilsToMap.
private GatewayServletUtils addGWServletUtilsToMap(String orgName, String module) {
GatewayServletUtils utils = null;
String authService = AMAuthConfigUtils.getModuleServiceName(module);
try {
ServiceConfigManager scm = new ServiceConfigManager(authService, defToken);
utils = new GatewayServletUtils(scm, module);
utils.organizationConfigChanged(orgName);
AuthServiceConfigInfo info = utils.getAuthConfigInfo(orgName);
if ((info != null) && (info.getPortNumber() != null)) {
scm.addListener(utils);
gwServletUtilsMap.put(authService, utils);
} else {
gwServletUtilsMap.put(authService, utils = null);
}
} catch (Exception e) {
debug.error("GatewayServlet: " + "Unable to add Auth Service Info : " + authService, e);
}
return utils;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class OpenSSOPolicyDataStore method getOrgConfig.
private ServiceConfig getOrgConfig(SSOToken adminToken, String realm) throws SMSException, SSOException {
ServiceConfigManager mgr = new ServiceConfigManager(PolicyManager.POLICY_SERVICE_NAME, adminToken);
ServiceConfig orgConf = mgr.getOrganizationConfig(realm, null);
if (orgConf == null) {
mgr.createOrganizationConfig(realm, null);
orgConf = mgr.getOrganizationConfig(realm, null);
}
return orgConf;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class DelegationUtils method getPermissionConfig.
/**
* Returns service config information for a delegation permission.
* @param orgName name of the organization whose organization config
* is searched.
* @param name name of the delegation permission whose information is.
sought.
* @param global <code>boolean</code> indicating if global config
* of the delegation service is expected.
* @return <code>ServiceConfig</code> information for a delegation
* permission
*/
static ServiceConfig getPermissionConfig(String orgName, String name, boolean global) throws SSOException, DelegationException {
ServiceConfig orgConfig = null;
ServiceConfig permsConfig = null;
ServiceConfig perm = null;
try {
// get the service configuration manager of the
// delegation service
ServiceConfigManager scm = new ServiceConfigManager(DelegationManager.DELEGATION_SERVICE, DelegationManager.getAdminToken());
// get the organization configuration of this realm
if (global) {
orgConfig = scm.getGlobalConfig(null);
} else {
orgConfig = scm.getOrganizationConfig(orgName, null);
}
} catch (SMSException se) {
throw new DelegationException(ResBundleUtils.rbName, "get_org_config_failed", null, se);
}
if (orgConfig == null) {
throw new DelegationException(ResBundleUtils.rbName, "get_perms_config_failed", null, null);
}
try {
// get the sub configuration "Permissions"
permsConfig = orgConfig.getSubConfig(DelegationManager.PERMISSIONS);
} catch (SMSException se) {
throw new DelegationException(ResBundleUtils.rbName, "get_perms_config_failed", null, se);
}
try {
// get the sub configuration for the defined permission
perm = permsConfig.getSubConfig(name);
} catch (SMSException se) {
throw new DelegationException(ResBundleUtils.rbName, "get_permission_config_failed", null, se);
}
return (perm);
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class IdUtils method initialize.
protected static void initialize() {
if (ServiceManager.isConfigMigratedTo70()) {
// entities from there
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
serviceConfigManager = new ServiceConfigManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
ServiceConfig ss = serviceConfigManager.getGlobalConfig(null);
Set typeSchemaNames = ss.getSubConfigNames("*", IdConstants.SUPPORTED_TYPES);
if (typeSchemaNames == null || typeSchemaNames.isEmpty()) {
loadDefaultTypes();
} else {
Iterator it = typeSchemaNames.iterator();
while (it.hasNext()) {
String typeSchema = (String) it.next();
IdType idType = new IdType(typeSchema);
supportedTypes.add(idType);
mapSupportedTypes.put(idType.getName(), idType);
ServiceConfig tsc = ss.getSubConfig(typeSchema);
Map attributes = tsc.getAttributes();
Set serviceNameSet = (Set) attributes.get(IdConstants.SERVICE_NAME);
Set canBeMembersOf = (Set) attributes.get(IdConstants.ATTR_MEMBER_OF);
Set canHaveMembers = (Set) attributes.get(IdConstants.ATTR_HAVE_MEMBERS);
Set canAddMembers = (Set) attributes.get(IdConstants.ATTR_ADD_MEMBERS);
if (serviceNameSet != null && !serviceNameSet.isEmpty()) {
mapTypesToServiceNames.put(typeSchema, (String) serviceNameSet.iterator().next());
}
if (canBeMembersOf != null && !canBeMembersOf.isEmpty()) {
Set memberOfSet = getMemberSet(canBeMembersOf);
typesCanBeMemberOf.put(typeSchema, memberOfSet);
}
if (canHaveMembers != null && !canHaveMembers.isEmpty()) {
Set memberSet = getMemberSet(canHaveMembers);
typesCanHaveMembers.put(typeSchema, memberSet);
}
if (canAddMembers != null && !canAddMembers.isEmpty()) {
Set memberSet = getMemberSet(canAddMembers);
typesCanAddMembers.put(typeSchema, memberSet);
}
}
}
} catch (SMSException e) {
String installTime = SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
if (!installTime.equals("true")) {
debug.error("IdUtils.initialize: Loading default types.", e);
}
loadDefaultTypes();
} catch (SSOException ssoe) {
debug.error("dUtils.initialize: Loading default types", ssoe);
loadDefaultTypes();
}
} else {
loadDefaultTypes();
}
// Register for SMS notifications to root realm
if (notificationId == null) {
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
if (serviceConfigManager == null) {
serviceConfigManager = new ServiceConfigManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
}
notificationId = serviceConfigManager.addListener(new IdUtilsListener());
} catch (SMSException e) {
String installTime = SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
if (!installTime.equals("true")) {
debug.error("IdUtils.initialize: Register notification", e);
}
} catch (SSOException ssoe) {
String installTime = SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
if (!installTime.equals("true")) {
debug.error("IdUtils.initialize: Register notification", ssoe);
}
}
}
}
Aggregations