use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class GetAttributeDefaults method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
ServiceSchema ss = getServiceSchema();
IOutput outputWriter = getOutputWriter();
String[] params = { serviceName, schemaType, subSchemaName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_SCHEMA_ATTR_DEFAULTS", params);
Map attrValues = ss.getAttributeDefaults();
retainValues(rc, attrValues);
maskPasswordValues(ss, attrValues);
if (!attrValues.isEmpty()) {
outputWriter.printlnMessage(FormatUtils.printAttributeValues(getResourceString("schema-get-attribute-defaults-result"), attrValues));
outputWriter.printlnMessage(getResourceString("schema-get-attribute-defaults-succeed"));
} else {
outputWriter.printlnMessage(getResourceString("schema-get-attribute-defaults-no-matching-attr"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_SCHEMA_ATTR_DEFAULTS", params);
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class AMCommonNameGenerator method getAttributeSchemaExactNames.
private Map getAttributeSchemaExactNames(String idType) throws SMSException, SSOException, IdRepoException {
Map mapping = new HashMap();
String serviceName = IdUtils.getServiceName(IdUtils.getType(idType));
if (serviceName != null) {
ServiceSchemaManager svcSchemaMgr = new ServiceSchemaManager(serviceName, adminSSOToken);
ServiceSchema svcSchema = svcSchemaMgr.getSchema(idType);
Set attributeSchemas = (svcSchema != null) ? svcSchema.getAttributeSchemas() : Collections.EMPTY_SET;
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
String name = as.getName();
mapping.put(name.toLowerCase(), name);
}
}
return mapping;
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class AMModelBase method isAMSDKEnabled.
/**
* Returns <code>true</code> if server is running with <code>AMSDK</code>
* repo enabled.
*
* @return <code>true</code> if server is running with <code>AMSDK</code>
* repo enabled.
*/
public boolean isAMSDKEnabled() {
try {
ServiceSchemaManager schemaMgr = new ServiceSchemaManager(IdConstants.REPO_SERVICE, AMAdminUtils.getSuperAdminSSOToken());
ServiceSchema orgSchema = schemaMgr.getOrganizationSchema();
Set names = orgSchema.getSubSchemaNames();
return (names != null) && names.contains("amSDK");
} catch (SMSException e) {
debug.error("AMModelBase.isAMSDKEnabled", e);
return false;
} catch (SSOException e) {
debug.error("AMModelBase.isAMSDKEnabled", e);
return false;
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class AMModelBase method getAttributesToDisplay.
protected Set getAttributesToDisplay(ServiceSchemaManager mgr, SchemaType schemaType, String schemaName) {
ServiceSchema schema = null;
try {
schema = mgr.getSchema(schemaType);
} catch (SMSException smse) {
debug.warning("error getting schema", smse);
}
if (schema == null) {
return Collections.EMPTY_SET;
}
ServiceSchema subSchema = null;
try {
subSchema = schema.getSubSchema(schemaName);
} catch (SMSException smse) {
debug.warning("error getting subschema", smse);
}
if (subSchema == null) {
return Collections.EMPTY_SET;
}
Set attrSchemaSet = Collections.EMPTY_SET;
Set attrSchemaNames = subSchema.getAttributeSchemaNames();
if (attrSchemaNames != null) {
Collator collator = Collator.getInstance(getUserLocale());
attrSchemaSet = new TreeSet(new AMAttrSchemaComparator(collator));
Iterator asnIterator = attrSchemaNames.iterator();
while (asnIterator.hasNext()) {
String asn = (String) asnIterator.next();
AttributeSchema attrSchema = subSchema.getAttributeSchema(asn);
if (isDisplayed(attrSchema)) {
attrSchemaSet.add(attrSchema);
}
}
}
return attrSchemaSet;
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class AMAdminUtils method getSchemaSchema.
/**
* Returns service schema for an IdType.
*
* @param serviceName Name of Service.
* @param idType IdType.
* @return service schema for an IdType.
*/
public static ServiceSchema getSchemaSchema(String serviceName, IdType idType) {
ServiceSchema serviceSchema = null;
SSOToken adminSSOToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, adminSSOToken);
serviceSchema = mgr.getSchema(idType.getName());
} catch (SSOException e) {
debug.warning("AMAdminUtils.getAttributeSchemas", e);
} catch (SMSException e) {
debug.warning("AMAdminUtils.getAttributeSchemas", e);
}
return serviceSchema;
}
Aggregations