use of com.sun.identity.entitlement.EntitlementException in project OpenAM by OpenRock.
the class EntitlementService method storeApplicationType.
/**
* Stores the application type to data store.
*
* @param applicationType Application type object.
* @throws EntitlementException if application type cannot be stored.
*/
public void storeApplicationType(ApplicationType applicationType) throws EntitlementException {
try {
SSOToken token = SubjectUtils.getSSOToken(getAdminSubject());
if (token == null) {
Object[] arg = { applicationType.getName() };
throw new EntitlementException(246, arg);
}
ServiceConfig conf = getApplicationTypeCollectionConfig(token);
if (conf != null) {
ServiceConfig sc = conf.getSubConfig(applicationType.getName());
if (sc == null) {
conf.addSubConfig(applicationType.getName(), EntitlementUtils.APPLICATION_TYPE, 0, getApplicationTypeData(applicationType));
} else {
sc.setAttributes(getApplicationTypeData(applicationType));
}
}
} catch (SMSException ex) {
Object[] arg = { applicationType.getName() };
throw new EntitlementException(241, arg, ex);
} catch (SSOException ex) {
Object[] arg = { applicationType.getName() };
throw new EntitlementException(241, arg, ex);
}
}
use of com.sun.identity.entitlement.EntitlementException in project OpenAM by OpenRock.
the class EntitlementService method addSubjectAttributeNames.
/**
* Returns subject attribute names.
*
* @param applicationName Application name.
* @param names subject attribute names.
* @throws EntitlementException if subject attribute names cannot be
* returned.
*/
public void addSubjectAttributeNames(String applicationName, Set<String> names) throws EntitlementException {
if ((names == null) || names.isEmpty()) {
return;
}
try {
SSOToken token = getSSOToken();
if (token == null) {
throw new EntitlementException(225);
}
Application appl = ApplicationManager.getApplication(PolicyConstants.SUPER_ADMIN_SUBJECT, realm, applicationName);
if (appl != null) {
appl.addAttributeNames(names);
}
ServiceConfig applConf = getApplicationSubConfig(token, realm, applicationName);
String parentRealm = realm;
while (applConf == null) {
parentRealm = getParentRealm(parentRealm);
if (parentRealm == null) {
break;
}
applConf = getApplicationSubConfig(token, parentRealm, applicationName);
}
if (applConf != null) {
Set<String> orig = (Set<String>) applConf.getAttributes().get(ATTR_NAME_SUBJECT_ATTR_NAMES);
if ((orig == null) || orig.isEmpty()) {
orig = new HashSet<String>();
}
orig.addAll(names);
Map<String, Set<String>> map = new HashMap<String, Set<String>>();
map.put(ATTR_NAME_SUBJECT_ATTR_NAMES, orig);
applConf.setAttributes(map);
}
} catch (SMSException ex) {
throw new EntitlementException(220, ex);
} catch (SSOException ex) {
throw new EntitlementException(220, ex);
}
}
use of com.sun.identity.entitlement.EntitlementException 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.entitlement.EntitlementException in project OpenAM by OpenRock.
the class EntitlementService method searchApplicationNames.
/**
* Returns a set of application names for a given search criteria.
*
* @param adminSubject Admin Subject
* @param filters Set of search filter.
* @return a set of application names for a given search criteria.
* @throws EntitlementException if search failed.
*/
public Set<String> searchApplicationNames(Subject adminSubject, Set<SearchFilter> filters) throws EntitlementException {
SSOToken token = getSSOToken(adminSubject);
if (token == null) {
throw new EntitlementException(451);
}
String baseDN = getApplicationSearchBaseDN(realm);
if (!SMSEntry.checkIfEntryExists(baseDN, token)) {
return Collections.EMPTY_SET;
}
try {
Set<String> dns = SMSEntry.search(token, baseDN, getApplicationSearchFilter(filters), 0, 0, false, false);
Set<String> results = new HashSet<String>();
for (String dn : dns) {
if (!LDAPUtils.dnEquals(baseDN, dn)) {
results.add(LDAPUtils.rdnValueFromDn(dn));
}
}
return results;
} catch (SMSException e) {
throw new EntitlementException(450, e);
}
}
use of com.sun.identity.entitlement.EntitlementException 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;
}
Aggregations