Conflicts:
	features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/user-api-publisher-config.xml
4.x.x
mharindu 10 years ago
commit 695ff8edcb

@ -31,6 +31,6 @@ public interface WebappAuthenticator {
Status authenticate(Request request, Response response);
String getAuthenticatorName();
String getName();
}

@ -29,7 +29,7 @@ import org.wso2.carbon.webapp.authenticator.framework.authenticator.OAuthAuthent
public class WebappAuthenticatorFactory {
public static WebappAuthenticator getAuthenticator(String authScheme) {
return new OAuthAuthenticator();
return DataHolder.getWebappAuthenticatorRepository().getAuthenticator(authScheme);
}
}

@ -29,14 +29,18 @@ import javax.servlet.http.HttpServletResponse;
public class WebappAuthenticatorFrameworkValve extends CarbonTomcatValve {
private static final String AUTHENTICATION_SCHEME = "AuthenticationScheme";
private static final Log log = LogFactory.getLog(WebappAuthenticatorFrameworkValve.class);
private static final String AUTHENTICATION_SCHEME = "authentication-scheme";
@Override
public void invoke(Request request, Response response, CompositeValve compositeValve) {
String authScheme =
request.getContext().findParameter(WebappAuthenticatorFrameworkValve.AUTHENTICATION_SCHEME);
if (authScheme == null || "".equals(authScheme)) {
this.getNext().invoke(request, response, compositeValve);
return;
}
WebappAuthenticator authenticator = WebappAuthenticatorFactory.getAuthenticator(authScheme);
WebappAuthenticator.Status status = authenticator.authenticate(request, response);
this.processResponse(request, response, compositeValve, status);
}
@ -55,5 +59,4 @@ public class WebappAuthenticatorFrameworkValve extends CarbonTomcatValve {
}
}
}

@ -0,0 +1,40 @@
/*
* 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;
import java.util.HashMap;
import java.util.Map;
public class WebappAuthenticatorRepository {
private Map<String, WebappAuthenticator> authenticators;
public WebappAuthenticatorRepository() {
this.authenticators = new HashMap<String, WebappAuthenticator>();
}
public void addAuthenticator(WebappAuthenticator authenticator) {
authenticators.put(authenticator.getName(), authenticator);
}
public WebappAuthenticator getAuthenticator(String name) {
return authenticators.get(name);
}
}

@ -28,7 +28,7 @@ import org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticator;
public class BasicAuthAuthenticator implements WebappAuthenticator {
private static final String BASIC_AUTH_AUTHENTICATOR = "BasicAuthAuthenticator";
private static final String BASIC_AUTH_AUTHENTICATOR = "BasicAuth";
@Override
public boolean isAuthenticated(Request request) {
@ -41,7 +41,7 @@ public class BasicAuthAuthenticator implements WebappAuthenticator {
}
@Override
public String getAuthenticatorName() {
public String getName() {
return BasicAuthAuthenticator.BASIC_AUTH_AUTHENTICATOR;
}

@ -37,7 +37,7 @@ import java.util.StringTokenizer;
public class OAuthAuthenticator implements WebappAuthenticator {
private static final String OAUTH_AUTHENTICATOR = "OAuthAuthenticator";
private static final String OAUTH_AUTHENTICATOR = "OAuth";
private static APITokenAuthenticator authenticator = new APITokenAuthenticator();
private static final Log log = LogFactory.getLog(OAuthAuthenticator.class);
@ -97,7 +97,7 @@ public class OAuthAuthenticator implements WebappAuthenticator {
}
@Override
public String getAuthenticatorName() {
public String getName() {
return OAuthAuthenticator.OAUTH_AUTHENTICATOR;
}

@ -24,7 +24,10 @@ import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve;
import org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer;
import org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticator;
import org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticatorFrameworkValve;
import org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticatorRepository;
import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfig;
import org.wso2.carbon.webapp.authenticator.framework.config.WebappAuthenticatorConfig;
import java.util.ArrayList;
@ -41,6 +44,14 @@ public class WebappAuthenticatorFrameworkBundleActivator implements BundleActiva
}
try {
WebappAuthenticatorConfig.init();
WebappAuthenticatorRepository repository = new WebappAuthenticatorRepository();
for (AuthenticatorConfig config : WebappAuthenticatorConfig.getInstance().getAuthenticators()) {
WebappAuthenticator authenticator =
(WebappAuthenticator) Class.forName(config.getClassName()).newInstance();
repository.addAuthenticator(authenticator);
}
List<CarbonTomcatValve> valves = new ArrayList<CarbonTomcatValve>();
valves.add(new WebappAuthenticatorFrameworkValve());
TomcatValveContainer.addValves(valves);

@ -27,51 +27,19 @@
<Transports>http,https</Transports>
</API>
<API>
<Name>Enrollment</Name>
<Name>AndroidAgent</Name>
<Owner>admin</Owner>
<Context>enrollment</Context>
<Context>mdm-android-agent</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/enrollment</Endpoint>
<Endpoint>http://localhost:9763/mdm-android-agent</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>License</Name>
<Name>MDMAdmin</Name>
<Owner>admin</Owner>
<Context>license-mgt</Context>
<Context>mdm-admin</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/device/license</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>Operation</Name>
<Owner>admin</Owner>
<Context>operation</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/operation</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>Device List</Name>
<Owner>admin</Owner>
<Context>mdm-admin/devices</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-admin/devices</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>APP Install Operation</Name>
<Owner>admin</Owner>
<Context>operations</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/operations/installApp</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>APP UN Install Operation</Name>
<Owner>admin</Owner>
<Context>operations</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/operations/uninstallApp</Endpoint>
<Endpoint>http://localhost:9763/mdm-admin</Endpoint>
<Transports>http,https</Transports>
</API>
</APIs>

Loading…
Cancel
Save