forked from community/device-mgt-core
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
commit
c6e2c01caa
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class holds required parameters for a querying a paginated response.
|
||||||
|
*/
|
||||||
|
public class PaginationRequest {
|
||||||
|
|
||||||
|
private int startIndex;
|
||||||
|
private int rowCount;
|
||||||
|
private String owner;
|
||||||
|
private String status;
|
||||||
|
private String deviceType;
|
||||||
|
private String deviceName;
|
||||||
|
private String ownership;
|
||||||
|
|
||||||
|
public PaginationRequest(int start, int rowCount) {
|
||||||
|
this.startIndex = start;
|
||||||
|
this.rowCount = rowCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStartIndex() {
|
||||||
|
return startIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartIndex(int startIndex) {
|
||||||
|
this.startIndex = startIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRowCount() {
|
||||||
|
return rowCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRowCount(int rowCount) {
|
||||||
|
this.rowCount = rowCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceType(String deviceType) {
|
||||||
|
this.deviceType = deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceName() {
|
||||||
|
return deviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceName(String deviceName) {
|
||||||
|
this.deviceName = deviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwnership() {
|
||||||
|
return ownership;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwnership(String ownership) {
|
||||||
|
this.ownership = ownership;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.webapp.authenticator.framework.Utils;
|
||||||
|
|
||||||
|
import org.apache.axis2.AxisFault;
|
||||||
|
import org.apache.axis2.client.Options;
|
||||||
|
import org.apache.axis2.client.ServiceClient;
|
||||||
|
import org.apache.axis2.transport.http.HTTPConstants;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.httpclient.Header;
|
||||||
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
|
import org.apache.commons.httpclient.HttpConnectionManager;
|
||||||
|
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||||
|
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.commons.pool.PoolableObjectFactory;
|
||||||
|
import org.apache.http.conn.HttpClientConnectionManager;
|
||||||
|
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.authenticator.oauth.OAuthConstants;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.authenticator.oauth.OAuthTokenValidationException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class OAuthTokenValidationStubFactory implements PoolableObjectFactory {
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
private String basicAuthHeader;
|
||||||
|
private HttpClient httpClient;
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(OAuthTokenValidationStubFactory.class);
|
||||||
|
|
||||||
|
public OAuthTokenValidationStubFactory(String url, String adminUsername, String adminPassword,
|
||||||
|
Properties properties) {
|
||||||
|
this.validateUrl(url);
|
||||||
|
this.url = url;
|
||||||
|
|
||||||
|
this.validateCredentials(adminUsername, adminPassword);
|
||||||
|
this.basicAuthHeader = new String(Base64.encodeBase64((adminUsername + ":" + adminPassword).getBytes()));
|
||||||
|
|
||||||
|
HttpConnectionManager connectionManager = this.createConnectionManager(properties);
|
||||||
|
this.httpClient = new HttpClient(connectionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of MultiThreadedHttpConnectionManager using HttpClient 3.x APIs
|
||||||
|
*
|
||||||
|
* @param properties Properties to configure MultiThreadedHttpConnectionManager
|
||||||
|
* @return An instance of properly configured MultiThreadedHttpConnectionManager
|
||||||
|
*/
|
||||||
|
private HttpConnectionManager createConnectionManager(Properties properties) {
|
||||||
|
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
|
||||||
|
if (properties == null || properties.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Parameters required to initialize HttpClient instances " +
|
||||||
|
"associated with OAuth token validation service stub are not provided");
|
||||||
|
}
|
||||||
|
String maxConnectionsPerHostParam = properties.getProperty("MaxConnectionsPerHost");
|
||||||
|
if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 2, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
params.setDefaultMaxConnectionsPerHost(Integer.parseInt(maxConnectionsPerHostParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
String maxTotalConnectionsParam = properties.getProperty("MaxTotalConnections");
|
||||||
|
if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 10, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
params.setMaxTotalConnections(Integer.parseInt(maxTotalConnectionsParam));
|
||||||
|
}
|
||||||
|
HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
|
||||||
|
connectionManager.setParams(params);
|
||||||
|
return connectionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of PoolingHttpClientConnectionManager using HttpClient 4.x APIs
|
||||||
|
*
|
||||||
|
* @param properties Properties to configure PoolingHttpClientConnectionManager
|
||||||
|
* @return An instance of properly configured PoolingHttpClientConnectionManager
|
||||||
|
*/
|
||||||
|
private HttpClientConnectionManager createClientConnectionManager(Properties properties) {
|
||||||
|
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
|
||||||
|
if (properties != null) {
|
||||||
|
String maxConnectionsPerHostParam = properties.getProperty("MaxConnectionsPerHost");
|
||||||
|
if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 2, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
connectionManager.setDefaultMaxPerRoute(Integer.parseInt(maxConnectionsPerHostParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
String maxTotalConnectionsParam = properties.getProperty("MaxTotalConnections");
|
||||||
|
if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 10, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
connectionManager.setMaxTotal(Integer.parseInt(maxTotalConnectionsParam));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Properties, i.e. MaxTotalConnections/MaxConnectionsPerHost, required to tune the " +
|
||||||
|
"HttpClient used in OAuth token validation service stub instances are not provided. " +
|
||||||
|
"Therefore, the defaults, 2/10 respectively, will be used");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return connectionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object makeObject() throws Exception {
|
||||||
|
return this.createStub();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroyObject(Object o) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validateObject(Object o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activateObject(Object o) throws Exception {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("OAuth token validate stub instance is activated");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void passivateObject(Object o) throws Exception {
|
||||||
|
if (o instanceof OAuth2TokenValidationServiceStub) {
|
||||||
|
OAuth2TokenValidationServiceStub stub = (OAuth2TokenValidationServiceStub) o;
|
||||||
|
stub._getServiceClient().cleanupTransport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private OAuth2TokenValidationServiceStub createStub() throws OAuthTokenValidationException {
|
||||||
|
OAuth2TokenValidationServiceStub stub;
|
||||||
|
try {
|
||||||
|
stub = new OAuth2TokenValidationServiceStub(url);
|
||||||
|
ServiceClient client = stub._getServiceClient();
|
||||||
|
client.getServiceContext().getConfigurationContext().setProperty(
|
||||||
|
HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
|
||||||
|
|
||||||
|
List<Header> headerList = new ArrayList<>();
|
||||||
|
Header header = new Header();
|
||||||
|
header.setName(HTTPConstants.HEADER_AUTHORIZATION);
|
||||||
|
header.setValue(OAuthConstants.AUTHORIZATION_HEADER_PREFIX_BASIC + " " + basicAuthHeader);
|
||||||
|
headerList.add(header);
|
||||||
|
|
||||||
|
Options options = client.getOptions();
|
||||||
|
options.setProperty(HTTPConstants.HTTP_HEADERS, headerList);
|
||||||
|
options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true");
|
||||||
|
client.setOptions(options);
|
||||||
|
} catch (AxisFault axisFault) {
|
||||||
|
throw new OAuthTokenValidationException("Error occurred while creating the " +
|
||||||
|
"OAuth2TokenValidationServiceStub.", axisFault);
|
||||||
|
}
|
||||||
|
return stub;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateUrl(String url) {
|
||||||
|
if (url == null || url.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Url provided as the endpoint of the OAuth token validation service " +
|
||||||
|
"is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCredentials(String adminUsername, String adminPassword) {
|
||||||
|
if (adminUsername == null || adminUsername.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("An appropriate username required to initialize OAuth token " +
|
||||||
|
"validation service stub factory hasn't been provided");
|
||||||
|
}
|
||||||
|
if (adminPassword == null || adminPassword.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("An appropriate password required to initialize OAuth token " +
|
||||||
|
"validation service stub factory hasn't been provided");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.webapp.authenticator.framework.test;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.wso2.carbon.utils.ServerConstants;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.AuthenticatorFrameworkException;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfig;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.config.WebappAuthenticatorConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WebappAuthenticatorConfigTest {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public void init() {
|
||||||
|
System.setProperty(ServerConstants.CARBON_CONFIG_DIR_PATH, "src/test/resources/config");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigInitialization() {
|
||||||
|
try {
|
||||||
|
WebappAuthenticatorConfig.init();
|
||||||
|
|
||||||
|
WebappAuthenticatorConfig config = WebappAuthenticatorConfig.getInstance();
|
||||||
|
Assert.assertNotNull(config);
|
||||||
|
|
||||||
|
List<AuthenticatorConfig> authConfigs = config.getAuthenticators();
|
||||||
|
Assert.assertNotNull(authConfigs);
|
||||||
|
} catch (AuthenticatorFrameworkException e) {
|
||||||
|
Assert.fail("Error occurred while testing webapp authenticator config initialization", e);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Assert.fail("Unexpected error has been encountered while testing webapp authenticator config " +
|
||||||
|
"initialization", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public void cleanup() {
|
||||||
|
System.setProperty(ServerConstants.CARBON_CONFIG_DIR_PATH, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.webapp.authenticator.framework.test;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.commons.pool.ObjectPool;
|
||||||
|
import org.apache.commons.pool.impl.GenericObjectPool;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class WebappAuthenticatorFrameworkUtilTest {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(WebappAuthenticatorFrameworkUtilTest.class);
|
||||||
|
|
||||||
|
private static final String TOKEN_VALIDATION_SERVICE_URL = "https://localhost:9443";
|
||||||
|
private static final String ADMIN_USERNAME = "admin";
|
||||||
|
private static final String ADMIN_PASSWORD = "admin";
|
||||||
|
private static final Properties PROPERTIES = new Properties();
|
||||||
|
|
||||||
|
static {
|
||||||
|
PROPERTIES.setProperty("MaxTotalConnections", "100");
|
||||||
|
PROPERTIES.setProperty("MaxConnectionsPerHost", "100");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOAuthTokenValidatorStubPool() {
|
||||||
|
ObjectPool stubs = null;
|
||||||
|
OAuth2TokenValidationServiceStub stub = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
stubs = new GenericObjectPool(
|
||||||
|
new OAuthTokenValidationStubFactory(
|
||||||
|
TOKEN_VALIDATION_SERVICE_URL, ADMIN_USERNAME, ADMIN_PASSWORD, PROPERTIES));
|
||||||
|
|
||||||
|
stub = (OAuth2TokenValidationServiceStub) stubs.borrowObject();
|
||||||
|
Assert.assertNotNull(stub);
|
||||||
|
} catch (Exception e) {
|
||||||
|
String msg = "Error occurred while borrowing an oauth validator service stub instance from the pool";
|
||||||
|
log.error(msg, e);
|
||||||
|
Assert.fail(msg, e);
|
||||||
|
} finally {
|
||||||
|
if (stubs != null) {
|
||||||
|
try {
|
||||||
|
if (stub != null) {
|
||||||
|
stubs.returnObject(stub);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Error occurred while returning oauth validator service stub instance to the pool", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checks if the stub instance used above has been properly returned to the pool */
|
||||||
|
Assert.assertEquals(stubs.getNumIdle(), 1);
|
||||||
|
/* Verifies that there's no hanging connections after the operation performed above */
|
||||||
|
Assert.assertEquals(stubs.getNumActive(), 0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
stubs.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Error occurred while closing the object pool", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
|
public void testStubFactoryInitWithInvalidHttpClientProperties() {
|
||||||
|
new OAuthTokenValidationStubFactory(TOKEN_VALIDATION_SERVICE_URL, null, ADMIN_PASSWORD, PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
|
public void testStubFactoryInitWithInvalidUsername() {
|
||||||
|
new OAuthTokenValidationStubFactory(TOKEN_VALIDATION_SERVICE_URL, null, ADMIN_PASSWORD, PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
|
public void testStubFactoryInitWithInvalidPassword() {
|
||||||
|
new OAuthTokenValidationStubFactory(TOKEN_VALIDATION_SERVICE_URL, ADMIN_USERNAME, null, PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
|
public void testStubFactoryInitWithInvalidUrl() {
|
||||||
|
new OAuthTokenValidationStubFactory(null, ADMIN_USERNAME, ADMIN_PASSWORD, PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
<WebappAuthenticatorConfig>
|
||||||
|
<Authenticators>
|
||||||
|
<Authenticator>
|
||||||
|
<Name>OAuth</Name>
|
||||||
|
<ClassName>org.wso2.carbon.webapp.authenticator.framework.authenticator.OAuthAuthenticator</ClassName>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="TokenValidationEndpointUrl">https://localhost:9443</Parameter>
|
||||||
|
<Parameter Name="Username">admin</Parameter>
|
||||||
|
<Parameter Name="Password">admin</Parameter>
|
||||||
|
<Parameter Name="IsRemote">true</Parameter>
|
||||||
|
<Parameter Name="MaxConnectionsPerHost">10000</Parameter>
|
||||||
|
<Parameter Name="MaxTotalConnections">10000</Parameter>
|
||||||
|
</Parameters>
|
||||||
|
</Authenticator>
|
||||||
|
<Authenticator>
|
||||||
|
<Name>BasicAuth</Name>
|
||||||
|
<ClassName>org.wso2.carbon.webapp.authenticator.framework.authenticator.BasicAuthAuthenticator</ClassName>
|
||||||
|
</Authenticator>
|
||||||
|
<Authenticator>
|
||||||
|
<Name>JWT</Name>
|
||||||
|
<ClassName>org.wso2.carbon.webapp.authenticator.framework.authenticator.JWTAuthenticator</ClassName>
|
||||||
|
</Authenticator>
|
||||||
|
<Authenticator>
|
||||||
|
<Name>CertificateAuth</Name>
|
||||||
|
<ClassName>org.wso2.carbon.webapp.authenticator.framework.authenticator.CertificateAuthenticator</ClassName>
|
||||||
|
</Authenticator>
|
||||||
|
</Authenticators>
|
||||||
|
</WebappAuthenticatorConfig>
|
@ -0,0 +1,32 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2009 WSO2, Inc. (http://wso2.com)
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is the log4j configuration file used by WSO2 Carbon
|
||||||
|
#
|
||||||
|
# IMPORTANT : Please do not remove or change the names of any
|
||||||
|
# of the Appenders defined here. The layout pattern & log file
|
||||||
|
# can be changed using the WSO2 Carbon Management Console, and those
|
||||||
|
# settings will override the settings in this file.
|
||||||
|
#
|
||||||
|
|
||||||
|
log4j.rootLogger=ERROR, STD_OUT
|
||||||
|
|
||||||
|
# Redirect log messages to console
|
||||||
|
log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.STD_OUT.Target=System.out
|
||||||
|
log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ you may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||||
|
|
||||||
|
<suite name="WebappAuthenticatorFramework">
|
||||||
|
<parameter name="useDefaultListeners" value="false"/>
|
||||||
|
|
||||||
|
<test name="WebappAuthenticatorConfigTests" preserve-order="true">
|
||||||
|
<classes>
|
||||||
|
<class name="org.wso2.carbon.webapp.authenticator.framework.test.WebappAuthenticatorConfigTest"/>
|
||||||
|
</classes>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
<test name="WebappAuthenticatorUtilTests" preserve-order="true">
|
||||||
|
<classes>
|
||||||
|
<class name="org.wso2.carbon.webapp.authenticator.framework.test.WebappAuthenticatorFrameworkUtilTest"/>
|
||||||
|
</classes>
|
||||||
|
</test>
|
||||||
|
|
||||||
|
</suite>
|
Loading…
Reference in new issue