Search in sources :

Example 31 with AttributeSchema

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;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashSet(java.util.HashSet)

Example 32 with AttributeSchema

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);
        }
    }
}
Also used : AttributeSchema(com.sun.identity.sm.AttributeSchema)

Example 33 with AttributeSchema

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;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashSet(java.util.HashSet)

Example 34 with AttributeSchema

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;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 35 with AttributeSchema

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;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) Collator(java.text.Collator)

Aggregations

AttributeSchema (com.sun.identity.sm.AttributeSchema)149 Iterator (java.util.Iterator)80 ServiceSchema (com.sun.identity.sm.ServiceSchema)76 Set (java.util.Set)75 SMSException (com.sun.identity.sm.SMSException)67 HashSet (java.util.HashSet)59 SSOException (com.iplanet.sso.SSOException)58 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)46 HashMap (java.util.HashMap)36 Map (java.util.Map)34 CLIException (com.sun.identity.cli.CLIException)28 CLIRequest (com.sun.identity.cli.CLIRequest)18 AfterTest (org.testng.annotations.AfterTest)18 BeforeTest (org.testng.annotations.BeforeTest)18 Parameters (org.testng.annotations.Parameters)18 Test (org.testng.annotations.Test)18 IOutput (com.sun.identity.cli.IOutput)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)9 SSOToken (com.iplanet.sso.SSOToken)8