use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class ShowApplication method displayAttrs.
private void displayAttrs(IOutput writer, Application appl) {
ApplicationType applType = appl.getApplicationType();
writer.printlnMessage(ATTR_APPLICATIONTYPE + '=' + applType.getName());
String description = appl.getDescription();
if (description == null) {
description = "";
}
writer.printlnMessage(ATTR_DESCRIPTION + "=" + description);
writer.printlnMessage(ATTR_CREATED_BY + "=" + appl.getCreatedBy());
writer.printlnMessage(ATTR_CREATION_DATE + "=" + appl.getCreationDate());
writer.printlnMessage(ATTR_LAST_MODIFIED_BY + "=" + appl.getLastModifiedBy());
writer.printlnMessage(ATTR_LAST_MODIFICATION_DATE + "=" + appl.getLastModifiedDate());
displayAttributes(writer, ATTR_SUBJECT_ATTRIBUTE_NAMES, appl.getAttributeNames());
displayAttributes(writer, ATTR_RESOURCE_TYPE_UUIDS, appl.getResourceTypeUuids());
displayAttributes(writer, ATTR_CONDITIONS, appl.getConditions());
displayAttributes(writer, ATTR_SUBJECTS, appl.getSubjects());
displayClassName(writer, ATTR_ENTITLEMENT_COMBINER, appl.getEntitlementCombinerClass());
displayClassName(writer, ATTR_RESOURCE_COMPARATOR, appl.getResourceComparatorClass());
displayClassName(writer, ATTR_SAVE_INDEX, appl.getSaveIndexClass());
displayClassName(writer, ATTR_SEARCH_INDEX, appl.getSearchIndexClass());
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class ApplicationImpl method getApplicationType.
protected ApplicationType getApplicationType(String name) throws CLIException {
ApplicationType applType = ApplicationTypeManager.getAppplicationType(getAdminSubject(), name);
if (applType == null) {
String msg = getResourceString("application-type-invalid");
Object[] param = { name };
throw new CLIException(MessageFormat.format(msg, param), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
return applType;
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class ConfigureOAuth2 method getUrlResourceTypeId.
private String getUrlResourceTypeId(Subject adminSubject, String realm) throws EntitlementException, WorkflowException {
Application application = ApplicationManager.getApplication(adminSubject, realm, POLICY_APPLICATION_NAME);
if (application == null) {
ApplicationType applicationType = ApplicationTypeManager.getAppplicationType(adminSubject, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
application = ApplicationManager.newApplication(POLICY_APPLICATION_NAME, applicationType);
}
Set<String> resourceTypeIds = application.getResourceTypeUuids();
ResourceTypeService resourceTypeService = InjectorHolder.getInstance(ResourceTypeService.class);
for (String id : resourceTypeIds) {
ResourceType resourceType = resourceTypeService.getResourceType(adminSubject, realm, id);
if (POLICY_RESOURCE_TYPE_NAME.equalsIgnoreCase(resourceType.getName())) {
return id;
}
}
QueryFilter<SmsAttribute> name = equalTo(SmsAttribute.newSearchableInstance("name"), POLICY_RESOURCE_TYPE_NAME);
Set<ResourceType> types = resourceTypeService.getResourceTypes(name, adminSubject, realm);
ResourceType resourceType;
if (types == null || types.isEmpty()) {
resourceType = ResourceType.builder().addPatterns(asSet("*://*:*/*/authorize?*")).addActions(new ImmutableMap.Builder<String, Boolean>().put("GET", true).put("POST", true).build()).setName(POLICY_RESOURCE_TYPE_NAME).setUUID(UUID.randomUUID().toString()).build();
resourceType = resourceTypeService.saveResourceType(adminSubject, realm, resourceType);
} else {
resourceType = types.iterator().next();
}
application.addAllResourceTypeUuids(asSet(resourceType.getUUID()));
application.setEntitlementCombiner(DenyOverride.class);
ApplicationManager.saveApplication(adminSubject, realm, application);
return resourceType.getUUID();
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class CreateApplicationType 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 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);
String[] params = { appTypeName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_APPLICATION_TYPE", params);
try {
Map<String, Boolean> actions = getActions(attributeValues);
Class searchIndex = getClassAttribute(ATTR_SEARCH_INDEX, attributeValues);
Class saveIndex = getClassAttribute(ATTR_SAVE_INDEX, attributeValues);
Class resourceComp = getClassAttribute(ATTR_RESOURCE_COMPARATOR, attributeValues);
ApplicationType applType = new ApplicationType(appTypeName, actions, searchIndex, saveIndex, resourceComp);
ApplicationTypeManager.saveApplicationType(getAdminSubject(), applType);
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("create-application-type-succeeded"), (Object[]) params));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_CREATE_APPLICATION_TYPE", params);
} catch (ClassCastException e) {
String[] paramExs = { appTypeName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_CREATE_APPLICATION_TYPE", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (EntitlementException e) {
String[] paramExs = { appTypeName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_CREATE_APPLICATION_TYPE", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (InstantiationException e) {
String[] paramExs = { appTypeName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_CREATE_APPLICATION_TYPE", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IllegalAccessException e) {
String[] paramExs = { appTypeName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_CREATE_APPLICATION_TYPE", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (CLIException e) {
String[] paramExs = { appTypeName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_CREATE_APPLICATION_TYPE", paramExs);
throw e;
}
}
use of com.sun.identity.entitlement.ApplicationType in project OpenAM by OpenRock.
the class ShowApplicationType 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 appTypeName = getStringOptionValue(PARAM_APPL_TYPE_NAME);
String[] params = { appTypeName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_APPLICATION_TYPE", params);
ApplicationType applType = ApplicationTypeManager.getAppplicationType(getAdminSubject(), appTypeName);
IOutput writer = getOutputWriter();
if (applType == null) {
Object[] param = { appTypeName };
writer.printlnMessage(MessageFormat.format(getResourceString("show-application-type-not-found"), param));
} else {
displayAttrs(writer, applType);
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SHOW_APPLICATION_TYPE", params);
}
Aggregations