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

@ -44,16 +44,16 @@ public class LocalOAuthValidator implements OAuth2TokenValidator {
accessToken.setIdentifier(token);
validationRequest.setAccessToken(accessToken);
OAuth2TokenValidationService validationService = new OAuth2TokenValidationService();
OAuth2ClientApplicationDTO respond = validationService.
OAuth2ClientApplicationDTO clientApplicationDTO = validationService.
findOAuthConsumerIfTokenIsValid(validationRequest);
boolean isValid = respond.getAccessTokenValidationResponse().isValid();
boolean isValid = clientApplicationDTO.getAccessTokenValidationResponse().isValid();
String userName = null;
String tenantDomain = null;
if(isValid){
userName = MultitenantUtils.getTenantAwareUsername(
respond.getAccessTokenValidationResponse().getAuthorizedUser());
clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser());
tenantDomain =
MultitenantUtils.getTenantDomain(respond.getAccessTokenValidationResponse().getAuthorizedUser());
MultitenantUtils.getTenantDomain(clientApplicationDTO.getAccessTokenValidationResponse().getAuthorizedUser());
}
return new OAuthValidationResponse(userName,tenantDomain,isValid);
}

Loading…
Cancel
Save