Search in sources :

Example 66 with SMSException

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

the class BaseURLProviderFactory method create.

private synchronized BaseURLProvider create(String realmDN) {
    if (!providers.containsKey(realmDN)) {
        debug.message("Creating base URL provider for realm: {}", realmDN);
        OpenAMSettingsImpl settings = new OpenAMSettingsImpl(SERVICE_NAME, SERVICE_VERSION);
        try {
            BaseURLProvider provider;
            if (settings.hasConfig(realmDN)) {
                ProviderType providerType = ProviderType.valueOf(settings.getStringSetting(realmDN, PROVIDER_TYPE));
                provider = providerType.getProvider();
                provider.init(settings, realmDN);
                provider.setContextPath(settings.getStringSetting(realmDN, CONTEXT_PATH));
            } else {
                provider = new RequestValuesBaseURLProvider();
                provider.setContextPath(servletContext.getContextPath());
            }
            provider.setCoreWrapper(coreWrapper);
            providers.put(realmDN, provider);
        } catch (SMSException | SSOException e) {
            debug.error("Unable to access BaseURL config for realm {}", realmDN, e);
            throw new IllegalStateException(e);
        }
    }
    return providers.get(realmDN);
}
Also used : SMSException(com.sun.identity.sm.SMSException) OpenAMSettingsImpl(org.forgerock.openam.utils.OpenAMSettingsImpl) SSOException(com.iplanet.sso.SSOException)

Example 67 with SMSException

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

the class OpenAMScopeValidator method getOIDCClaimsExtensionScript.

private ScriptObject getOIDCClaimsExtensionScript(String realm) throws ServerException {
    OpenAMSettingsImpl settings = new OpenAMSettingsImpl(OAuth2Constants.OAuth2ProviderService.NAME, OAuth2Constants.OAuth2ProviderService.VERSION);
    try {
        String scriptId = settings.getStringSetting(realm, OAuth2Constants.OAuth2ProviderService.OIDC_CLAIMS_EXTENSION_SCRIPT);
        if (EMPTY_SCRIPT_SELECTION.equals(scriptId)) {
            return new ScriptObject("oidc-claims-script", "", SupportedScriptingLanguage.JAVASCRIPT);
        }
        ScriptConfiguration config = getScriptConfiguration(realm, scriptId);
        return new ScriptObject(config.getName(), config.getScript(), config.getLanguage());
    } catch (org.forgerock.openam.scripting.ScriptException | SSOException | SMSException e) {
        logger.message("Error running OIDC claims script", e);
        throw new ServerException("Error running OIDC claims script: " + e.getMessage());
    }
}
Also used : ScriptObject(org.forgerock.openam.scripting.ScriptObject) ScriptException(javax.script.ScriptException) ServerException(org.forgerock.oauth2.core.exceptions.ServerException) SMSException(com.sun.identity.sm.SMSException) OpenAMSettingsImpl(org.forgerock.openam.utils.OpenAMSettingsImpl) ScriptConfiguration(org.forgerock.openam.scripting.service.ScriptConfiguration) SSOException(com.iplanet.sso.SSOException)

Example 68 with SMSException

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

the class AMIdentityTestBase method deleteRealm.

private void deleteRealm(SSOToken ssoToken, String realm) throws SSOException {
    if ((realm != null) && !realm.equals("/")) {
        String parentRealm = getParentRealm(realm);
        try {
            OrganizationConfigManager orgMgr = new OrganizationConfigManager(ssoToken, parentRealm);
            int idx = realm.lastIndexOf("/");
            orgMgr.deleteSubOrganization(realm.substring(idx + 1), true);
        } catch (SMSException e) {
        //ignore if the sub organization already exists.
        }
        deleteRealm(ssoToken, parentRealm);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager)

Example 69 with SMSException

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

the class SchemaTest method setAttributeAny.

@Parameters({ "subschema" })
@Test(groups = { "schema", "set-attr-any", "attribute-schema-ops", "subschema" }, dependsOnMethods = { "addAttributeSchema" })
public void setAttributeAny(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("setAttributeAny", params);
    String[] args = (subschema.length() == 0) ? new String[9] : new String[11];
    args[0] = "set-attr-any";
    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_SCHEMA;
    args[6] = "mock-add";
    args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + ModifyAttributeSchemaAny.ARGUMENT_ANY;
    args[8] = "admin";
    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-add");
        assert (as.getAny().equals("admin"));
        exiting("setAttributeAny");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "setAttributeAny", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "setAttributeAny", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "setAttributeAny", 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 70 with SMSException

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

the class SchemaTest method setSubConfiguration.

@Test(groups = { "schema", "set-sub-cfg" }, dependsOnMethods = { "createSubConfiguration" })
public void setSubConfiguration() throws CLIException, SMSException, SSOException {
    entering("setSubConfiguration", null);
    String[] args = { "set-sub-cfg", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + ModifySubConfiguration.ARGUMENT_OPERATION, "set", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUB_CONFIGURATION_NAME, "/testConfig", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, "attr1=2" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        Map map = getSubConfigurationValues("/testConfig");
        Set set = (Set) map.get("attr1");
        String attr1 = (String) set.iterator().next();
        assert attr1.equals("2");
        args[4] = "delete";
        req = new CLIRequest(null, args, getAdminSSOToken());
        cmdManager.addToRequestQueue(req);
        cmdManager.serviceRequestQueue();
        map = getSubConfigurationValues("/testConfig");
        set = (Set) map.get("attr1");
        assert (set == null) || set.isEmpty();
        args[4] = "add";
        args[8] = "attr3=2";
        req = new CLIRequest(null, args, getAdminSSOToken());
        cmdManager.addToRequestQueue(req);
        cmdManager.serviceRequestQueue();
        map = getSubConfigurationValues("/testConfig");
        set = (Set) map.get("attr3");
        attr1 = (String) set.iterator().next();
        assert attr1.equals("2");
        exiting("setSubConfiguration");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "setSubConfiguration", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "setSubConfiguration", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "setSubConfiguration", e.getMessage());
        throw e;
    }
}
Also used : Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Aggregations

SMSException (com.sun.identity.sm.SMSException)704 SSOException (com.iplanet.sso.SSOException)525 Set (java.util.Set)272 HashSet (java.util.HashSet)200 SSOToken (com.iplanet.sso.SSOToken)185 Map (java.util.Map)166 ServiceConfig (com.sun.identity.sm.ServiceConfig)164 HashMap (java.util.HashMap)158 CLIException (com.sun.identity.cli.CLIException)149 ServiceSchema (com.sun.identity.sm.ServiceSchema)138 Iterator (java.util.Iterator)133 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)104 IOutput (com.sun.identity.cli.IOutput)96 IdRepoException (com.sun.identity.idm.IdRepoException)86 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)83 AttributeSchema (com.sun.identity.sm.AttributeSchema)66 IOException (java.io.IOException)55 List (java.util.List)51