Search in sources :

Example 1 with RequestObjectHandler

use of org.wso2.carbon.identity.openidconnect.handlers.RequestObjectHandler in project identity-inbound-auth-oauth by wso2-extensions.

the class RequestObjectHandler method handleEvent.

/**
 * Handles the event and invoke RequestObjectPersistenceFactory.
 *
 * @param event event
 * @throws IdentityEventException
 */
@Override
public void handleEvent(Event event) throws IdentityEventException {
    Map<String, Object> eventProperties = event.getEventProperties();
    String eventName = event.getEventName();
    boolean isRequestObjectEnabled = OAuthServerConfiguration.getInstance().isRequestObjectEnabled();
    if (!isRequestObjectEnabled) {
        log.debug("Request Object Flow is disabled, hence dropping the event");
        return;
    }
    try {
        Object isRequestObject = eventProperties.get(OIDCConstants.Event.IS_REQUEST_OBJECT_FLOW);
        if (isRequestObject != null && !(boolean) isRequestObject) {
            if (log.isDebugEnabled()) {
                log.debug("The request does not contains request object. So skipping RequestObjectHandler");
            }
            return;
        }
        String tokenState = (String) eventProperties.get(OIDCConstants.Event.TOKEN_STATE);
        String sessionDataKey = (String) eventProperties.get(OIDCConstants.Event.SESSION_DATA_KEY);
        if (OIDCConstants.Event.POST_REVOKE_ACESS_TOKEN.equals(eventName)) {
            handlePostRevokeToken(eventProperties, tokenState);
        } else if (OIDCConstants.Event.POST_REVOKE_CODE.equals(eventName)) {
            handlePostRevokeCode(eventProperties, tokenState);
        } else if (OIDCConstants.Event.POST_REVOKE_CODE_BY_ID.equals(eventName)) {
            revokeCodeById(eventProperties, tokenState);
        } else if (OIDCConstants.Event.POST_REVOKE_ACESS_TOKEN_BY_ID.equals(eventName)) {
            postRevokeTokenById(eventProperties, tokenState);
        } else if (OIDCConstants.Event.POST_REFRESH_TOKEN.equals(eventName)) {
            postRefreshToken(eventProperties);
        } else if (OIDCConstants.Event.POST_ISSUE_CODE.equals(eventName)) {
            postIssueCode(eventProperties, sessionDataKey);
        } else if (OIDCConstants.Event.POST_ISSUE_ACCESS_TOKEN.equals(eventName)) {
            postIssueTOken(eventProperties, sessionDataKey);
        }
    } catch (IdentityOAuth2Exception | IdentityOAuthAdminException e) {
        String errorMsg = "Error while handling event: " + eventName;
        log.info(errorMsg);
        throw new IdentityEventException(errorMsg, e.getMessage());
    }
}
Also used : IdentityOAuthAdminException(org.wso2.carbon.identity.oauth.IdentityOAuthAdminException) IdentityOAuth2Exception(org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception) IdentityEventException(org.wso2.carbon.identity.event.IdentityEventException)

Example 2 with RequestObjectHandler

use of org.wso2.carbon.identity.openidconnect.handlers.RequestObjectHandler in project identity-inbound-auth-oauth by wso2-extensions.

the class OpenIDConnectServiceComponent method activate.

protected void activate(ComponentContext context) {
    try {
        bundleContext = context.getBundleContext();
        bundleContext.registerService(ClaimProvider.class.getName(), new OpenIDConnectSystemClaimImpl(), null);
        bundleContext.registerService(AbstractEventHandler.class.getName(), new RequestObjectHandler(), null);
        bundleContext.registerService(RequestObjectService.class.getName(), new RequestObjectService(), null);
        bundleContext.registerService(AbstractEventHandler.class.getName(), new OIDCClaimMetaDataOperationHandler(), null);
    } catch (Throwable e) {
        String errMsg = "Error while activating OpenIDConnectServiceComponent.";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }
}
Also used : OIDCClaimMetaDataOperationHandler(org.wso2.carbon.identity.openidconnect.OIDCClaimMetaDataOperationHandler) AbstractEventHandler(org.wso2.carbon.identity.event.handler.AbstractEventHandler) ClaimProvider(org.wso2.carbon.identity.openidconnect.ClaimProvider) RequestObjectService(org.wso2.carbon.identity.openidconnect.RequestObjectService) OpenIDConnectSystemClaimImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectSystemClaimImpl) RequestObjectHandler(org.wso2.carbon.identity.openidconnect.handlers.RequestObjectHandler)

Aggregations

IdentityEventException (org.wso2.carbon.identity.event.IdentityEventException)1 AbstractEventHandler (org.wso2.carbon.identity.event.handler.AbstractEventHandler)1 IdentityOAuthAdminException (org.wso2.carbon.identity.oauth.IdentityOAuthAdminException)1 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)1 ClaimProvider (org.wso2.carbon.identity.openidconnect.ClaimProvider)1 OIDCClaimMetaDataOperationHandler (org.wso2.carbon.identity.openidconnect.OIDCClaimMetaDataOperationHandler)1 OpenIDConnectSystemClaimImpl (org.wso2.carbon.identity.openidconnect.OpenIDConnectSystemClaimImpl)1 RequestObjectService (org.wso2.carbon.identity.openidconnect.RequestObjectService)1 RequestObjectHandler (org.wso2.carbon.identity.openidconnect.handlers.RequestObjectHandler)1