use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class EntitlementService method getApplications.
/**
* Returns a set of registered applications.
*
* @return a set of registered applications.
*/
public Set<Application> getApplications() {
final Set<Application> results = new HashSet<Application>();
try {
SSOToken token = getSSOToken();
final ServiceConfig appConfig = getApplicationConfiguration(token, realm);
if (appConfig != null) {
final Set<String> names = appConfig.getSubConfigNames();
for (String name : names) {
results.add(createApplication(appConfig, name));
}
}
} catch (EntitlementException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
} catch (ClassCastException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
} catch (InstantiationException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
} catch (IllegalAccessException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
}
return results;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class EntitlementService method getApplication.
/**
* {@inheritDoc}
*/
public Application getApplication(String name) {
try {
final ServiceConfig appConfig = getApplicationConfiguration(getSSOToken(), realm);
final Set<String> names = appConfig.getSubConfigNames();
if (appConfig != null && names.contains(name)) {
return createApplication(appConfig, name);
}
} catch (EntitlementException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
} catch (ClassCastException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
} catch (InstantiationException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
} catch (IllegalAccessException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
}
return null;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class EntitlementService method createApplicationCollectionConfig.
private ServiceConfig createApplicationCollectionConfig(String realm) throws SMSException, SSOException {
ServiceConfig sc = null;
SSOToken token = SubjectUtils.getSSOToken(getAdminSubject());
ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, token);
ServiceConfig orgConfig = mgr.getOrganizationConfig(realm, null);
if (orgConfig != null) {
sc = orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
}
if (sc == null) {
orgConfig.addSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS, SCHEMA_APPLICATIONS, 0, Collections.EMPTY_MAP);
sc = orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
}
return sc;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class PolicyManager method getPolicyNames.
/**
* Gets a set of selected policy names matching the
* pattern in the given organization. The pattern
* accepts "*" as the wild card for searching policy names.
* For example if the pattern is "co*", it returns policies
* starting with "co". Similarly, if the pattern is "*net", it returns
* policies ending with "net". The wildcard can be anywhere in the
* the string. If there are no policies that match the provided filter,
* this method returns an empty set (not null).
*
* @param pattern search pattern that will be used to select policy names
*
* @return <code>Set</code> of policy names that satisfy the pattern
*
* @throws SSOException invalid or expired single-sign-on token
* @throws NoPermissionException user does not have sufficient
* privileges to get policy names
* @throws PolicyException for any other abnormal condition
*
* @supported.api
*/
public Set getPolicyNames(String pattern) throws SSOException, NoPermissionException, PolicyException {
try {
ServiceConfig oConfig = scm.getOrganizationConfig(org, null);
ServiceConfig namedPolicy = (oConfig == null) ? null : oConfig.getSubConfig(NAMED_POLICY);
if (namedPolicy == null) {
return (Collections.EMPTY_SET);
} else {
if (pattern.equals("*")) {
return (namedPolicy.getSubConfigNames());
} else {
return (namedPolicy.getSubConfigNames(pattern));
}
}
} catch (SMSException se) {
debug.error("Unable to get named policies for organization: " + org);
// Check for permission exception
String[] objs = { org };
if (se.getExceptionCode() == SMSException.STATUS_NO_PERMISSION) {
throw (new NoPermissionException(ResBundleUtils.rbName, "insufficient_access_rights", null));
} else {
// Throw generic policy exception
throw (new PolicyException(ResBundleUtils.rbName, "unable_to_get_policies_for_organization", objs, se));
}
}
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class AMSetupServlet method updateEmbeddedIdRepo.
/**
* Update Embedded Idrepo instance with new embedded opends isntance.
*/
private static void updateEmbeddedIdRepo(String orgName, String configName, String entry) throws SMSException, SSOException {
SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
ServiceConfigManager scm = new ServiceConfigManager(token, IdConstants.REPO_SERVICE, "1.0");
ServiceConfig sc = scm.getOrganizationConfig(orgName, null);
if (sc != null) {
ServiceConfig subConfig = sc.getSubConfig(configName);
if (subConfig != null) {
Map<String, Object> configMap = subConfig.getAttributes();
Set<String> vals = (Set<String>) configMap.get("sun-idrepo-ldapv3-config-ldap-server");
vals.add(entry);
HashMap<String, Set<String>> mp = new HashMap<String, Set<String>>(2);
mp.put("sun-idrepo-ldapv3-config-ldap-server", vals);
subConfig.setAttributes(mp);
}
}
}
Aggregations