use of com.sun.identity.sm.OrganizationConfigManager 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.OrganizationConfigManager in project OpenAM by OpenRock.
the class PWResetModelImpl method getAttributeValues.
protected Set getAttributeValues(String realm, String attrName) throws SSOException, SMSException {
OrganizationConfigManager mgr = new OrganizationConfigManager(ssoToken, realm);
Map attributeValues = mgr.getServiceAttributes(PW_RESET_SERVICE);
return (Set) attributeValues.get(attrName);
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class SmsRealmProvider method getJsonValue.
private JsonValue getJsonValue(String realmPath, String parentPath) throws SMSException {
OrganizationConfigManager realmManager = new OrganizationConfigManager(getSSOToken(), realmPath);
String realmName = getRealmName(realmManager);
return getJsonValue(realmManager, realmName, parentPath);
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class DefaultADFSPartnerAccountMapper method isDynamicalOrIgnoredProfile.
/**
* Checks if dynamical profile creation or ignore profile is enabled.
* @param realm realm to check the dynamical profile creation attributes.
* @return true if dynamical profile creation or ignore profile is enabled,
* false otherwise.
*/
protected boolean isDynamicalOrIgnoredProfile(String realm) {
try {
OrganizationConfigManager orgConfigMgr = AuthD.getAuth().getOrgConfigManager(realm);
ServiceConfig svcConfig = orgConfigMgr.getServiceConfig(ISAuthConstants.AUTH_SERVICE_NAME);
Map attrs = svcConfig.getAttributes();
String tmp = CollectionHelper.getMapAttr(attrs, ISAuthConstants.DYNAMIC_PROFILE);
if (debug.messageEnabled()) {
debug.message("dynamicalCreationEnabled, attr=" + tmp);
}
if (tmp != null && (tmp.equalsIgnoreCase("createAlias") || tmp.equalsIgnoreCase("true") || tmp.equalsIgnoreCase("ignore"))) {
return true;
} else {
return false;
}
} catch (Exception e) {
debug.error("dynamicalCreationEnabled, unable to get attribute", e);
return false;
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ApplicationCacheAfterRealmChangeTest method test.
@Test
public void test() throws Exception {
if (!migrated) {
return;
}
Application appl = ApplicationManager.getApplication(adminSubject, SUB_REALM, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
// Test disabled, unable to fix model changes
// Set<String> resources = appl.getResources();
// if ((resources != null) && !resources.isEmpty()) {
// throw new Exception("ApplicationCacheAfterRealmChangeTest: " +
// "application resources should be empty");
// }
OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, SUB_REALM);
Map<String, Set<String>> attributes = new HashMap<String, Set<String>>();
Set<String> setAlias = new HashSet<String>();
setAlias.add("www.ApplicationCacheAfterRealmChangeTest.com");
attributes.put("sunOrganizationAliases", setAlias);
Set<String> setStatus = new HashSet<String>();
setStatus.add("Active");
attributes.put("sunOrganizationStatus", setStatus);
ocm.setAttributes(IdConstants.REPO_SERVICE, attributes);
appl = ApplicationManager.getApplication(adminSubject, SUB_REALM, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
// Test disabled, unable to fix model changes.
// resources = appl.getResources();
// if ((resources == null) || resources.isEmpty()) {
// throw new Exception("ApplicationCacheAfterRealmChangeTest: " +
// "application resources should NOT be empty");
// }
}
Aggregations