use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class ResourceTypeServiceConfig method getOrgConfig.
/**
* Get the organization configuration for the sunEntitlementService service.
* @param subject The subject used to retrieve the SSO token.
* @param realm The realm from which to retrieve it.
* @return The organization configuration, which is guaranteed to not be null.
* @throws SMSException If the sub configuration could not be read.
* @throws SSOException If the Admin token could not be found.
*/
ServiceConfig getOrgConfig(Subject subject, String realm) throws SMSException, SSOException {
final SSOToken token = getSSOToken(subject);
if (token == null) {
throw new SSOException("Could not find Admin token.");
}
ServiceConfig orgConfig = new ServiceConfigManager(SERVICE_NAME, token).getOrganizationConfig(realm, null);
if (orgConfig == null) {
throw new SMSException("Configuration '" + SERVICE_NAME + "' in realm '" + realm + "' could not be retrieved.");
}
return orgConfig;
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class AuditTestUtils method mockAuditContext.
public static Context mockAuditContext() throws Exception {
final Context httpContext = new HttpContext(jsonFromFile("/org/forgerock/openam/rest/fluent/httpContext.json"), AbstractAuditFilterTest.class.getClassLoader());
final Subject callerSubject = new Subject();
final Context securityContext = new SecurityContext(httpContext, null, null);
final Context subjectContext = new SSOTokenContext(mock(Debug.class), null, securityContext) {
@Override
public Subject getCallerSubject() {
return callerSubject;
}
@Override
public SSOToken getCallerSSOToken() {
SSOToken token = mock(SSOToken.class);
try {
given(token.getProperty(Constants.AM_CTX_ID)).willReturn("TRACKING_ID");
given(token.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("USER_ID");
} catch (SSOException e) {
// won't happen - it's a mock
}
return token;
}
};
final Context clientContext = ClientContext.newInternalClientContext(subjectContext);
return new RequestAuditContext(new AuditInfoContext(clientContext, AuditConstants.Component.AUDIT));
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class RestletRealmRouter method doHandle.
/**
* <p>Takes the last realm URI parameter from the request and appends to the growing full realm value.</p>
*
* <p>i.e. last realm URI parameter: realm2, current full realm value: /realm1, after appending: /realm1/realm2.</p>
*
* @param next {@inheritDoc}
* @param request {@inheritDoc}
* @param response {@inheritDoc}
*/
@Override
protected void doHandle(Restlet next, Request request, Response response) {
RealmInfo realmInfo = getRealmFromURI(request);
if (realmInfo == null) {
realmInfo = getRealmFromServerName(request);
}
if (next != delegateRoute) {
String overrideRealm = getRealmFromQueryString(request);
if (overrideRealm != null) {
realmInfo = realmInfo.withOverrideRealm(overrideRealm);
}
request.getAttributes().put(REALM_URL, request.getResourceRef().getBaseRef().toString());
}
// Check that the path references an existing realm
if (!realmValidator.isRealm(realmInfo.getAbsoluteRealm())) {
String realm = realmInfo.getAbsoluteRealm();
try {
SSOToken adminToken = coreWrapper.getAdminToken();
//Need to strip off leading '/' from realm otherwise just generates a DN based of the realm value, which is wrong
if (realmInfo.getAbsoluteRealm().startsWith("/")) {
realm = realm.substring(1);
}
String orgDN = coreWrapper.getOrganization(adminToken, realm);
realmInfo = realmInfo.withAbsoluteRealm(coreWrapper.convertOrgNameToRealmName(orgDN));
} catch (IdRepoException | SSOException e) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid realm, " + realm);
}
}
request.getAttributes().put(REALM, realmInfo.getAbsoluteRealm());
request.getAttributes().put(REALM_INFO, realmInfo);
HttpServletRequest httpRequest = ServletUtils.getRequest(request);
httpRequest.setAttribute(REALM, realmInfo.getAbsoluteRealm());
httpRequest.setAttribute(REALM_INFO, realmInfo);
request.getAttributes().remove("subrealm");
super.doHandle(next, request, response);
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class ScriptConfigurationDataStore method get.
@Override
public Set<ScriptConfiguration> get(QueryFilter<String> queryFilter) throws ScriptException {
final Set<ScriptConfiguration> scriptConfigurations = new LinkedHashSet<>();
try {
ServiceConfig config = getSubOrgConfig();
Set<String> uuids = config.getSubConfigNames();
for (String uuid : uuids) {
if (queryFilter.accept(new ServiceConfigQueryFilterVisitor(), config.getSubConfig(uuid))) {
scriptConfigurations.add(get(uuid));
}
}
config = getSubGlobalConfig();
uuids = config.getSubConfigNames();
for (String uuid : uuids) {
if (queryFilter.accept(new ServiceConfigQueryFilterVisitor(), config.getSubConfig(uuid))) {
scriptConfigurations.add(get(uuid));
}
}
} catch (SMSException | SSOException e) {
throw createAndLogError(logger, RETRIEVE_ALL_FAILED, e, realm);
} catch (UnsupportedOperationException e) {
throw createAndLogError(logger, ScriptErrorCode.valueOf(e.getMessage()), e);
}
return scriptConfigurations;
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class ScriptConfigurationDataStore method getAll.
@Override
public Set<ScriptConfiguration> getAll() throws ScriptException {
final Set<ScriptConfiguration> scriptConfigurations = new LinkedHashSet<>();
try {
ServiceConfig config = getSubOrgConfig();
Set<String> uuids = config.getSubConfigNames();
for (String uuid : uuids) {
scriptConfigurations.add(scriptConfigurationFromMap(uuid, config.getSubConfig(uuid).getAttributesForRead()));
}
config = getSubGlobalConfig();
uuids = config.getSubConfigNames();
for (String uuid : uuids) {
scriptConfigurations.add(scriptConfigurationFromMap(uuid, config.getSubConfig(uuid).getAttributesForRead()));
}
} catch (SSOException | SMSException e) {
throw createAndLogError(logger, RETRIEVE_ALL_FAILED, e, realm);
}
return scriptConfigurations;
}
Aggregations