Skip to content

Commit 227e256

Browse files
Address comments
1 parent bf0c881 commit 227e256

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/token/AccessTokenIssuer.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@
9999
import org.wso2.carbon.utils.CarbonUtils;
100100
import org.wso2.carbon.utils.DiagnosticLog;
101101

102-
import java.time.Instant;
103-
import java.time.format.DateTimeFormatter;
104102
import java.util.ArrayList;
105103
import java.util.Arrays;
106104
import java.util.Collections;
@@ -1428,17 +1426,21 @@ private static void triggerPostIssueTokenEvent(OAuth2AccessTokenReqDTO tokenReqD
14281426
}
14291427
return;
14301428
}
1429+
if (existingTokenUsed(tokReqMsgCtx)) {
1430+
if (log.isDebugEnabled()) {
1431+
log.debug("Existing token is used. Hence skipping the post issue token event.");
1432+
}
1433+
return;
1434+
}
14311435
String userType = StringUtils.EMPTY;
14321436
String organizationId = StringUtils.EMPTY;
14331437
String tenantDomain = StringUtils.EMPTY;
14341438
String clientId = StringUtils.EMPTY;
14351439
String accessingOrganizationId = StringUtils.EMPTY;
14361440
String tokenId = StringUtils.EMPTY;
14371441
String grantType = StringUtils.EMPTY;
1438-
String issuedTime;
1442+
String issuedTime = String.valueOf(tokReqMsgCtx.getAccessTokenIssuedTime());
14391443

1440-
issuedTime = DateTimeFormatter.ISO_INSTANT.format(
1441-
Instant.ofEpochMilli(tokReqMsgCtx.getAccessTokenIssuedTime()));
14421444
Object userTypeObject = tokReqMsgCtx.getProperty(OAuthConstants.UserType.USER_TYPE);
14431445
if (userTypeObject instanceof String) {
14441446
userType = (String) userTypeObject;
@@ -1463,18 +1465,17 @@ private static void triggerPostIssueTokenEvent(OAuth2AccessTokenReqDTO tokenReqD
14631465
if (tokenReqDTO.getGrantType() != null) {
14641466
grantType = tokenReqDTO.getGrantType();
14651467
}
1466-
if (!existingTokenUsed(tokReqMsgCtx)) {
1467-
Map<String, Object> eventProperties = new HashMap<>();
1468-
eventProperties.put(OIDCConstants.Event.TOKEN_ID, tokenId);
1469-
eventProperties.put(OIDCConstants.Event.TENANT_DOMAIN, tenantDomain);
1470-
eventProperties.put(OIDCConstants.Event.USER_TYPE, userType);
1471-
eventProperties.put(OIDCConstants.Event.CLIENT_ID, clientId);
1472-
eventProperties.put(OIDCConstants.Event.GRANT_TYPE, grantType);
1473-
eventProperties.put(OIDCConstants.Event.ISSUED_TIME, issuedTime);
1474-
eventProperties.put(OIDCConstants.Event.ISSUER_ORGANIZATION_ID, organizationId);
1475-
eventProperties.put(OIDCConstants.Event.ACCESSING_ORGANIZATION_ID, accessingOrganizationId);
1476-
OAuth2TokenUtil.postIssueToken(eventProperties);
1477-
}
1468+
1469+
Map<String, Object> eventProperties = new HashMap<>();
1470+
eventProperties.put(OIDCConstants.Event.TOKEN_ID, tokenId);
1471+
eventProperties.put(OIDCConstants.Event.TENANT_DOMAIN, tenantDomain);
1472+
eventProperties.put(OIDCConstants.Event.USER_TYPE, userType);
1473+
eventProperties.put(OIDCConstants.Event.CLIENT_ID, clientId);
1474+
eventProperties.put(OIDCConstants.Event.GRANT_TYPE, grantType);
1475+
eventProperties.put(OIDCConstants.Event.ISSUED_TIME, issuedTime);
1476+
eventProperties.put(OIDCConstants.Event.ISSUER_ORGANIZATION_ID, organizationId);
1477+
eventProperties.put(OIDCConstants.Event.ACCESSING_ORGANIZATION_ID, accessingOrganizationId);
1478+
OAuth2TokenUtil.postIssueToken(eventProperties);
14781479
}
14791480

14801481
private static Boolean existingTokenUsed(OAuthTokenReqMessageContext tokReqMsgCtx) {

components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/openidconnect/OIDCConstants.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,4 @@ public class Event {
6262
public static final String ISSUER_ORGANIZATION_ID = "ISSUER_ORGANIZATION_ID";
6363
public static final String ACCESSING_ORGANIZATION_ID = "ACCESSING_ORGANIZATION_ID";
6464
}
65-
66-
/**
67-
* This enum is used to define the token types used in OIDC.
68-
*/
69-
public enum TokenBillingCategory {
70-
71-
M2M_ACCESS_TOKEN
72-
}
7365
}
74-

0 commit comments

Comments
 (0)