From 824f57b5d2491818edeea9960bb4941e5c0f86bc Mon Sep 17 00:00:00 2001 From: Kamidu Sachith Date: Mon, 12 Oct 2015 18:36:59 +0530 Subject: [PATCH] Change the code for better performance --- .../validator/impl/ExternalOAuthValidator.java | 14 +++++++------- .../validator/impl/LocalOAuthValidator.java | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java b/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java index f05bd7dea0..e68088fe63 100755 --- a/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java +++ b/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java @@ -25,9 +25,9 @@ import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticatorCo import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuth2TokenValidator; import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidationResponse; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; -import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2ClientApplicationDTO; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.rmi.RemoteException; @@ -69,16 +69,16 @@ public class ExternalOAuthValidator implements OAuth2TokenValidator{ headerList.add(header); options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, headerList); client.setOptions(options); - OAuth2ClientApplicationDTO clientApplicationDTO = - tokenValidationService.findOAuthConsumerIfTokenIsValid(validationRequest); - boolean isValid = clientApplicationDTO.getAccessTokenValidationResponse().getValid(); + OAuth2TokenValidationResponseDTO tokenValidationResponse = + tokenValidationService.findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse(); + boolean isValid = tokenValidationResponse.getValid(); String userName = null; String tenantDomain = null; if(isValid){ userName = MultitenantUtils.getTenantAwareUsername( - clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); - tenantDomain = - MultitenantUtils.getTenantDomain(clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); + tokenValidationResponse.getAuthorizedUser()); + tenantDomain = MultitenantUtils. + getTenantDomain(tokenValidationResponse.getAuthorizedUser()); } return new OAuthValidationResponse(userName,tenantDomain,isValid); } diff --git a/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java b/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java index 5595b19d43..2deb2b3b36 100755 --- a/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java +++ b/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java @@ -17,13 +17,13 @@ */ package org.wso2.carbon.identity.authenticator.backend.oauth.validator.impl; +import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticatorConstants; +import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuth2TokenValidator; import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidationResponse; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; -import org.wso2.carbon.identity.oauth2.dto.OAuth2ClientApplicationDTO; import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticatorConstants; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuth2TokenValidator; /** * Handles the authentication using the inbuilt IS features. @@ -44,16 +44,16 @@ public class LocalOAuthValidator implements OAuth2TokenValidator { accessToken.setIdentifier(token); validationRequest.setAccessToken(accessToken); OAuth2TokenValidationService validationService = new OAuth2TokenValidationService(); - OAuth2ClientApplicationDTO clientApplicationDTO = validationService. - findOAuthConsumerIfTokenIsValid(validationRequest); - boolean isValid = clientApplicationDTO.getAccessTokenValidationResponse().isValid(); + OAuth2TokenValidationResponseDTO tokenValidationResponse = validationService. + findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse(); + boolean isValid = tokenValidationResponse.isValid(); String userName = null; String tenantDomain = null; if(isValid){ userName = MultitenantUtils.getTenantAwareUsername( - clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); + tokenValidationResponse.getAuthorizedUser()); tenantDomain = - MultitenantUtils.getTenantDomain(clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); + MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser()); } return new OAuthValidationResponse(userName,tenantDomain,isValid); }