Adding updated webapp authenticator config

revert-70aa11f8
prabathabey 9 years ago
parent edf21ae5c8
commit 0cdc139a0b

@ -43,27 +43,33 @@ public class RemoteOAuthValidator implements OAuth2TokenValidator {
private static final Log log = LogFactory.getLog(RemoteOAuthValidator.class); private static final Log log = LogFactory.getLog(RemoteOAuthValidator.class);
public RemoteOAuthValidator(String hostURL, String adminUserName, String adminPassword, Properties properties) { public RemoteOAuthValidator(String hostURL, String adminUserName, String adminPassword, Properties properties) {
this.stubs = new GenericObjectPool(new OAuthTokenValidationStubFactory(hostURL, adminUserName, adminPassword, properties)); this.stubs =
new GenericObjectPool(new OAuthTokenValidationStubFactory(
hostURL, adminUserName, adminPassword, properties));
} }
public OAuthValidationResponse validateToken(String accessToken, String resource) throws OAuthTokenValidationException { public OAuthValidationResponse validateToken(String accessToken,
String resource) throws OAuthTokenValidationException {
OAuth2TokenValidationServiceStub stub = null; OAuth2TokenValidationServiceStub stub = null;
OAuth2TokenValidationResponseDTO validationResponse; OAuth2TokenValidationResponseDTO validationResponse;
try { try {
OAuth2TokenValidationRequestDTO validationRequest = createValidationRequest(accessToken, resource); OAuth2TokenValidationRequestDTO validationRequest = createValidationRequest(accessToken, resource);
stub = (OAuth2TokenValidationServiceStub) this.stubs.borrowObject(); stub = (OAuth2TokenValidationServiceStub) this.stubs.borrowObject();
validationResponse = stub.findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse(); validationResponse =
stub.findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
} catch (RemoteException e) { } catch (RemoteException e) {
throw new OAuthTokenValidationException("Remote Exception occurred while invoking the Remote IS server for OAuth2 token validation.", e); throw new OAuthTokenValidationException("Remote Exception occurred while invoking the Remote " +
"IS server for OAuth2 token validation.", e);
} catch (Exception e) { } catch (Exception e) {
throw new OAuthTokenValidationException("Error occurred while borrowing an oauth token validation service stub from the pool", e); throw new OAuthTokenValidationException("Error occurred while borrowing an oauth token validation " +
"service stub from the pool", e);
} finally { } finally {
try { try {
this.stubs.returnObject(stub); this.stubs.returnObject(stub);
} catch (Exception e) { } catch (Exception e) {
log.warn("Error occurred while returning the object back to the oauth token validation service stub pool", e); log.warn("Error occurred while returning the object back to the oauth token validation service " +
"stub pool", e);
} }
} }
if (validationResponse == null) { if (validationResponse == null) {
@ -89,18 +95,21 @@ public class RemoteOAuthValidator implements OAuth2TokenValidator {
private OAuth2TokenValidationRequestDTO createValidationRequest(String accessToken, String resource) { private OAuth2TokenValidationRequestDTO createValidationRequest(String accessToken, String resource) {
OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
OAuth2TokenValidationRequestDTO_OAuth2AccessToken oauthToken = new OAuth2TokenValidationRequestDTO_OAuth2AccessToken(); OAuth2TokenValidationRequestDTO_OAuth2AccessToken oauthToken =
new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
oauthToken.setTokenType("bearer"); oauthToken.setTokenType("bearer");
oauthToken.setIdentifier(accessToken); oauthToken.setIdentifier(accessToken);
validationRequest.setAccessToken(oauthToken); validationRequest.setAccessToken(oauthToken);
OAuth2TokenValidationRequestDTO_TokenValidationContextParam resourceContextParam = new OAuth2TokenValidationRequestDTO_TokenValidationContextParam(); OAuth2TokenValidationRequestDTO_TokenValidationContextParam resourceContextParam =
new OAuth2TokenValidationRequestDTO_TokenValidationContextParam();
resourceContextParam.setKey("resource"); resourceContextParam.setKey("resource");
resourceContextParam.setValue(resource); resourceContextParam.setValue(resource);
OAuth2TokenValidationRequestDTO_TokenValidationContextParam[] tokenValidationContextParams = new OAuth2TokenValidationRequestDTO_TokenValidationContextParam[1]; OAuth2TokenValidationRequestDTO_TokenValidationContextParam[] tokenValidationContextParams =
new OAuth2TokenValidationRequestDTO_TokenValidationContextParam[1];
tokenValidationContextParams[0] = resourceContextParam; tokenValidationContextParams[0] = resourceContextParam;
validationRequest.setContext(tokenValidationContextParams); validationRequest.setContext(tokenValidationContextParams);

@ -3,6 +3,14 @@
<Authenticator> <Authenticator>
<Name>OAuth</Name> <Name>OAuth</Name>
<ClassName>org.wso2.carbon.webapp.authenticator.framework.authenticator.OAuthAuthenticator</ClassName> <ClassName>org.wso2.carbon.webapp.authenticator.framework.authenticator.OAuthAuthenticator</ClassName>
<Parameters>
<Parameter name="IsRemote">true</Parameter>
<Parameter name="TokenValidationEndpointUrl">https://localhost:9443</Parameter>
<Parameter name="Username">admin</Parameter>
<Parameter name="Password">admin</Parameter>
<Parameter name="MaxTotalConnections">100</Parameter>
<Parameter name="MaxConnectionsPerHost">100</Parameter>
</Parameters>
</Authenticator> </Authenticator>
<Authenticator> <Authenticator>
<Name>BasicAuth</Name> <Name>BasicAuth</Name>

Loading…
Cancel
Save