Search in sources :

Example 16 with AttributeSchema

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

the class SMDiscoveryServiceModelImpl method getDiscoEntry.

/**
     * Returns resource offering entry stored in the model map for a given
     * type.
     *
     * @param dynamic value to indicate if it is a dynamic or not.
     * @return resource offering entry stored in the model map for a given
     * type.
     */
public Set getDiscoEntry(boolean dynamic) {
    Set set = null;
    if (dynamic) {
    // TO FIX
    } else {
        ServiceSchemaManager mgr = getServiceSchemaManager();
        try {
            ServiceSchema schema = mgr.getSchema(SchemaType.GLOBAL);
            AttributeSchema as = schema.getAttributeSchema(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF);
            set = as.getDefaultValues();
        } catch (SMSException e) {
            debug.error("SMDiscoveryServiceModelImpl.getDiscoEntry", e);
        }
    }
    return set;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 17 with AttributeSchema

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

the class SCModelBase method getAttributeValues.

private Map getAttributeValues(ServiceSchema schema, Set attributes) {
    Map values = new HashMap(attributes.size() * 2);
    for (Iterator x = attributes.iterator(); x.hasNext(); ) {
        String attributeName = (String) x.next();
        AttributeSchema as = (AttributeSchema) schema.getAttributeSchema(attributeName);
        if (as != null) {
            AttributeSchema.Type type = as.getType();
            if ((type == AttributeSchema.Type.MULTIPLE_CHOICE) || (type == AttributeSchema.Type.SINGLE_CHOICE)) {
                Map m = new HashMap(4);
                m.put(AMAdminConstants.CHOICES, AMAdminUtils.toSet(as.getChoiceValues()));
                m.put(AMAdminConstants.VALUES, as.getDefaultValues());
                values.put(as.getName(), m);
            } else {
                values.put(as.getName(), as.getDefaultValues());
            }
        }
    }
    return (values == null) ? Collections.EMPTY_MAP : values;
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with AttributeSchema

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

the class AMClientCapData method getSchemaMap.

/**
     * Cache for the attribute schemas.
     */
private static synchronized Map getSchemaMap() {
    if (schemaMap == null) {
        Set set = clientSchema.getAttributeSchemas();
        schemaMap = new HashMap();
        Iterator itr = set.iterator();
        while (itr.hasNext()) {
            AttributeSchema prop = (AttributeSchema) itr.next();
            String name = prop.getName();
            schemaMap.put(name, prop);
        }
    }
    return schemaMap;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema)

Example 19 with AttributeSchema

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

the class EntitiesModelImpl method getAttributeValues.

/**
     * Returns attribute values of an entity object.
     *
     * @param universalId Universal ID of the entity.
     * @param bCreate true for creation page
     * @return attribute values of an entity object.
     * @throws AMConsoleException if object cannot located.
     */
public Map getAttributeValues(String universalId, boolean bCreate) throws AMConsoleException {
    String[] param = { universalId, "*" };
    logEvent("ATTEMPT_READ_IDENTITY_ATTRIBUTE_VALUE", param);
    try {
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
        Map tempMap = new CaseInsensitiveHashMap();
        tempMap.putAll(amid.getAttributes());
        validateUserStatusEntry(tempMap);
        Map values = new HashMap();
        String agentType = null;
        boolean webJ2EEagent = false;
        Set agentTypes = amid.getAttribute("AgentType");
        if ((agentTypes != null) && !agentTypes.isEmpty()) {
            agentType = (String) agentTypes.iterator().next();
            webJ2EEagent = agentType.equals(AgentConfiguration.AGENT_TYPE_J2EE) || agentType.equals(AgentConfiguration.AGENT_TYPE_WEB) || agentType.equals(AgentConfiguration.AGENT_TYPE_AGENT_AUTHENTICATOR);
        }
        Set attributeSchemas = getAttributeSchemas(amid.getType().getName(), agentType, bCreate);
        Set attributeNames = new HashSet();
        for (Iterator iter = attributeSchemas.iterator(); iter.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) iter.next();
            String name = as.getName();
            if (!tempMap.containsKey(name)) {
                values.put(name, Collections.EMPTY_SET);
            } else {
                if (webJ2EEagent && name.equals(AGENT_ATTRIBUTE_LIST)) {
                    Set newValues = new HashSet();
                    Set temp = (Set) tempMap.get(name);
                    for (Iterator i = temp.iterator(); i.hasNext(); ) {
                        String val = (String) i.next();
                        if (val.startsWith(AGENT_ROOT_URL)) {
                            val = val.substring(AGENT_ROOT_URL.length());
                        }
                        newValues.add(val);
                    }
                    values.put(name, newValues);
                } else {
                    values.put(name, tempMap.get(name));
                }
            }
            attributeNames.add(name);
        }
        for (Iterator iter = values.keySet().iterator(); iter.hasNext(); ) {
            String name = (String) iter.next();
            if (!attributeNames.contains(name)) {
                iter.remove();
            }
        }
        logEvent("SUCCEED_READ_IDENTITY_ATTRIBUTE_VALUE", param);
        return values;
    } catch (IdRepoException e) {
        String[] paramsEx = { universalId, "*", getErrorString(e) };
        logEvent("IDM_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        debug.warning("EntitiesModelImpl.getAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] paramsEx = { universalId, "*", getErrorString(e) };
        logEvent("SMS_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        debug.warning("EntitiesModelImpl.getAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] paramsEx = { universalId, "*", getErrorString(e) };
        logEvent("SSO_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        debug.warning("EntitiesModelImpl.getAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) HashSet(java.util.HashSet)

Example 20 with AttributeSchema

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

the class EntitiesModelImpl method hasI18nKeys.

private boolean hasI18nKeys(Set attributeSchemes) {
    boolean has = false;
    for (Iterator i = attributeSchemes.iterator(); (i.hasNext() && !has); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        String i18nKey = as.getI18NKey();
        has = (i18nKey != null) && (i18nKey.length() > 0);
    }
    return has;
}
Also used : 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