Requested Modifications

revert-70aa11f8
Kamidu Sachith 9 years ago
parent d932522d37
commit 743f394fb9

@ -58,27 +58,27 @@ public class ExternalOAuthValidator implements OAuth2TokenValidator{
accessToken.setTokenType(OauthAuthenticatorConstants.BEARER_TOKEN_TYPE); accessToken.setTokenType(OauthAuthenticatorConstants.BEARER_TOKEN_TYPE);
accessToken.setIdentifier(token); accessToken.setIdentifier(token);
validationRequest.setAccessToken(accessToken); validationRequest.setAccessToken(accessToken);
OAuth2TokenValidationServiceStub validationService = OAuth2TokenValidationServiceStub tokenValidationService =
new OAuth2TokenValidationServiceStub(hostURL); new OAuth2TokenValidationServiceStub(hostURL);
ServiceClient client = validationService._getServiceClient(); ServiceClient client = tokenValidationService._getServiceClient();
Options options = client.getOptions(); Options options = client.getOptions();
List<Header> list = new ArrayList<>(); List<Header> headerList = new ArrayList<>();
Header header = new Header(); Header header = new Header();
header.setName(HTTPConstants.HEADER_AUTHORIZATION); header.setName(HTTPConstants.HEADER_AUTHORIZATION);
header.setValue(OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BEARER+ " " + token); header.setValue(OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BEARER+ " " + token);
list.add(header); headerList.add(header);
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, list); options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, headerList);
client.setOptions(options); client.setOptions(options);
OAuth2ClientApplicationDTO respond = OAuth2ClientApplicationDTO clientApplicationDTO =
validationService.findOAuthConsumerIfTokenIsValid(validationRequest); tokenValidationService.findOAuthConsumerIfTokenIsValid(validationRequest);
boolean isValid = respond.getAccessTokenValidationResponse().getValid(); boolean isValid = clientApplicationDTO.getAccessTokenValidationResponse().getValid();
String userName = null; String userName = null;
String tenantDomain = null; String tenantDomain = null;
if(isValid){ if(isValid){
userName = MultitenantUtils.getTenantAwareUsername( userName = MultitenantUtils.getTenantAwareUsername(
respond.getAccessTokenValidationResponse().getAuthorizedUser()); clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser());
tenantDomain = tenantDomain =
MultitenantUtils.getTenantDomain(respond.getAccessTokenValidationResponse().getAuthorizedUser()); MultitenantUtils.getTenantDomain(clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser());
} }
return new OAuthValidationResponse(userName,tenantDomain,isValid); return new OAuthValidationResponse(userName,tenantDomain,isValid);
} }

@ -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 respond = validationService. OAuth2ClientApplicationDTO clientApplicationDTO = validationService.
findOAuthConsumerIfTokenIsValid(validationRequest); findOAuthConsumerIfTokenIsValid(validationRequest);
boolean isValid = respond.getAccessTokenValidationResponse().isValid(); boolean isValid = clientApplicationDTO.getAccessTokenValidationResponse().isValid();
String userName = null; String userName = null;
String tenantDomain = null; String tenantDomain = null;
if(isValid){ if(isValid){
userName = MultitenantUtils.getTenantAwareUsername( userName = MultitenantUtils.getTenantAwareUsername(
respond.getAccessTokenValidationResponse().getAuthorizedUser()); clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser());
tenantDomain = tenantDomain =
MultitenantUtils.getTenantDomain(respond.getAccessTokenValidationResponse().getAuthorizedUser()); MultitenantUtils.getTenantDomain(clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser());
} }
return new OAuthValidationResponse(userName,tenantDomain,isValid); return new OAuthValidationResponse(userName,tenantDomain,isValid);
} }

Loading…
Cancel
Save