Search in sources :

Example 66 with SSOException

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;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 67 with SSOException

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));
}
Also used : SecurityContext(org.forgerock.services.context.SecurityContext) HttpContext(org.forgerock.json.resource.http.HttpContext) AuditInfoContext(org.forgerock.openam.rest.resource.AuditInfoContext) Context(org.forgerock.services.context.Context) ClientContext(org.forgerock.services.context.ClientContext) RequestAuditContext(org.forgerock.services.context.RequestAuditContext) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) RequestAuditContext(org.forgerock.services.context.RequestAuditContext) SSOToken(com.iplanet.sso.SSOToken) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) HttpContext(org.forgerock.json.resource.http.HttpContext) SecurityContext(org.forgerock.services.context.SecurityContext) SSOException(com.iplanet.sso.SSOException) AuditInfoContext(org.forgerock.openam.rest.resource.AuditInfoContext) Subject(javax.security.auth.Subject) Debug(com.sun.identity.shared.debug.Debug)

Example 68 with SSOException

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RealmInfo(org.forgerock.openam.core.RealmInfo) SSOToken(com.iplanet.sso.SSOToken) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) ResourceException(org.restlet.resource.ResourceException)

Example 69 with SSOException

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ServiceConfigQueryFilterVisitor(org.forgerock.openam.sm.ServiceConfigQueryFilterVisitor) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ScriptConfiguration(org.forgerock.openam.scripting.service.ScriptConfiguration) SSOException(com.iplanet.sso.SSOException)

Example 70 with SSOException

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ScriptConfiguration(org.forgerock.openam.scripting.service.ScriptConfiguration) SSOException(com.iplanet.sso.SSOException)

Aggregations

SSOException (com.iplanet.sso.SSOException)1002 SMSException (com.sun.identity.sm.SMSException)553 Set (java.util.Set)374 SSOToken (com.iplanet.sso.SSOToken)336 IdRepoException (com.sun.identity.idm.IdRepoException)291 HashSet (java.util.HashSet)289 Map (java.util.Map)223 HashMap (java.util.HashMap)205 AMIdentity (com.sun.identity.idm.AMIdentity)193 Iterator (java.util.Iterator)189 CLIException (com.sun.identity.cli.CLIException)170 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)126 ServiceConfig (com.sun.identity.sm.ServiceConfig)126 IOutput (com.sun.identity.cli.IOutput)121 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)104 ServiceSchema (com.sun.identity.sm.ServiceSchema)101 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)93 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)88 IOException (java.io.IOException)65 PolicyException (com.sun.identity.policy.PolicyException)62