use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class SetConfigurations 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);
ldapLogin();
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);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ENTITLEMENT_SVC", null);
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(EntitlementService.SERVICE_NAME, getAdminSSOToken());
validateData(attributeValues, ssm);
ServiceSchema gss = ssm.getGlobalSchema();
gss.setAttributeDefaults(attributeValues);
getOutputWriter().printlnMessage(getResourceString("set-entitlement-config-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_MODIFY_ENTITLEMENT_SVC", null);
} catch (SMSException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (CLIException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
throw e;
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class GetAssignableServices method discardServicesWithoutAttributeSchema.
private void discardServicesWithoutAttributeSchema(SSOToken adminSSOToken, Set serviceNames, IdType type) throws SMSException, SSOException {
for (Iterator iter = serviceNames.iterator(); iter.hasNext(); ) {
String serviceName = (String) iter.next();
ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, adminSSOToken);
String url = mgr.getPropertiesViewBeanURL();
if (url == null) {
ServiceSchema serviceSchema = mgr.getSchema(type.getName());
Set attributes = serviceSchema.getAttributeSchemas();
if ((attributes == null) || attributes.isEmpty()) {
iter.remove();
} else if (!hasI18nKeys(attributes)) {
iter.remove();
}
}
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class AMServiceProfileModelImpl method setAttributeValues.
/**
* Set attribute values.
*
* @param map Map of attribute name to Set of attribute values.
* @throws AMConsoleException if values cannot be set.
*/
public void setAttributeValues(Map map) throws AMConsoleException {
Set attributeSchemas = new HashSet();
attributeSchemas.addAll(xmlBuilder.getAttributeSchemas());
addMoreAttributeSchemasForModification(attributeSchemas);
// Need to find the service schema for each attributeSchema
Map mapSvcSchemaToMapNameToValues = new HashMap();
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
String name = as.getName();
Set values = (Set) map.get(name);
if (values != null) {
ServiceSchema ss = as.getServiceSchema();
Map m = (Map) mapSvcSchemaToMapNameToValues.get(ss);
if (m == null) {
m = new HashMap();
mapSvcSchemaToMapNameToValues.put(ss, m);
}
m.put(name, values);
}
}
if (!mapSvcSchemaToMapNameToValues.isEmpty()) {
for (Iterator i = mapSvcSchemaToMapNameToValues.keySet().iterator(); i.hasNext(); ) {
ServiceSchema ss = (ServiceSchema) i.next();
setDefaultValues(ss, (Map) mapSvcSchemaToMapNameToValues.get(ss));
}
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class TabControllerBase method updateStatus.
protected void updateStatus() {
boolean status = false;
SSOToken adminSSOToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ServiceSchemaManager mgr = new ServiceSchemaManager(AMAdminConstants.ADMIN_CONSOLE_SERVICE, adminSSOToken);
ServiceSchema schema = mgr.getSchema(SchemaType.GLOBAL);
AttributeSchema as = schema.getAttributeSchema(getConfigAttribute());
Set defaultValue = as.getDefaultValues();
if ((defaultValue != null) && !defaultValue.isEmpty()) {
String val = (String) defaultValue.iterator().next();
status = (val != null) && val.equals("true");
}
} catch (SMSException e) {
AMModelBase.debug.error("TabControllerBase.updateStatus", e);
} catch (SSOException e) {
AMModelBase.debug.error("TabControllerBase.updateStatus", e);
}
visible = status;
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class AMOrganizationImpl method createGroup.
protected AMGroup createGroup(String name, Map attributes, Map serviceNameAndAttrs, int type) throws AMException, SSOException {
String groupDN = AMNamingAttrManager.getNamingAttr(GROUP) + "=" + name + "," + super.entryDN;
AMObjectImpl groupImpl;
switch(type) {
case AMObject.STATIC_GROUP:
groupImpl = new AMStaticGroupImpl(super.token, groupDN);
break;
case AMObject.DYNAMIC_GROUP:
groupImpl = new AMDynamicGroupImpl(super.token, groupDN);
break;
case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
groupImpl = new AMAssignableDynamicGroupImpl(super.token, groupDN);
break;
default:
throw new UnsupportedOperationException();
}
if (serviceNameAndAttrs != null && !serviceNameAndAttrs.isEmpty()) {
Set serviceNames = serviceNameAndAttrs.keySet();
Set registered = dsServices.getRegisteredServiceNames(null, entryDN);
Iterator it = serviceNames.iterator();
while (it.hasNext()) {
String tmpS = (String) it.next();
if (!registered.contains(tmpS)) {
Object[] args = { tmpS };
throw new AMException(AMSDKBundle.getString("459", args, super.locale), "459", args);
}
}
Set objectClasses = null;
if ((serviceNames != null) && (!serviceNames.isEmpty())) {
objectClasses = AMServiceUtils.getServiceObjectClasses(token, serviceNames);
Set userOCs = (Set) attributes.get("objectclass");
objectClasses = AMCommonUtils.combineOCs(userOCs, objectClasses);
}
it = serviceNames.iterator();
while (it.hasNext()) {
String thisService = (String) it.next();
Map sAttrMap = (Map) serviceNameAndAttrs.get(thisService);
// validate the attributes and add pick the defaults.
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(thisService, token);
ServiceSchema ss = ssm.getSchema(SchemaType.GROUP);
sAttrMap = ss.validateAndInheritDefaults(sAttrMap, true);
sAttrMap = AMCommonUtils.removeEmptyValues(sAttrMap);
groupImpl.setAttributes(sAttrMap);
} catch (SMSException se) {
debug.error("AMGroupContainerImpl.createStaticGroup: " + "Data validation failed.. ", se);
}
Object[] args = { thisService };
throw new AMException(AMSDKBundle.getString("976", args, super.locale), "976", args);
}
if (objectClasses != null && !objectClasses.isEmpty()) {
groupImpl.setAttribute("objectclass", objectClasses);
}
}
groupImpl.setAttributes(attributes);
groupImpl.create();
return ((AMGroup) groupImpl);
}
Aggregations