Search in sources :

Example 21 with ServiceSchema

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

the class SchemaTest method setAttributeSchemaChoiceValues.

@Parameters({ "subschema" })
@Test(groups = { "schema", "set-attr-choicevals", "attribute-schema-ops", "subschema" })
public void setAttributeSchemaChoiceValues(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("setAttributeSchemaChoiceValues", params);
    String[] args = (subschema.length() == 0) ? new String[9] : new String[11];
    args[0] = "set-attr-choicevals";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
    args[2] = TEST_SERVICE;
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE;
    args[4] = "global";
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_NAME;
    args[6] = "mock-single-choice";
    args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.CHOICE_VALUES;
    args[8] = "i18nKey1=choice1";
    if (subschema.length() > 0) {
        args[9] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
        args[10] = subschema;
    }
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
        ServiceSchema serviceSchema = mgr.getGlobalSchema();
        if (subschema.length() > 0) {
            serviceSchema = serviceSchema.getSubSchema(subschema);
        }
        AttributeSchema as = serviceSchema.getAttributeSchema("mock-single-choice");
        String[] choiceValues = as.getChoiceValues();
        assert (choiceValues.length == 1);
        assert choiceValues[0].equals("choice1");
        String i18nKey = as.getChoiceValueI18NKey("choice1");
        assert i18nKey.equals("i18nKey1");
        exiting("setAttributeSchemaChoiceValues");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "setAttributeSchemaChoiceValues", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "setAttributeSchemaChoiceValues", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "setAttributeSchemaChoiceValues", e.getMessage());
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 22 with ServiceSchema

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

the class SchemaTest method removeSubSchema.

@Test(groups = { "schema", "remove-sub-schema" }, dependsOnMethods = { "addSubSchema" })
public void removeSubSchema() throws CLIException, SMSException, SSOException {
    entering("removeSubSchema", null);
    String[] args = { "remove-sub-schema", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE, "global", CLIConstants.PREFIX_ARGUMENT_LONG + RemoveSubSchema.ARGUMENT_SCHEMA_NAMES, "subschema" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
        ServiceSchema globalSchema = mgr.getSchema(SchemaType.GLOBAL);
        ServiceSchema s = globalSchema.getSubSchema("subschema");
        assert (s == null);
        exiting("removeSubSchema");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 23 with ServiceSchema

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

the class SchemaTest method removeAttributeDefaultValues.

@Parameters({ "subschema" })
@Test(groups = { "schema", "remove-attr-defs", "attribute-schema-ops", "subschema" }, dependsOnMethods = { "showAttributeDefaultValues" })
public void removeAttributeDefaultValues(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("removeAttributeDefaultValues", params);
    String[] args = (subschema.length() == 0) ? new String[7] : new String[9];
    args[0] = "remove-attr-defs";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
    args[2] = TEST_SERVICE;
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE;
    args[4] = "global";
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_NAMES;
    args[6] = "mock-add";
    if (subschema.length() > 0) {
        args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
        args[8] = subschema;
    }
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
        ServiceSchema serviceSchema = mgr.getGlobalSchema();
        if (subschema.length() > 0) {
            serviceSchema = serviceSchema.getSubSchema(subschema);
        }
        AttributeSchema as = serviceSchema.getAttributeSchema("mock-add");
        Set values = as.getDefaultValues();
        assert values.isEmpty();
        exiting("removeAttributeDefaultValues");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "removeAttributeDefaultValues", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "removeAttributeDefaultValues", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "removeAttributeDefaultValues", e.getMessage());
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 24 with ServiceSchema

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

the class DelegationManager method loadDelegationPlugin.

/**
     * Loads the default implementation of DelegationInterface
     */
static synchronized DelegationInterface loadDelegationPlugin() throws DelegationException {
    if (pluginInstance == null) {
        try {
            // get super admin user token
            SSOToken privilegedToken = getAdminToken();
            ServiceSchemaManager ssm = new ServiceSchemaManager(DELEGATION_SERVICE, privilegedToken);
            ServiceSchema globalSchema = ssm.getGlobalSchema();
            if (globalSchema != null) {
                Map attributeDefaults = globalSchema.getAttributeDefaults();
                if (attributeDefaults != null) {
                    subjectIdTypes.addAll((Set) attributeDefaults.get(SUBJECT_ID_TYPES));
                }
            }
            if (debug.messageEnabled()) {
                debug.message("Configured Subject ID Types: " + subjectIdTypes);
            }
            Set pluginNames = ssm.getPluginSchemaNames(DELEGATION_PLUGIN_INTERFACE, null);
            if (pluginNames == null) {
                throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
            }
            if (debug.messageEnabled()) {
                debug.message("pluginNames=" + pluginNames);
            }
            // for the time being, only support one plugin
            Iterator it = pluginNames.iterator();
            if (it.hasNext()) {
                String pluginName = (String) it.next();
                PluginSchema ps = ssm.getPluginSchema(pluginName, DELEGATION_PLUGIN_INTERFACE, null);
                if (ps == null) {
                    throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
                }
                String className = ps.getClassName();
                if (debug.messageEnabled()) {
                    debug.message("Plugin class name:" + className);
                }
                pluginInstance = (DelegationInterface) Class.forName(className).newInstance();
                pluginInstance.initialize(privilegedToken, null);
                if (debug.messageEnabled()) {
                    debug.message("Successfully created " + "a delegation plugin instance");
                }
            } else {
                throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
            }
        } catch (Exception e) {
            debug.error("Unable to get an instance of plugin " + "for delegation", e);
            pluginInstance = null;
            throw new DelegationException(e);
        }
    }
    return pluginInstance;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) PluginSchema(com.sun.identity.sm.PluginSchema) Iterator(java.util.Iterator) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 25 with ServiceSchema

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

the class FederationPlugin method setAuthModules.

private void setAuthModules(SSOToken adminSSOToken) {
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager("iPlanetAMAuthService", adminSSOToken);
        ServiceSchema ss = mgr.getSchema(SchemaType.GLOBAL);
        Map values = ss.getAttributeDefaults();
        Set modules = (Set) values.get("iplanet-am-auth-authenticators");
        modules.add("com.sun.identity.authentication.modules.federation.Federation");
        modules.add("com.sun.identity.authentication.modules.sae.SAE");
        ss.setAttributeDefaults(values);
    } catch (SSOException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    } catch (SMSException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) 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