Search in sources :

Example 66 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AgentConfiguration method getDefaultValues.

/**
     * Returns the default values of attribute schemas
     * of a given agent type.
     *
     * @param agentType Type of agent.
     * @param bGroup <code>true</code> if this is for a group.
     * @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 Map getDefaultValues(String agentType, boolean bGroup) throws SMSException, SSOException {
    Map mapDefault = new HashMap();
    Set attributeSchemas = getAgentAttributeSchemas(agentType);
    if ((attributeSchemas != null) && !attributeSchemas.isEmpty()) {
        for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) i.next();
            mapDefault.put(as.getName(), as.getDefaultValues());
        }
    }
    if (bGroup) {
        mapDefault.remove(ATTR_NAME_PWD);
    }
    return mapDefault;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map)

Example 67 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AgentConfiguration method getAttributeSchemas.

/**
     * Returns attribute schema for a given set of attribute names.
     *
     * @param agentType Agent type.
     * @param names Set of attribute names.
     * @return localized names for a given set of attribute names.
     */
public static Map getAttributeSchemas(String agentType, Collection names) throws SMSException, SSOException {
    Map map = new HashMap();
    Set attributeSchema = getAgentAttributeSchemas(agentType);
    for (Iterator i = attributeSchema.iterator(); i.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        if (names.contains(as.getName())) {
            map.put(as.getName(), as);
        }
    }
    return map;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map)

Example 68 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class GetAttributes method isPassword.

private boolean isPassword(Set attrSchemas, String attrName) {
    boolean isPwd = false;
    for (Iterator i = attrSchemas.iterator(); i.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        if (attrName.equals(as.getName())) {
            AttributeSchema.Syntax syntax = as.getSyntax();
            isPwd = (syntax != null) && (syntax == AttributeSchema.Syntax.PASSWORD);
            break;
        }
    }
    return isPwd;
}
Also used : Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema)

Example 69 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AMServiceProfileModelImpl method getAttributeValues.

/**
     * Returns attributes values.
     *
     * @return attributes values.
     */
public Map getAttributeValues() {
    String[] param = { serviceName };
    logEvent("ATTEMPT_READ_ALL_GLOBAL_DEFAULT_ATTRIBUTE_VALUES", param);
    Set attributeSchemas = xmlBuilder.getAttributeSchemas();
    Map values = new HashMap(attributeSchemas.size() * 2);
    for (Iterator iter = attributeSchemas.iterator(); iter.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) iter.next();
        AttributeSchema.UIType uiType = as.getUIType();
        if ((uiType == null) || (!uiType.equals(AttributeSchema.UIType.NAME_VALUE_LIST) && !uiType.equals(AttributeSchema.UIType.BUTTON) && !uiType.equals(AttributeSchema.UIType.LINK))) {
            AttributeSchema.Type type = as.getType();
            if ((type == AttributeSchema.Type.MULTIPLE_CHOICE) || (type == AttributeSchema.Type.SINGLE_CHOICE)) {
                Map tmp = new HashMap(4);
                tmp.put("choices", AMAdminUtils.toSet(as.getChoiceValues()));
                tmp.put("values", as.getDefaultValues());
                values.put(as.getName(), tmp);
            }
            values.put(as.getName(), as.getDefaultValues());
        }
    }
    logEvent("SUCCEED_READ_ALL_GLOBAL_DEFAULT_ATTRIBUTE_VALUES", param);
    return values;
}
Also used : 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)

Example 70 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AMServiceProfileModelImpl method getAttributeValues.

/**
     * Returns attribute values.
     *
     * @param name Name of attribute.
     * @return attribute values.
     */
public Set getAttributeValues(String name) {
    boolean found = false;
    Set values = null;
    Set attributeSchemas = xmlBuilder.getAttributeSchemas();
    String[] params = { serviceName, name };
    logEvent("ATTEMPT_READ_GLOBAL_DEFAULT_ATTRIBUTE_VALUES", params);
    for (Iterator i = attributeSchemas.iterator(); i.hasNext() && !found; ) {
        AttributeSchema as = (AttributeSchema) i.next();
        if (as.getName().equals(name)) {
            values = as.getDefaultValues();
            found = true;
        }
    }
    if (found) {
        logEvent("SUCCEED_READ_GLOBAL_DEFAULT_ATTRIBUTE_VALUES", params);
    } else {
        logEvent("FAILED_READ_GLOBAL_DEFAULT_ATTRIBUTE_VALUES", params);
    }
    return (values == null) ? Collections.EMPTY_SET : values;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema)

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