Change the code for better performance

revert-70aa11f8
Kamidu Sachith 9 years ago
parent fe355b3184
commit 824f57b5d2

@ -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.OAuth2TokenValidator;
import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidationResponse; 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.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;
import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; 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 org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.rmi.RemoteException; import java.rmi.RemoteException;
@ -69,16 +69,16 @@ public class ExternalOAuthValidator implements OAuth2TokenValidator{
headerList.add(header); headerList.add(header);
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, headerList); options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, headerList);
client.setOptions(options); client.setOptions(options);
OAuth2ClientApplicationDTO clientApplicationDTO = OAuth2TokenValidationResponseDTO tokenValidationResponse =
tokenValidationService.findOAuthConsumerIfTokenIsValid(validationRequest); tokenValidationService.findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
boolean isValid = clientApplicationDTO.getAccessTokenValidationResponse().getValid(); boolean isValid = tokenValidationResponse.getValid();
String userName = null; String userName = null;
String tenantDomain = null; String tenantDomain = null;
if(isValid){ if(isValid){
userName = MultitenantUtils.getTenantAwareUsername( userName = MultitenantUtils.getTenantAwareUsername(
clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); tokenValidationResponse.getAuthorizedUser());
tenantDomain = tenantDomain = MultitenantUtils.
MultitenantUtils.getTenantDomain(clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); getTenantDomain(tokenValidationResponse.getAuthorizedUser());
} }
return new OAuthValidationResponse(userName,tenantDomain,isValid); return new OAuthValidationResponse(userName,tenantDomain,isValid);
} }

@ -17,13 +17,13 @@
*/ */
package org.wso2.carbon.identity.authenticator.backend.oauth.validator.impl; 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.authenticator.backend.oauth.validator.OAuthValidationResponse;
import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; 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.OAuth2TokenValidationRequestDTO;
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; 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. * Handles the authentication using the inbuilt IS features.
@ -44,16 +44,16 @@ public class LocalOAuthValidator implements OAuth2TokenValidator {
accessToken.setIdentifier(token); accessToken.setIdentifier(token);
validationRequest.setAccessToken(accessToken); validationRequest.setAccessToken(accessToken);
OAuth2TokenValidationService validationService = new OAuth2TokenValidationService(); OAuth2TokenValidationService validationService = new OAuth2TokenValidationService();
OAuth2ClientApplicationDTO clientApplicationDTO = validationService. OAuth2TokenValidationResponseDTO tokenValidationResponse = validationService.
findOAuthConsumerIfTokenIsValid(validationRequest); findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
boolean isValid = clientApplicationDTO.getAccessTokenValidationResponse().isValid(); boolean isValid = tokenValidationResponse.isValid();
String userName = null; String userName = null;
String tenantDomain = null; String tenantDomain = null;
if(isValid){ if(isValid){
userName = MultitenantUtils.getTenantAwareUsername( userName = MultitenantUtils.getTenantAwareUsername(
clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); tokenValidationResponse.getAuthorizedUser());
tenantDomain = tenantDomain =
MultitenantUtils.getTenantDomain(clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser()); MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser());
} }
return new OAuthValidationResponse(userName,tenantDomain,isValid); return new OAuthValidationResponse(userName,tenantDomain,isValid);
} }

Loading…
Cancel
Save