diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java index 75a07a3a4fd..90ec9f21397 100644 --- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java +++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java @@ -3023,12 +3023,12 @@ private String handlePreConsent(OAuth2Parameters oauth2Params, AuthenticatedUser ServiceProvider serviceProvider = getServiceProvider(clientId); Map params = new HashMap<>(); - params.put("clientId", clientId); + params.put(LogConstants.InputKeys.CLIENT_ID, clientId); try { - params.put("user", user.getUserId()); + params.put(LogConstants.InputKeys.USER_ID, user.getUserId()); } catch (UserIdNotFoundException e) { if (StringUtils.isNotBlank(user.getAuthenticatedSubjectIdentifier())) { - params.put("user", LoggerUtils.isLogMaskingEnable ? LoggerUtils.getMaskedContent( + params.put(LogConstants.InputKeys.USER, LoggerUtils.isLogMaskingEnable ? LoggerUtils.getMaskedContent( user.getAuthenticatedSubjectIdentifier()) : user.getAuthenticatedSubjectIdentifier()); } } @@ -3044,11 +3044,16 @@ private String handlePreConsent(OAuth2Parameters oauth2Params, AuthenticatedUser + spTenantDomain + " for user: " + user.toFullQualifiedUsername()); } if (LoggerUtils.isDiagnosticLogsEnabled()) { - params.put("skipConsent", "true"); - LoggerUtils.triggerDiagnosticLogEvent(OAuthConstants.LogConstants.OAUTH_INBOUND_SERVICE, params, - OAuthConstants.LogConstants.SUCCESS, - "'skipConsent' is enabled for the OAuth client. Hence consent claims not generated.", - "generate-consent-claims", null); + params.put("skip consent", "true"); + DiagnosticLog.DiagnosticLogBuilder diagnosticLogBuilder = new DiagnosticLog.DiagnosticLogBuilder( + OAuthConstants.LogConstants.OAUTH_INBOUND_SERVICE, + EndpointConstants.LogConstants.ActionIDs.GENERATE_CONSENT_CLAIMS); + diagnosticLogBuilder.inputParams(params) + .resultStatus(DiagnosticLog.ResultStatus.SUCCESS) + .logDetailLevel(DiagnosticLog.LogDetailLevel.APPLICATION) + .resultMessage("'skipConsent' is enabled for the OAuth client. Hence consent claims not " + + "generated."); + LoggerUtils.triggerDiagnosticLogEvent(diagnosticLogBuilder); } return StringUtils.EMPTY; } diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointConstants.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointConstants.java index 0676b0b377a..93e5910818f 100644 --- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointConstants.java +++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointConstants.java @@ -47,6 +47,7 @@ public static class ActionIDs { public static final String VALIDATE_SCOPES_BEFORE_CONSENT = "validate-scopes-before-consent"; public static final String HAND_OVER_TO_FRAMEWORK = "hand-over-to-framework"; public static final String PERSIST_OAUTH_SCOPE_CONSENT = "persist-oauth-scope-consent"; + public static final String GENERATE_CONSENT_CLAIMS = "generate-consent-claims"; } /** diff --git a/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/OAuth2Constants.java b/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/OAuth2Constants.java index 99233db5c24..f10882d4ee5 100644 --- a/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/OAuth2Constants.java +++ b/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/OAuth2Constants.java @@ -89,7 +89,6 @@ public static class ActionIDs { public static final String ISSUE_ID_TOKEN = "issue-id-token"; public static final String VALIDATE_AUTHORIZATION_CODE = "validate-authz-code"; public static final String ISSUE_AUTHZ_CODE = "issue-authz-code"; - } /** @@ -102,7 +101,6 @@ public static class InputKeys { public static final String AUTHORIZED_SCOPES = "authorized scopes"; public static final String GRANT_TYPE = "grant type"; public static final String AUTHORIZATION_CODE = "authorization code"; - } } } diff --git a/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/token/handlers/grant/AuthorizationCodeGrantHandler.java b/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/token/handlers/grant/AuthorizationCodeGrantHandler.java index aa3ccb4b6fa..78e1eca4f64 100644 --- a/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/token/handlers/grant/AuthorizationCodeGrantHandler.java +++ b/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/token/handlers/grant/AuthorizationCodeGrantHandler.java @@ -393,7 +393,7 @@ private boolean validateAuthzCodeFromRequest(AuthzCodeDO authzCodeBean, String c if (LoggerUtils.isDiagnosticLogsEnabled()) { diagnosticLogBuilder.resultMessage("Invalid authorization code received. Couldn't find persisted data" + " for authorization code.") - .inputParam("authorization code", authzCode) + .inputParam(OAuth2Constants.LogConstants.InputKeys.AUTHORIZATION_CODE, authzCode) .resultStatus(DiagnosticLog.ResultStatus.FAILED) .logDetailLevel(DiagnosticLog.LogDetailLevel.APPLICATION); LoggerUtils.triggerDiagnosticLogEvent(diagnosticLogBuilder); @@ -405,7 +405,7 @@ private boolean validateAuthzCodeFromRequest(AuthzCodeDO authzCodeBean, String c clearTokenCache(authzCodeBean, clientId); if (LoggerUtils.isDiagnosticLogsEnabled()) { diagnosticLogBuilder.resultMessage("Inactive authorization code received.") - .inputParam("authorization code", authzCode) + .inputParam(OAuth2Constants.LogConstants.InputKeys.AUTHORIZATION_CODE, authzCode) .resultStatus(DiagnosticLog.ResultStatus.FAILED); LoggerUtils.triggerDiagnosticLogEvent(diagnosticLogBuilder); }