use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class OpenSSOIndexStore method getOrgAliasMappingResources.
static Set<String> getOrgAliasMappingResources(String realm, String applicationTypeName) throws SMSException {
Set<String> results = new HashSet<String>();
if (applicationTypeName.equalsIgnoreCase(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME)) {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
if (isOrgAliasMappingResourceEnabled(adminToken)) {
OrganizationConfigManager m = new OrganizationConfigManager(adminToken, realm);
Map<String, Set<String>> map = m.getAttributes(PolicyManager.ID_REPO_SERVICE);
Set<String> orgAlias = map.get(PolicyManager.ORG_ALIAS);
if ((orgAlias != null) && !orgAlias.isEmpty()) {
for (String s : orgAlias) {
results.add(PolicyManager.ORG_ALIAS_URL_HTTPS_PREFIX + s.trim() + PolicyManager.ORG_ALIAS_URL_SUFFIX);
results.add(PolicyManager.ORG_ALIAS_URL_HTTP_PREFIX + s.trim() + PolicyManager.ORG_ALIAS_URL_SUFFIX);
}
}
}
}
return results;
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class EntitlementService method getParentAndPeerRealmNames.
public Set<String> getParentAndPeerRealmNames() throws EntitlementException {
Set<String> results = new HashSet<String>();
try {
OrganizationConfigManager mgr = new OrganizationConfigManager(EntitlementUtils.getAdminToken(), realm);
mgr = mgr.getParentOrgConfigManager();
String parentRealm = DNMapper.orgNameToRealmName(mgr.getOrganizationName());
results.add(parentRealm);
Set<String> orgNames = mgr.getSubOrganizationNames();
for (String o : orgNames) {
results.add(DNMapper.orgNameToRealmName(o));
}
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getSubRealmNames", ex);
// realm no longer exist
}
return results;
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class PolicyModelImpl method hasPolicyConfigSvcRegistered.
private boolean hasPolicyConfigSvcRegistered(String realmName) {
try {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(adminSSOToken, realmName);
Set names = orgCfgMgr.getAssignedServices();
return (names != null) && names.contains(AMAdminConstants.POLICY_SERVICE);
} catch (SMSException e) {
debug.warning("PolicyModelImpl.hasPolicyConfigSvcRegistered", e);
return false;
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class CoreAttributesModelImpl method getAttributeValues.
/**
* Returns attributes values.
*
* @return attributes values.
*/
public Map getAttributeValues() {
Map attrs = null;
String[] param = { currentRealm };
logEvent("ATTEMPT_GET_AUTH_PROFILE_IN_REALM", param);
try {
OrganizationConfigManager scm = new OrganizationConfigManager(getUserSSOToken(), currentRealm);
ServiceConfig config = scm.getServiceConfig(AUTH_SERVICE_NAME);
attrs = config.getAttributes();
if ((attrs == null) || attrs.isEmpty()) {
debug.warning("no attributes were returned for Core Auth ...");
}
logEvent("SUCCEED_GET_AUTH_PROFILE_IN_REALM", param);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, strError };
logEvent("SMS_CONFIGURATION_EXCEPTION_GET_AUTH_PROFILE_IN_REALM", paramsEx);
debug.error("CoreAttributesModelImpl.getAttributeValues", e);
}
return (attrs == null) ? Collections.EMPTY_MAP : attrs;
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class IdServicesImpl method getServiceAttributesAscending.
/**
* Non-javadoc, non-public methods
* Get the service attributes of the name identity. Traverse to the global
* configuration if necessary until all attributes are found or reached
* the global area whichever occurs first.
*
* @param token is the sso token of the person performing this operation.
* @param type is the identity type of the name parameter.
* @param name is the identity we are interested in.
* @param serviceName is the service we are interested in
* @param attrNames are the name of the attributes wer are interested in.
* @param amOrgName is the orgname.
* @param amsdkDN is the amsdkDN.
* @throws IdRepoException if there are repository related error conditions.
* @throws SSOException if user's single sign on token is invalid.
*/
public Map getServiceAttributesAscending(SSOToken token, IdType type, String name, String serviceName, Set attrNames, String amOrgName, String amsdkDN) throws IdRepoException, SSOException {
Map finalResult = new HashMap();
Set finalAttrName = new HashSet();
String nextName = name;
String nextAmOrgName = amOrgName;
String nextAmsdkDN = amsdkDN;
IdType nextType = type;
Set missingAttr = new HashSet(attrNames);
do {
// amsdkDN will change as we move up the tree.
try {
Map serviceResult = getServiceAttributes(token, nextType, nextName, serviceName, missingAttr, nextAmOrgName, nextAmsdkDN);
if (DEBUG.messageEnabled()) {
DEBUG.message("IdServicesImpl." + "getServiceAttributesAscending:" + " nextType=" + nextType + "; nextName=" + nextName + "; serviceName=" + serviceName + "; missingAttr=" + missingAttr + "; nextAmOrgName=" + nextAmOrgName + "; nextAmsdkDN=" + nextAmsdkDN);
DEBUG.message(" getServiceAttributesAscending: " + "serviceResult=" + serviceResult);
DEBUG.message(" getServiceAttributesAscending: " + " finalResult=" + finalResult);
DEBUG.message(" getServiceAttributesAscending: " + " finalAttrName=" + finalAttrName);
}
if (serviceResult != null) {
Set srvNameReturned = serviceResult.keySet();
// save the newly found attrs
// amsdk returns emptyset when attrname is not present.
Iterator nameIt = srvNameReturned.iterator();
while (nameIt.hasNext()) {
String attr = (String) nameIt.next();
Set attrValue = (Set) serviceResult.get(attr);
if (!attrValue.isEmpty()) {
finalResult.put(attr, attrValue);
finalAttrName.add(attr);
}
}
if (DEBUG.messageEnabled()) {
DEBUG.message(" getServiceAttributesAscending:" + " serviceResult=" + serviceResult);
DEBUG.message(" getServiceAttributesAscending:" + " finalResult=" + finalResult);
}
}
if (finalAttrName.containsAll(attrNames)) {
if (DEBUG.messageEnabled()) {
DEBUG.message("exit getServiceAttributesAscending:" + " finalResult=" + finalResult);
}
return (finalResult);
}
// find the missing attributes
missingAttr.clear();
Iterator it = attrNames.iterator();
while (it.hasNext()) {
String attrName = (String) it.next();
if (!finalAttrName.contains(attrName)) {
missingAttr.add(attrName);
}
}
} catch (IdRepoException idrepo) {
if (DEBUG.warningEnabled()) {
DEBUG.warning(" getServiceAttributesAscending: " + "idrepoerr", idrepo);
}
} catch (SSOException ssoex) {
if (DEBUG.warningEnabled()) {
DEBUG.warning(" getServiceAttributesAscending: " + "ssoex", ssoex);
}
}
// go up to the parent org
try {
if (nextType.equals(IdType.USER) || nextType.equals(IdType.AGENT)) {
// try the user or agent's correct realm.
nextAmsdkDN = nextAmOrgName;
nextType = IdType.REALM;
} else {
OrganizationConfigManager ocm = new OrganizationConfigManager(token, nextAmOrgName);
OrganizationConfigManager parentOCM = ocm.getParentOrgConfigManager();
String parentName = parentOCM.getOrganizationName();
if (DEBUG.messageEnabled()) {
DEBUG.message(" getServiceAttributesAscending: " + "parentName=" + parentName);
}
nextType = IdType.REALM;
if (nextAmOrgName.equalsIgnoreCase(parentName)) {
// at root.
nextName = null;
} else {
nextAmOrgName = parentName;
}
nextAmOrgName = parentName;
nextAmsdkDN = parentName;
}
} catch (SMSException smse) {
if (DEBUG.warningEnabled()) {
DEBUG.warning(" getServiceAttributesAscending: " + "smserror", smse);
}
nextName = null;
}
} while (nextName != null);
// get the rest from global.
if (!missingAttr.isEmpty()) {
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
ServiceSchema schema = ssm.getDynamicSchema();
Map gAttrs = schema.getAttributeDefaults();
Iterator missingIt = missingAttr.iterator();
while (missingIt.hasNext()) {
String missingAttrName = (String) missingIt.next();
finalResult.put(missingAttrName, gAttrs.get(missingAttrName));
}
} catch (SMSException smse) {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdServicesImpl(): getServiceAttributeAscending " + " Failed to get global default.", smse);
}
}
}
if (DEBUG.messageEnabled()) {
DEBUG.message("exit end getServiceAttributesAscending: " + " finalResult=" + finalResult);
}
return finalResult;
}
Aggregations