Search in sources :

Example 1 with ExpiredJWTCleaner

use of org.wso2.carbon.apimgt.impl.keymgt.ExpiredJWTCleaner in project carbon-apimgt by wso2.

the class AbstractKeyManagerEventHandler method handleTokenRevocationEvent.

public boolean handleTokenRevocationEvent(TokenRevocationEvent tokenRevocationEvent) throws APIManagementException {
    Properties properties = new Properties();
    properties.setProperty(APIConstants.NotificationEvent.EVENT_ID, tokenRevocationEvent.getEventId());
    properties.put(APIConstants.NotificationEvent.CONSUMER_KEY, tokenRevocationEvent.getConsumerKey());
    if (StringUtils.isBlank(tokenRevocationEvent.getTokenType())) {
        tokenRevocationEvent.setTokenType(APIConstants.NotificationEvent.APPLICATION_TOKEN_TYPE_OAUTH2);
    }
    properties.put(APIConstants.NotificationEvent.TOKEN_TYPE, tokenRevocationEvent.getTokenType());
    properties.put(APIConstants.NotificationEvent.TENANT_ID, tokenRevocationEvent.getTenantId());
    properties.put(APIConstants.NotificationEvent.TENANT_DOMAIN, tokenRevocationEvent.getTenantDomain());
    ApiMgtDAO.getInstance().addRevokedJWTSignature(tokenRevocationEvent.getEventId(), tokenRevocationEvent.getAccessToken(), tokenRevocationEvent.getTokenType(), tokenRevocationEvent.getExpiryTime(), tokenRevocationEvent.getTenantId());
    revocationRequestPublisher.publishRevocationEvents(tokenRevocationEvent.getAccessToken(), tokenRevocationEvent.getExpiryTime(), properties);
    // Cleanup expired revoked tokens from db.
    Runnable expiredJWTCleaner = new ExpiredJWTCleaner();
    Thread cleanupThread = new Thread(expiredJWTCleaner);
    cleanupThread.start();
    return true;
}
Also used : ExpiredJWTCleaner(org.wso2.carbon.apimgt.impl.keymgt.ExpiredJWTCleaner) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)1 ExpiredJWTCleaner (org.wso2.carbon.apimgt.impl.keymgt.ExpiredJWTCleaner)1