Search in sources :

Example 61 with AttributeSchema

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

the class SmsResourceProvider method addType.

private void addType(JsonValue result, String pointer, AttributeSchema attribute, ResourceBundle schemaI18n, ResourceBundle consoleI18n, Context context) {
    String type = null;
    AttributeSchema.Type attributeType = attribute.getType();
    AttributeSchema.Syntax syntax = attribute.getSyntax();
    if (attributeType == AttributeSchema.Type.LIST && (attribute.getUIType() == AttributeSchema.UIType.GLOBALMAPLIST || attribute.getUIType() == AttributeSchema.UIType.MAPLIST)) {
        type = OBJECT_TYPE;
        JsonValue fieldType = json(object());
        if (attribute.hasChoiceValues()) {
            addEnumChoices(fieldType, attribute, schemaI18n, consoleI18n, context);
        } else {
            fieldType.add(TYPE, STRING_TYPE);
        }
        result.addPermissive(new JsonPointer(pointer + "/" + PATTERN_PROPERTIES), object(field(".*", fieldType.getObject())));
    } else if (attributeType == AttributeSchema.Type.LIST) {
        type = ARRAY_TYPE;
        result.addPermissive(new JsonPointer(pointer + "/" + ITEMS), object(field(TYPE, getTypeFromSyntax(attribute.getSyntax()))));
        if (attribute.hasChoiceValues()) {
            addEnumChoices(result.get(new JsonPointer(pointer + "/" + ITEMS)), attribute, schemaI18n, consoleI18n, context);
        }
    } else if (attributeType.equals(AttributeSchema.Type.MULTIPLE_CHOICE)) {
        type = ARRAY_TYPE;
        result.addPermissive(new JsonPointer(pointer + "/" + ITEMS), object(field(TYPE, getTypeFromSyntax(attribute.getSyntax()))));
        addEnumChoices(result.get(new JsonPointer(pointer + "/" + ITEMS)), attribute, schemaI18n, consoleI18n, context);
    } else if (attributeType.equals(AttributeSchema.Type.SINGLE_CHOICE)) {
        addEnumChoices(result.get(new JsonPointer(pointer)), attribute, schemaI18n, consoleI18n, context);
    } else {
        type = getTypeFromSyntax(syntax);
    }
    if (type != null) {
        result.addPermissive(new JsonPointer(pointer + "/" + TYPE), type);
    }
    if (AttributeSchema.Syntax.PASSWORD.equals(syntax)) {
        result.addPermissive(new JsonPointer(pointer + "/" + FORMAT), PASSWORD_TYPE);
    }
}
Also used : AttributeSchema(com.sun.identity.sm.AttributeSchema) JsonValue(org.forgerock.json.JsonValue) Syntax(com.sun.identity.sm.AttributeSchema.Syntax) JsonPointer(org.forgerock.json.JsonPointer)

Example 62 with AttributeSchema

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

the class PropertiesFinder method getProperty.

public static String getProperty(String propertyName, AttributeStruct ast) {
    String value = null;
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    try {
        ServiceSchemaManager ssm = new ServiceSchemaManager(ast.serviceName, adminToken);
        if (ssm.getRevisionNumber() >= ast.revisionNumber) {
            ServiceSchema ss = ssm.getGlobalSchema();
            if (ss != null) {
                AttributeSchema as = ss.getAttributeSchema(ast.attributeName);
                if (as != null) {
                    Set values = as.getDefaultValues();
                    if ((values != null) && !values.isEmpty()) {
                        value = (String) values.iterator().next();
                    }
                }
            }
        }
    } catch (SSOException ex) {
    // ignore: Service may not be present.
    } catch (SMSException ex) {
    // ignore: Service may not be present.
    }
    return value;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 63 with AttributeSchema

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

the class PossibleLocales method getChoiceValues.

/**
     * Returns a map of locales to its localized name.
     * 
     * @return a map of locales to its localized name.
     */
public Map getChoiceValues() {
    Map map = new HashMap();
    /*
         * provides a blank value because preferred locale attribute value can
         * be blanked.
         */
    map.put("", "-");
    ServiceSchemaManager mgr = getG11NServiceSchemaManager();
    Set values = DEFAULT_LOCALES;
    if (mgr != null) {
        AttributeSchema attributeSchema = getLocaleCharsetMappingAttributeSchema(mgr);
        if (attributeSchema != null) {
            values = attributeSchema.getDefaultValues();
        }
    }
    if ((values != null) && !values.isEmpty()) {
        for (Iterator iter = values.iterator(); iter.hasNext(); ) {
            String locale = parseLocaleCharsetValue((String) iter.next());
            if ((locale != null) && (locale.length() > 0)) {
                map.put(locale, locale);
            }
        }
    }
    return map;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AttributeSchema(com.sun.identity.sm.AttributeSchema) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 64 with AttributeSchema

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

the class AgentConfiguration method getAttributesSchemaNames.

private static Set getAttributesSchemaNames(AMIdentity amid) 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();
            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 65 with AttributeSchema

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

the class AgentConfiguration method getChoiceValues.

/**
     * Returns choice values of an attribute schema.
     *
     * @param name Name of attribute schema.
     * @param agentType Type of agent.
     * @return choice values of an attribute schema.
     * @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 getChoiceValues(String name, String agentType) throws SMSException, SSOException {
    Map choiceValues = new HashMap();
    AttributeSchema as = getAgentAttributeSchema(name, agentType);
    if (as != null) {
        String[] cValues = as.getChoiceValues();
        if (cValues != null) {
            for (int i = 0; i < cValues.length; i++) {
                String v = cValues[i];
                choiceValues.put(as.getChoiceValueI18NKey(v), v);
            }
        }
    }
    return choiceValues;
}
Also used : HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map)

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