Search in sources :

Example 96 with AttributeSchema

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

the class SetAttributeSchemaBooleanValues method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeName = getStringOptionValue(IArgument.ATTRIBUTE_NAME);
    String trueValue = getStringOptionValue(ARGUMENT_TRUE_VALUE);
    String trueI18nKey = getStringOptionValue(ARGUMENT_TRUE_I18N_KEY);
    String falseValue = getStringOptionValue(ARGUMENT_FALSE_VALUE);
    String falseI18nKey = getStringOptionValue(ARGUMENT_FALSE_I18N_KEY);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    String[] params = { serviceName, schemaType, subSchemaName, attributeName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_ATTRIBUTE_SCHEMA_BOOLEAN_VALUES", params);
    try {
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeName, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeName, "FAILED_SET_ATTRIBUTE_SCHEMA_BOOLEAN_VALUES", args);
        }
        attrSchema.setBooleanValues(trueValue, trueI18nKey, falseValue, falseI18nKey);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_ATTRIBUTE_SCHEMA_BOOLEAN_VALUES", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-set-boolean-values-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeName, e.getMessage() };
        debugError("SetAttributeSchemaBooleanValues.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_BOOLEAN_VALUES", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeName, e.getMessage() };
        debugError("SetAttributeSchemaBooleanValues.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_BOOLEAN_VALUES", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 97 with AttributeSchema

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

the class SetAttributeSchemaEndRange method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
    String range = getStringOptionValue(ARGUMENT_RANGE);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, range };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_ATTRIBUTE_SCHEMA_END_RANGE", params);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeSchemaName, "FAILED_SET_ATTRIBUTE_SCHEMA_END_RANGE", args);
        }
        attrSchema.setEndRange(range);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_ATTRIBUTE_SCHEMA_END_RANGE", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-set-end-range-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, e.getMessage() };
        debugError("SetAttributeSchemaEndRange.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_END_RANGE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, e.getMessage() };
        debugError("SetAttributeSchemaEndRange.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_END_RANGE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 98 with AttributeSchema

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

the class AgentsModelImpl method getTokenConversionTypes.

/**
     * Returns Token Conversion Types.
     * 
     * @return Token Conversion Types.
     */
public List getTokenConversionTypes() {
    List choices = null;
    AttributeSchema as = AMAdminUtils.getAttributeSchema(IdConstants.AGENT_SERVICE, SchemaType.ORGANIZATION, "WSPAgent", "TokenConversionType");
    if (as != null) {
        String[] choiceValues = as.getChoiceValues();
        int sz = choiceValues.length;
        choices = new ArrayList(sz);
        for (int i = 0; i < sz; i++) {
            choices.add(choiceValues[i]);
        }
    }
    return (choices == null) ? Collections.EMPTY_LIST : choices;
}
Also used : AttributeSchema(com.sun.identity.sm.AttributeSchema) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 99 with AttributeSchema

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

the class SubConfigMeta method getServiceSchemaDefaultValues.

/**
     * Returns default values of sub service schema of current sub schema. Map
     * of attribute name (String) to attribute values (Set).
     *
     * @param name Name of sub schema.
     * @throws SMSException if default values be determined.
     */
public Map getServiceSchemaDefaultValues(String name) throws SMSException {
    Map defaultValues = new HashMap();
    ServiceSchema ss = corrSchema.getSubSchema(name);
    Set attributeSchemas = ss.getAttributeSchemas();
    for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        Set values = as.getDefaultValues();
        if (values != null) {
            defaultValues.put(as.getName(), values);
        }
    }
    return defaultValues;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SortedSet(java.util.SortedSet) Set(java.util.Set) TreeSet(java.util.TreeSet) 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 100 with AttributeSchema

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

the class EntitiesModelImpl method correctAttributeNames.

/*
     * For whatever reason, AMIdentity.getServiceAttributes method
     * is returning attribute name is lowercase. Now, we have to
     * correct the case accordingly.
     */
private Map correctAttributeNames(AMIdentity amid, String serviceName, Map values) {
    Map correctedValues = new HashMap(values.size());
    ServiceSchema serviceSchema = AMAdminUtils.getSchemaSchema(serviceName, amid.getType());
    Set attributes = serviceSchema.getAttributeSchemas();
    Set emptySet = new HashSet();
    emptySet.add("");
    if ((attributes != null) && !attributes.isEmpty()) {
        for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) iter.next();
            String attrName = as.getName();
            Object val = values.get(attrName.toLowerCase());
            if (val != null) {
                correctedValues.put(attrName, val);
            } else {
                correctedValues.put(attrName, emptySet);
            }
        }
    }
    if (amid.getType().equals(IdType.ROLE)) {
        Object val = values.get(AMIdentity.COS_PRIORITY);
        if (val != null) {
            correctedValues.put(AMIdentity.COS_PRIORITY, val);
        } else {
            correctedValues.put(AMIdentity.COS_PRIORITY, emptySet);
        }
    }
    return correctedValues;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) Map(java.util.Map) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) 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