Search in sources :

Example 1 with AuthorizationGrantCacheKey

use of org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey in project identity-inbound-auth-oauth by wso2-extensions.

the class IdentityOathEventListener method removeAuthzCodesFromCache.

private void removeAuthzCodesFromCache(List<AuthzCodeDO> authorizationCodeDOSet) {
    if (CollectionUtils.isNotEmpty(authorizationCodeDOSet)) {
        for (AuthzCodeDO authorizationCodeDO : authorizationCodeDOSet) {
            String authorizationCode = authorizationCodeDO.getAuthorizationCode();
            String authzCodeId = authorizationCodeDO.getAuthzCodeId();
            AuthorizationGrantCacheKey cacheKey = new AuthorizationGrantCacheKey(authorizationCode);
            AuthorizationGrantCache.getInstance().clearCacheEntryByCodeId(cacheKey, authzCodeId);
        }
    }
}
Also used : AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey) AuthzCodeDO(org.wso2.carbon.identity.oauth2.model.AuthzCodeDO)

Example 2 with AuthorizationGrantCacheKey

use of org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey in project identity-inbound-auth-oauth by wso2-extensions.

the class IdentityOathEventListener method removeAccessTokensFromCache.

private void removeAccessTokensFromCache(Set<AccessTokenDO> accessTokenDOSet) {
    if (CollectionUtils.isNotEmpty(accessTokenDOSet)) {
        for (AccessTokenDO accessTokenDO : accessTokenDOSet) {
            String accessToken = accessTokenDO.getAccessToken();
            String tokenId = accessTokenDO.getTokenId();
            AuthorizationGrantCacheKey cacheKey = new AuthorizationGrantCacheKey(accessToken);
            AuthorizationGrantCache.getInstance().clearCacheEntryByTokenId(cacheKey, tokenId);
        }
    }
}
Also used : AccessTokenDO(org.wso2.carbon.identity.oauth2.model.AccessTokenDO) AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey)

Example 3 with AuthorizationGrantCacheKey

use of org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuthApplicationMgtListener method clearCacheEntriesAgainstToken.

private void clearCacheEntriesAgainstToken(Set<AccessTokenDO> accessTokenDOSet) {
    for (AccessTokenDO accessTokenDo : accessTokenDOSet) {
        // Remove access token from AuthorizationGrantCache
        AuthorizationGrantCacheKey grantCacheKey = new AuthorizationGrantCacheKey(accessTokenDo.getAccessToken());
        AuthorizationGrantCache.getInstance().clearCacheEntryByTokenId(grantCacheKey, accessTokenDo.getTokenId());
        // Remove access token from OAuthCache
        OAuthCacheKey oauthCacheKey = new OAuthCacheKey(accessTokenDo.getAccessToken());
        CacheEntry oauthCacheEntry = OAuthCache.getInstance().getValueFromCache(oauthCacheKey);
        if (oauthCacheEntry != null) {
            OAuthCache.getInstance().clearCacheEntry(oauthCacheKey);
        }
    }
}
Also used : AccessTokenDO(org.wso2.carbon.identity.oauth2.model.AccessTokenDO) OAuthCacheKey(org.wso2.carbon.identity.oauth.cache.OAuthCacheKey) AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey) CacheEntry(org.wso2.carbon.identity.oauth.cache.CacheEntry)

Example 4 with AuthorizationGrantCacheKey

use of org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuthApplicationMgtListener method clearCacheEntriesAgainstAuthzCode.

private void clearCacheEntriesAgainstAuthzCode(Set<AuthzCodeDO> authzCodeDOSet) {
    for (AuthzCodeDO authzCodeDO : authzCodeDOSet) {
        // Remove authorization code from AuthorizationGrantCache
        AuthorizationGrantCacheKey grantCacheKey = new AuthorizationGrantCacheKey(authzCodeDO.getAuthorizationCode());
        AuthorizationGrantCache.getInstance().clearCacheEntryByCodeId(grantCacheKey, authzCodeDO.getAuthzCodeId());
        // Remove authorization code from OAuthCache
        OAuthCacheKey oauthCacheKey = new OAuthCacheKey(authzCodeDO.getAuthorizationCode());
        CacheEntry oauthCacheEntry = OAuthCache.getInstance().getValueFromCache(oauthCacheKey);
        if (oauthCacheEntry != null) {
            OAuthCache.getInstance().clearCacheEntry(oauthCacheKey);
        }
    }
}
Also used : OAuthCacheKey(org.wso2.carbon.identity.oauth.cache.OAuthCacheKey) AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey) AuthzCodeDO(org.wso2.carbon.identity.oauth2.model.AuthzCodeDO) CacheEntry(org.wso2.carbon.identity.oauth.cache.CacheEntry)

Example 5 with AuthorizationGrantCacheKey

use of org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey in project identity-inbound-auth-oauth by wso2-extensions.

the class AbstractTokenBinder method getTokenBindingValue.

@Override
public Optional<String> getTokenBindingValue(OAuth2AccessTokenReqDTO oAuth2AccessTokenReqDTO) {
    if (AUTHORIZATION_CODE.equals(oAuth2AccessTokenReqDTO.getGrantType()) && StringUtils.isNotBlank(oAuth2AccessTokenReqDTO.getAuthorizationCode())) {
        AuthorizationGrantCacheKey cacheKey = new AuthorizationGrantCacheKey(oAuth2AccessTokenReqDTO.getAuthorizationCode());
        AuthorizationGrantCacheEntry authorizationGrantCacheEntry = AuthorizationGrantCache.getInstance().getValueFromCacheByCode(cacheKey);
        if (authorizationGrantCacheEntry != null && StringUtils.isNotBlank(authorizationGrantCacheEntry.getTokenBindingValue())) {
            return Optional.of(authorizationGrantCacheEntry.getTokenBindingValue());
        }
    }
    return Optional.empty();
}
Also used : AuthorizationGrantCacheEntry(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheEntry) AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey)

Aggregations

AuthorizationGrantCacheKey (org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey)21 AuthorizationGrantCacheEntry (org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheEntry)17 AccessTokenDO (org.wso2.carbon.identity.oauth2.model.AccessTokenDO)4 HashMap (java.util.HashMap)3 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)3 ArrayList (java.util.ArrayList)2 Claim (org.wso2.carbon.identity.application.common.model.Claim)2 CacheEntry (org.wso2.carbon.identity.oauth.cache.CacheEntry)2 OAuthCacheKey (org.wso2.carbon.identity.oauth.cache.OAuthCacheKey)2 OAuth2AuthorizeReqDTO (org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeReqDTO)2 AuthzCodeDO (org.wso2.carbon.identity.oauth2.model.AuthzCodeDO)2 Key (java.security.Key)1 Certificate (java.security.cert.Certificate)1 RSAPrivateKey (java.security.interfaces.RSAPrivateKey)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 JSONObject (org.json.JSONObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1 XMLObject (org.opensaml.core.xml.XMLObject)1