use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class EntitlementService method createApplication.
private Application createApplication(ServiceConfig conf, String appName) throws IllegalAccessException, EntitlementException, InstantiationException, SMSException, SSOException {
final Map<String, Set<String>> data = conf.getSubConfig(appName).getAttributes();
final ApplicationType applicationType = ApplicationTypeManager.getAppplicationType(getAdminSubject(), EntitlementUtils.getAttribute(data, EntitlementUtils.APPLICATION_TYPE));
return EntitlementUtils.createApplication(applicationType, appName, data);
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class CreateApplication method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
String realm = getStringOptionValue(IArgument.REALM_NAME);
String appName = getStringOptionValue(PARAM_APPL_NAME);
String appTypeName = getStringOptionValue(PARAM_APPL_TYPE_NAME);
String datafile = getStringOptionValue(IArgument.DATA_FILE);
List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
if ((datafile == null) && (attrValues == null)) {
throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
}
Map<String, Set<String>> attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
ApplicationType applicationType = getApplicationType(appTypeName);
String[] params = { realm, appName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_APPLICATION", params);
try {
Application appl = ApplicationManager.newApplication(appName, applicationType);
setApplicationAttributes(appl, attributeValues, true);
ApplicationManager.saveApplication(getAdminSubject(), realm, appl);
String[] param = { appName };
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("create-application-succeeded"), (Object[]) param));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_CREATE_APPLICATION", params);
} catch (EntitlementException e) {
String[] paramExs = { realm, appName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_CREATE_APPLICATION", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (CLIException e) {
String[] paramExs = { realm, appName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_CREATE_APPLICATION", paramExs);
throw e;
}
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class DeleteApplicationTypes method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
List<String> appTypeNames = (List) rc.getOption(PARAM_APPL_TYPE_NAMES);
String[] param = { appTypeNames.toString() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_APPLICATION_TYPES", param);
Subject adminSubject = getAdminSubject();
try {
for (String appTypeName : appTypeNames) {
// Check it exists before deleting
ApplicationType applType = ApplicationTypeManager.getAppplicationType(adminSubject, appTypeName);
if (applType != null) {
ApplicationTypeManager.removeApplicationType(adminSubject, appTypeName);
}
}
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("delete-application-types-succeeded"), (Object[]) param));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_DELETE_APPLICATION_TYPES", param);
} catch (EntitlementException e) {
String[] params = { appTypeNames.toString(), e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_DELETE_APPLICATION_TYPES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class EntitlementService method getApplicationTypes.
/**
* Returns a set of registered application type.
*
* @return A set of registered application type.
*/
public Set<ApplicationType> getApplicationTypes() {
Set<ApplicationType> results = new HashSet<ApplicationType>();
try {
SSOToken token = getSSOToken();
if (token == null) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationTypes : " + "admin sso token is absent");
} else {
ServiceConfig conf = getApplicationTypeCollectionConfig(token);
Set<String> names = conf.getSubConfigNames();
for (String name : names) {
ServiceConfig appType = conf.getSubConfig(name);
Map<String, Set<String>> data = appType.getAttributes();
results.add(EntitlementUtils.createApplicationType(name, data));
}
}
} catch (InstantiationException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationTypes", ex);
} catch (IllegalAccessException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationTypes", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationTypes", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationTypes", ex);
}
return results;
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class EntitlementUtils method createApplicationType.
/**
* Constructs an {@link ApplicationType} object based on the provided information.
*
* @param name The name of the application type.
* @param data The configuration settings for the application type.
* @return An {@link ApplicationType} object corresponding to the provided details.
* @throws InstantiationException If the class settings cannot be instantiated.
* @throws IllegalAccessException If the class settings cannot be instantiated.
*/
public static ApplicationType createApplicationType(String name, Map<String, Set<String>> data) throws InstantiationException, IllegalAccessException {
Map<String, Boolean> actions = getActions(data);
String saveIndexImpl = getAttribute(data, CONFIG_SAVE_INDEX_IMPL);
Class saveIndex = ApplicationTypeManager.getSaveIndex(saveIndexImpl);
String searchIndexImpl = getAttribute(data, CONFIG_SEARCH_INDEX_IMPL);
Class searchIndex = ApplicationTypeManager.getSearchIndex(searchIndexImpl);
String resourceComp = getAttribute(data, CONFIG_RESOURCE_COMP_IMPL);
Class resComp = ApplicationTypeManager.getResourceComparator(resourceComp);
String applicationClassName = getAttribute(data, APPLICATION_CLASSNAME);
ApplicationType appType = new ApplicationType(name, actions, searchIndex, saveIndex, resComp);
if (applicationClassName != null) {
appType.setApplicationClassName(applicationClassName);
}
return appType;
}
Aggregations