use of com.sun.identity.sm.ServiceSchemaManager 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.ServiceSchemaManager 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.ServiceSchemaManager 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.ServiceSchemaManager 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);
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class AuthUtils method getAuthRevisionNumber.
public static int getAuthRevisionNumber() {
try {
SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
ServiceSchemaManager scm = new ServiceSchemaManager(ISAuthConstants.AUTH_SERVICE_NAME, token);
return scm.getRevisionNumber();
} catch (Exception e) {
if (utilDebug.messageEnabled()) {
utilDebug.message("getAuthRevisionNumber error", e);
}
}
return 0;
}
Aggregations