Search in sources :

Example 1 with GeneralAccessDeniedError

use of com.sun.identity.idsvcs.opensso.GeneralAccessDeniedError in project OpenAM by OpenRock.

the class IdentityResourceV2 method attemptResourceCreation.

private Promise<IdentityDetails, ResourceException> attemptResourceCreation(String realm, SSOToken admin, IdentityDetails identity, String resourceId) {
    IdentityDetails dtls = null;
    try {
        // Create the resource
        identityServices.create(identity, admin);
        // Read created resource
        dtls = identityServices.read(resourceId, getIdentityServicesAttributes(realm, objectType), admin);
        if (debug.messageEnabled()) {
            debug.message("IdentityResource.createInstance() :: Created resourceId={} in realm={} by AdminID={}", resourceId, realm, admin.getTokenID());
        }
    } catch (final ObjectNotFound notFound) {
        debug.error("IdentityResource.createInstance() :: Cannot READ resourceId={} : Resource cannot be found.", resourceId, notFound);
        return new NotFoundException("Resource not found.", notFound).asPromise();
    } catch (final TokenExpired tokenExpired) {
        debug.error("IdentityResource.createInstance() :: Cannot CREATE resourceId={} : Unauthorized", resourceId, tokenExpired);
        return new PermanentException(401, "Unauthorized", null).asPromise();
    } catch (final NeedMoreCredentials needMoreCredentials) {
        debug.error("IdentityResource.createInstance() :: Cannot CREATE resourceId={} : Token is not authorized", resourceId, needMoreCredentials);
        return new ForbiddenException("Token is not authorized", needMoreCredentials).asPromise();
    } catch (final GeneralAccessDeniedError accessDenied) {
        debug.error("IdentityResource.createInstance() :: Cannot CREATE " + accessDenied);
        return new ForbiddenException().asPromise();
    } catch (GeneralFailure generalFailure) {
        debug.error("IdentityResource.createInstance() :: Cannot CREATE " + generalFailure);
        return new BadRequestException("Resource cannot be created: " + generalFailure.getMessage(), generalFailure).asPromise();
    } catch (AccessDenied accessDenied) {
        debug.error("IdentityResource.createInstance() :: Cannot CREATE " + accessDenied);
        return new ForbiddenException("Token is not authorized: " + accessDenied.getMessage(), accessDenied).asPromise();
    } catch (ResourceException re) {
        debug.warning("IdentityResource.createInstance() :: Cannot CREATE resourceId={}", resourceId, re);
        return re.asPromise();
    } catch (final Exception e) {
        debug.error("IdentityResource.createInstance() :: Cannot CREATE resourceId={}", resourceId, e);
        return new NotFoundException(e.getMessage(), e).asPromise();
    }
    return newResultPromise(dtls);
}
Also used : GeneralAccessDeniedError(com.sun.identity.idsvcs.opensso.GeneralAccessDeniedError) ForbiddenException(org.forgerock.json.resource.ForbiddenException) NeedMoreCredentials(com.sun.identity.idsvcs.NeedMoreCredentials) NotFoundException(org.forgerock.json.resource.NotFoundException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) AccessDenied(com.sun.identity.idsvcs.AccessDenied) MessagingException(javax.mail.MessagingException) ConflictException(org.forgerock.json.resource.ConflictException) PermanentException(org.forgerock.json.resource.PermanentException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) ForbiddenException(org.forgerock.json.resource.ForbiddenException) DeleteFailedException(org.forgerock.openam.cts.exceptions.DeleteFailedException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NotFoundException(org.forgerock.json.resource.NotFoundException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) NotSupportedException(org.forgerock.json.resource.NotSupportedException) BadRequestException(org.forgerock.json.resource.BadRequestException) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) ResourceException(org.forgerock.json.resource.ResourceException) CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) ObjectNotFound(com.sun.identity.idsvcs.ObjectNotFound) PermanentException(org.forgerock.json.resource.PermanentException) GeneralFailure(com.sun.identity.idsvcs.GeneralFailure) IdentityDetails(com.sun.identity.idsvcs.IdentityDetails) BadRequestException(org.forgerock.json.resource.BadRequestException) TokenExpired(com.sun.identity.idsvcs.TokenExpired) ResourceException(org.forgerock.json.resource.ResourceException)

Aggregations

SSOException (com.iplanet.sso.SSOException)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 AccessDenied (com.sun.identity.idsvcs.AccessDenied)1 GeneralFailure (com.sun.identity.idsvcs.GeneralFailure)1 IdentityDetails (com.sun.identity.idsvcs.IdentityDetails)1 NeedMoreCredentials (com.sun.identity.idsvcs.NeedMoreCredentials)1 ObjectNotFound (com.sun.identity.idsvcs.ObjectNotFound)1 TokenExpired (com.sun.identity.idsvcs.TokenExpired)1 GeneralAccessDeniedError (com.sun.identity.idsvcs.opensso.GeneralAccessDeniedError)1 SMSException (com.sun.identity.sm.SMSException)1 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MessagingException (javax.mail.MessagingException)1 BadRequestException (org.forgerock.json.resource.BadRequestException)1 ConflictException (org.forgerock.json.resource.ConflictException)1 ForbiddenException (org.forgerock.json.resource.ForbiddenException)1 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)1 NotFoundException (org.forgerock.json.resource.NotFoundException)1 NotSupportedException (org.forgerock.json.resource.NotSupportedException)1 PermanentException (org.forgerock.json.resource.PermanentException)1