Search in sources :

Example 66 with ServiceSchema

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

the class GetAttributeDefaults 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);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    String[] params = { serviceName, schemaType, subSchemaName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_SCHEMA_ATTR_DEFAULTS", params);
    Map attrValues = ss.getAttributeDefaults();
    retainValues(rc, attrValues);
    maskPasswordValues(ss, attrValues);
    if (!attrValues.isEmpty()) {
        outputWriter.printlnMessage(FormatUtils.printAttributeValues(getResourceString("schema-get-attribute-defaults-result"), attrValues));
        outputWriter.printlnMessage(getResourceString("schema-get-attribute-defaults-succeed"));
    } else {
        outputWriter.printlnMessage(getResourceString("schema-get-attribute-defaults-no-matching-attr"));
    }
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_SCHEMA_ATTR_DEFAULTS", params);
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) IOutput(com.sun.identity.cli.IOutput) Map(java.util.Map)

Example 67 with ServiceSchema

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

the class AMCommonNameGenerator method getAttributeSchemaExactNames.

private Map getAttributeSchemaExactNames(String idType) throws SMSException, SSOException, IdRepoException {
    Map mapping = new HashMap();
    String serviceName = IdUtils.getServiceName(IdUtils.getType(idType));
    if (serviceName != null) {
        ServiceSchemaManager svcSchemaMgr = new ServiceSchemaManager(serviceName, adminSSOToken);
        ServiceSchema svcSchema = svcSchemaMgr.getSchema(idType);
        Set attributeSchemas = (svcSchema != null) ? svcSchema.getAttributeSchemas() : Collections.EMPTY_SET;
        for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) i.next();
            String name = as.getName();
            mapping.put(name.toLowerCase(), name);
        }
    }
    return mapping;
}
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) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 68 with ServiceSchema

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

the class AMModelBase method isAMSDKEnabled.

/**
     * Returns <code>true</code> if server is running with <code>AMSDK</code>
     * repo enabled.
     * 
     * @return <code>true</code> if server is running with <code>AMSDK</code>
     * repo enabled.
     */
public boolean isAMSDKEnabled() {
    try {
        ServiceSchemaManager schemaMgr = new ServiceSchemaManager(IdConstants.REPO_SERVICE, AMAdminUtils.getSuperAdminSSOToken());
        ServiceSchema orgSchema = schemaMgr.getOrganizationSchema();
        Set names = orgSchema.getSubSchemaNames();
        return (names != null) && names.contains("amSDK");
    } catch (SMSException e) {
        debug.error("AMModelBase.isAMSDKEnabled", e);
        return false;
    } catch (SSOException e) {
        debug.error("AMModelBase.isAMSDKEnabled", e);
        return false;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 69 with ServiceSchema

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

the class AMModelBase method getAttributesToDisplay.

protected Set getAttributesToDisplay(ServiceSchemaManager mgr, SchemaType schemaType, String schemaName) {
    ServiceSchema schema = null;
    try {
        schema = mgr.getSchema(schemaType);
    } catch (SMSException smse) {
        debug.warning("error getting schema", smse);
    }
    if (schema == null) {
        return Collections.EMPTY_SET;
    }
    ServiceSchema subSchema = null;
    try {
        subSchema = schema.getSubSchema(schemaName);
    } catch (SMSException smse) {
        debug.warning("error getting subschema", smse);
    }
    if (subSchema == null) {
        return Collections.EMPTY_SET;
    }
    Set attrSchemaSet = Collections.EMPTY_SET;
    Set attrSchemaNames = subSchema.getAttributeSchemaNames();
    if (attrSchemaNames != null) {
        Collator collator = Collator.getInstance(getUserLocale());
        attrSchemaSet = new TreeSet(new AMAttrSchemaComparator(collator));
        Iterator asnIterator = attrSchemaNames.iterator();
        while (asnIterator.hasNext()) {
            String asn = (String) asnIterator.next();
            AttributeSchema attrSchema = subSchema.getAttributeSchema(asn);
            if (isDisplayed(attrSchema)) {
                attrSchemaSet.add(attrSchema);
            }
        }
    }
    return attrSchemaSet;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) Collator(java.text.Collator)

Example 70 with ServiceSchema

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

the class AMAdminUtils method getSchemaSchema.

/**
     * Returns service schema for an IdType.
     *
     * @param serviceName Name of Service.
     * @param idType IdType.
     * @return service schema for an IdType.
     */
public static ServiceSchema getSchemaSchema(String serviceName, IdType idType) {
    ServiceSchema serviceSchema = null;
    SSOToken adminSSOToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, adminSSOToken);
        serviceSchema = mgr.getSchema(idType.getName());
    } catch (SSOException e) {
        debug.warning("AMAdminUtils.getAttributeSchemas", e);
    } catch (SMSException e) {
        debug.warning("AMAdminUtils.getAttributeSchemas", e);
    }
    return serviceSchema;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Aggregations

ServiceSchema (com.sun.identity.sm.ServiceSchema)216 SMSException (com.sun.identity.sm.SMSException)152 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 SSOException (com.iplanet.sso.SSOException)117 Set (java.util.Set)101 AttributeSchema (com.sun.identity.sm.AttributeSchema)76 HashSet (java.util.HashSet)71 Map (java.util.Map)70 HashMap (java.util.HashMap)57 Iterator (java.util.Iterator)56 CLIException (com.sun.identity.cli.CLIException)46 SSOToken (com.iplanet.sso.SSOToken)27 IOutput (com.sun.identity.cli.IOutput)26 BeforeTest (org.testng.annotations.BeforeTest)22 CLIRequest (com.sun.identity.cli.CLIRequest)21 ByteString (org.forgerock.opendj.ldap.ByteString)21 AfterTest (org.testng.annotations.AfterTest)21 Test (org.testng.annotations.Test)21 Parameters (org.testng.annotations.Parameters)18 TreeSet (java.util.TreeSet)15