use of org.wso2.carbon.identity.oauth.event.OAuthEventInterceptor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2Service method invokePostRevocationListeners.
private void invokePostRevocationListeners(OAuthRevocationRequestDTO revokeRequestDTO, OAuthRevocationResponseDTO revokeResponseDTO, AccessTokenDO accessTokenDO, RefreshTokenValidationDataDO refreshTokenDO) {
OAuthEventInterceptor oAuthEventInterceptorProxy = OAuthComponentServiceHolder.getInstance().getOAuthEventInterceptorProxy();
if (oAuthEventInterceptorProxy != null && oAuthEventInterceptorProxy.isEnabled()) {
try {
Map<String, Object> paramMap = new HashMap<>();
oAuthEventInterceptorProxy.onPostTokenRevocationByClient(revokeRequestDTO, revokeResponseDTO, accessTokenDO, refreshTokenDO, paramMap);
} catch (IdentityOAuth2Exception e) {
log.error("Error occurred when invoking post token revoke listener ", e);
}
}
}
use of org.wso2.carbon.identity.oauth.event.OAuthEventInterceptor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuthAdminServiceImpl method triggerPostRevokeListeners.
void triggerPostRevokeListeners(OAuthRevocationRequestDTO revokeRequestDTO, OAuthRevocationResponseDTO revokeRespDTO, AccessTokenDO[] accessTokenDOs) {
OAuthEventInterceptor oAuthEventInterceptorProxy = OAuthComponentServiceHolder.getInstance().getOAuthEventInterceptorProxy();
for (AccessTokenDO accessTokenDO : accessTokenDOs) {
if (oAuthEventInterceptorProxy != null && oAuthEventInterceptorProxy.isEnabled()) {
try {
Map<String, Object> paramMap = new HashMap<String, Object>();
oAuthEventInterceptorProxy.onPostTokenRevocationByResourceOwner(revokeRequestDTO, revokeRespDTO, accessTokenDO, paramMap);
} catch (IdentityOAuth2Exception e) {
LOG.error("Error occurred with post revocation listener.", e);
}
}
}
}
use of org.wso2.carbon.identity.oauth.event.OAuthEventInterceptor in project identity-inbound-auth-oauth by wso2-extensions.
the class AccessTokenIssuer method triggerPostListeners.
private void triggerPostListeners(OAuth2AccessTokenReqDTO tokenReqDTO, OAuth2AccessTokenRespDTO tokenRespDTO, OAuthTokenReqMessageContext tokReqMsgCtx, boolean isRefresh) {
OAuthEventInterceptor oAuthEventInterceptorProxy = OAuthComponentServiceHolder.getInstance().getOAuthEventInterceptorProxy();
if (isRefresh) {
if (oAuthEventInterceptorProxy != null && oAuthEventInterceptorProxy.isEnabled()) {
try {
if (log.isDebugEnabled()) {
log.debug("Triggering refresh token post renewal listeners for client: " + tokenReqDTO.getClientId());
}
Map<String, Object> paramMap = new HashMap<>();
oAuthEventInterceptorProxy.onPostTokenRenewal(tokenReqDTO, tokenRespDTO, tokReqMsgCtx, paramMap);
} catch (IdentityOAuth2Exception e) {
log.error("Oauth post renewal listener failed", e);
}
}
} else {
if (oAuthEventInterceptorProxy != null && oAuthEventInterceptorProxy.isEnabled()) {
try {
if (log.isDebugEnabled()) {
log.debug("Triggering access token post issuer listeners for client: " + tokenReqDTO.getClientId());
}
Map<String, Object> paramMap = new HashMap<>();
oAuthEventInterceptorProxy.onPostTokenIssue(tokenReqDTO, tokenRespDTO, tokReqMsgCtx, paramMap);
} catch (IdentityOAuth2Exception e) {
log.error("Oauth post issuer listener failed.", e);
}
}
}
}
use of org.wso2.carbon.identity.oauth.event.OAuthEventInterceptor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2Util method triggerOnIntrospectionExceptionListeners.
/**
* Extract information related to the token introspection and publish the event on introspection error.
*
* @param
*/
public static void triggerOnIntrospectionExceptionListeners(OAuth2TokenValidationRequestDTO introspectionRequest, OAuth2IntrospectionResponseDTO introspectionResponse) {
Map<String, Object> params = new HashMap<>();
params.put("error", introspectionResponse.getError());
try {
OAuthEventInterceptor oAuthEventInterceptorProxy = OAuthComponentServiceHolder.getInstance().getOAuthEventInterceptorProxy();
if (oAuthEventInterceptorProxy != null) {
try {
oAuthEventInterceptorProxy.onTokenValidationException(introspectionRequest, params);
} catch (IdentityOAuth2Exception e) {
log.error("Error while invoking OAuthEventInterceptor for onTokenValidationException", e);
}
}
} catch (Throwable e) {
// Catching a throwable as we do no need to interrupt the code flow since these are logging purposes.
if (log.isDebugEnabled()) {
log.debug("Error occurred while executing oAuthEventInterceptorProxy for onTokenValidationException.", e);
}
}
}
use of org.wso2.carbon.identity.oauth.event.OAuthEventInterceptor in project identity-inbound-auth-oauth by wso2-extensions.
the class TokenResponseTypeHandlerTest method setUp.
@BeforeTest
public void setUp() throws Exception {
OAuthEventInterceptor interceptor = Mockito.mock(OAuthEventInterceptor.class);
OAuthComponentServiceHolder.getInstance().addOauthEventInterceptorProxy(interceptor);
}
Aggregations