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);
}
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());
}
}
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);
}
}
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;
}
}
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;
}
}
Aggregations