Search in sources :

Example 1 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 2 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 3 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)

Example 4 with AttributeSchema

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

the class AMServiceProfileModelImpl method getPropertiesViewBean.

/**
     * Returns properties view bean URL for an attribute schema.
     *
     * @param name Name of attribute schema.
     * @return properties view bean URL for an attribute schema.
     */
public String getPropertiesViewBean(String name) {
    Set attributeSchemas = xmlBuilder.getAttributeSchemas();
    String url = null;
    for (Iterator iter = attributeSchemas.iterator(); iter.hasNext() && (url == null); ) {
        AttributeSchema as = (AttributeSchema) iter.next();
        if (as.getName().equals(name)) {
            url = as.getPropertiesViewBeanURL();
        }
    }
    return url;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema)

Example 5 with AttributeSchema

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

the class AMServiceProfileModelImpl method setAttributeValues.

/**
     * Set attribute values.
     *
     * @param map Map of attribute name to Set of attribute values.
     * @throws AMConsoleException if values cannot be set.
     */
public void setAttributeValues(Map map) throws AMConsoleException {
    Set attributeSchemas = new HashSet();
    attributeSchemas.addAll(xmlBuilder.getAttributeSchemas());
    addMoreAttributeSchemasForModification(attributeSchemas);
    // Need to find the service schema for each attributeSchema
    Map mapSvcSchemaToMapNameToValues = new HashMap();
    for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        String name = as.getName();
        Set values = (Set) map.get(name);
        if (values != null) {
            ServiceSchema ss = as.getServiceSchema();
            Map m = (Map) mapSvcSchemaToMapNameToValues.get(ss);
            if (m == null) {
                m = new HashMap();
                mapSvcSchemaToMapNameToValues.put(ss, m);
            }
            m.put(name, values);
        }
    }
    if (!mapSvcSchemaToMapNameToValues.isEmpty()) {
        for (Iterator i = mapSvcSchemaToMapNameToValues.keySet().iterator(); i.hasNext(); ) {
            ServiceSchema ss = (ServiceSchema) i.next();
            setDefaultValues(ss, (Map) mapSvcSchemaToMapNameToValues.get(ss));
        }
    }
}
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) HashSet(java.util.HashSet)

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