use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class AgentConfiguration method getAttributesSchemaNames.
/**
* Returns a set of attribute schema names whose schema match a given
* syntax.
*
* @param amid Identity Object. Agent Type is to be gotten from it.
* @param syntax Syntax.
* @return a set of attribute schema names whose schema match a given
* syntax.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
public static Set getAttributesSchemaNames(AMIdentity amid, AttributeSchema.Syntax syntax) throws SMSException, SSOException, IdRepoException {
Set results = new HashSet();
Set attributeSchemas = getAgentAttributeSchemas(getAgentType(amid));
if ((attributeSchemas != null) && !attributeSchemas.isEmpty()) {
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
if (as.getSyntax().equals(syntax)) {
results.add(as.getName());
}
}
}
return results;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class RealmAddServiceAttributes method getMultipleValueAttrs.
private void getMultipleValueAttrs(ServiceSchema schema, Map<String, Boolean> result) {
Set<String> attrNames = schema.getServiceAttributeNames();
for (String n : attrNames) {
AttributeSchema as = schema.getAttributeSchema(n);
AttributeSchema.Type type = as.getType();
if (type.equals(AttributeSchema.Type.LIST) || type.equals(AttributeSchema.Type.MULTIPLE_CHOICE)) {
result.put(n, true);
} else {
result.put(n, false);
}
}
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class AMAdminUtils method getDisplayableAttributeNames.
/**
* Returns a set of attribute schemas that can be displayed in console
* for a service of a given schema type.
*
* @param serviceName Name of Service.
* @param schemaType Schema Type.
* @return set of attribute schemas that can be displayed in console.
*/
public static Set getDisplayableAttributeNames(String serviceName, SchemaType schemaType) {
Set displayable = null;
Set attributeSchemas = getAttributeSchemas(serviceName, schemaType);
if ((attributeSchemas != null) && !attributeSchemas.isEmpty()) {
displayable = new HashSet(attributeSchemas.size() * 2);
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
String i18nKey = as.getI18NKey();
if ((i18nKey != null) && (i18nKey.trim().length() > 0)) {
displayable.add(as);
}
}
}
return (displayable != null) ? displayable : Collections.EMPTY_SET;
}
use of com.sun.identity.sm.AttributeSchema 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.AttributeSchema 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;
}
Aggregations