From bcc1cad6e535d291d3e347fdf3ba5f4b936ef4fa Mon Sep 17 00:00:00 2001 From: prabathabey Date: Wed, 25 Mar 2015 18:46:17 +0530 Subject: [PATCH] Merging Webapp authenticator framework implementation --- .../device/mgt/core/api/mgt/APIConfig.java | 2 + .../api/mgt/config/APIPublisherConfig.java | 2 +- .../mgt/handler/valve/APIFaultException.java | 39 ----- .../valve/OAuthTokenValidatorValve.java | 143 ------------------ .../pom.xml | 15 +- .../framework/AuthenticationException.java | 74 +++++++++ .../framework/BasicAuthAuthenticator.java | 50 ++++++ .../framework}/HandlerConstants.java | 2 +- .../authenticator/framework}/HandlerUtil.java | 14 +- .../framework/OAuthAuthenticator.java | 102 +++++++++++++ .../framework/WebappAuthenticator.java | 35 +++++ .../framework/WebappAuthenticatorFactory.java | 67 ++++++++ .../WebappAuthenticatorFrameworkValve.java | 46 ++++++ ...AuthenticatorFrameworkBundleActivator.java | 59 ++++++++ .../pom.xml | 4 +- .../pom.xml | 106 +++++++++++++ .../src/main/resources/build.properties | 1 + .../src/main/resources/conf/cdm-config.xml | 35 +++++ .../main/resources/conf/license-config.xml | 50 ++++++ .../resources/conf/notification-messages.xml | 32 ++++ .../conf/user-api-publisher-config.xml | 30 ++++ .../src/main/resources/dbscripts/cdm/h2.sql | 60 ++++++++ .../main/resources/dbscripts/cdm/mysql.sql | 35 +++++ .../src/main/resources/p2.inf | 7 + .../src/main/resources/rxts/license.rxt | 47 ++++++ .../webapp-authenticator-framework/pom.xml | 41 +++++ pom.xml | 9 +- 27 files changed, 909 insertions(+), 198 deletions(-) delete mode 100644 components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/APIFaultException.java delete mode 100644 components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/OAuthTokenValidatorValve.java rename components/{key-mgt/org.wso2.carbon.key.mgt.handler.valve => webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework}/pom.xml (82%) create mode 100644 components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationException.java create mode 100644 components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/BasicAuthAuthenticator.java rename components/{key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve => webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework}/HandlerConstants.java (94%) rename components/{key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve => webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework}/HandlerUtil.java (91%) create mode 100644 components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/OAuthAuthenticator.java create mode 100644 components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticator.java create mode 100644 components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFactory.java create mode 100644 components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java create mode 100644 components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkBundleActivator.java rename components/{key-mgt => webapp-authenticator-framework}/pom.xml (94%) create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/build.properties create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/cdm-config.xml create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/license-config.xml create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/notification-messages.xml create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/user-api-publisher-config.xml create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/h2.sql create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/mysql.sql create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/rxts/license.rxt create mode 100644 features/webapp-authenticator-framework/pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIConfig.java index faf50e85e7..fa693508b1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/APIConfig.java @@ -21,8 +21,10 @@ package org.wso2.carbon.device.mgt.core.api.mgt; import org.wso2.carbon.apimgt.api.APIProvider; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; +@XmlRootElement(name = "API") public class APIConfig { private String name; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/config/APIPublisherConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/config/APIPublisherConfig.java index 96f220fc70..a781770c6a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/config/APIPublisherConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/api/mgt/config/APIPublisherConfig.java @@ -77,7 +77,7 @@ public class APIPublisherConfig { Document doc = DeviceManagerUtil.convertToDocument(publisherConfig); /* Un-marshaling Device Management configuration */ - JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfig.class); + JAXBContext ctx = JAXBContext.newInstance(APIPublisherConfig.class); Unmarshaller unmarshaller = ctx.createUnmarshaller(); config = (APIPublisherConfig) unmarshaller.unmarshal(doc); } catch (JAXBException e) { diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/APIFaultException.java b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/APIFaultException.java deleted file mode 100644 index be305b5695..0000000000 --- a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/APIFaultException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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. - */ -package org.wso2.carbon.key.mgt.handler.valve; - -public class APIFaultException extends Exception { - - private static final long serialVersionUID = 1L; - private int errorCode; - - public APIFaultException(int errorCode, String message) { - super(message); - this.errorCode = errorCode; - } - - public APIFaultException(int errorCode, String message, Throwable cause) { - super(message, cause); - this.errorCode = errorCode; - } - - public int getErrorCode() { - return errorCode; - } - -} diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/OAuthTokenValidatorValve.java b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/OAuthTokenValidatorValve.java deleted file mode 100644 index ef75e0d3c4..0000000000 --- a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/OAuthTokenValidatorValve.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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. - */ -package org.wso2.carbon.key.mgt.handler.valve; - -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; -import org.apache.catalina.valves.ValveBase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.core.authenticate.APITokenValidator; -import org.wso2.carbon.apimgt.core.gateway.APITokenAuthenticator; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO; -import org.wso2.carbon.apimgt.impl.utils.APIUtil; - -import javax.servlet.ServletException; -import java.io.IOException; -import java.util.Enumeration; - -public class OAuthTokenValidatorValve extends ValveBase { - - private static final Log log = LogFactory.getLog(OAuthTokenValidatorValve.class); - - APITokenAuthenticator authenticator; - - public OAuthTokenValidatorValve() { - authenticator = new APITokenAuthenticator(); - } - - @Override - public void invoke(Request request, Response response) throws java.io.IOException, javax.servlet.ServletException { - String context = request.getContextPath(); - if (context == null || context.equals("")) { - //Invoke the next valve in handler chain. - getNext().invoke(request, response); - return; - } - - boolean contextExist; - Boolean contextValueInCache = null; - if (APIUtil.getAPIContextCache().get(context) != null) { - contextValueInCache = Boolean.parseBoolean(APIUtil.getAPIContextCache().get(context).toString()); - } - - if (contextValueInCache != null) { - contextExist = contextValueInCache; - } else { - contextExist = ApiMgtDAO.isContextExist(context); - APIUtil.getAPIContextCache().put(context, contextExist); - } - - if (!contextExist) { - getNext().invoke(request, response); - return; - } - - try { - handleWSDLGetRequest(request, response, context); - } catch (IOException e) { - e.printStackTrace(); - } catch (ServletException e) { - e.printStackTrace(); - } - - String authHeader = request.getHeader(APIConstants.OperationParameter.AUTH_PARAM_NAME); - String accessToken = null; - - /* Authenticate*/ - try { - if (authHeader != null) { - accessToken = HandlerUtil.getAccessToken(authHeader); - } else { - // There can be some API published with None Auth Type - /* - * throw new - * APIFaultException(APIConstants.KeyValidationStatus - * .API_AUTH_INVALID_CREDENTIALS, - * "Invalid format for Authorization header. Expected 'Bearer '" - * ); - */ - } - - String apiVersion = HandlerUtil.getAPIVersion(request); - String domain = request.getHeader(APITokenValidator.getAPIManagerClientDomainHeader()); - String authLevel = authenticator.getResourceAuthenticationScheme(context, - apiVersion, - request.getRequestURI(), - request.getMethod()); - if (HandlerConstants.NO_MATCHING_AUTH_SCHEME.equals(authLevel)) { - HandlerUtil.handleNoMatchAuthSchemeCallForRestService(response, - request.getMethod(), request.getRequestURI(), - apiVersion, context); - return; - } else { - HandlerUtil.doAuthenticate(context, apiVersion, accessToken, authLevel, domain); - } - } catch (APIManagementException e) { - //ignore - } catch (APIFaultException e) { - log.error("Error occurred while key validation", e); - return; - } - - getNext().invoke(request, response); - } - - private void handleWSDLGetRequest(Request request, Response response, - String context) throws IOException, ServletException { - if (request.getMethod().equals("GET")) { - // TODO:Need to get these paths from a config file. - if (request.getRequestURI().matches(context + "/[^/]*/services")) { - getNext().invoke(request, response); - return; - } - Enumeration params = request.getParameterNames(); - String paramName; - while (params.hasMoreElements()) { - paramName = params.nextElement(); - if (paramName.endsWith("wsdl") || paramName.endsWith("wadl")) { - getNext().invoke(request, response); - return; - } - } - } - } - -} diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml similarity index 82% rename from components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml rename to components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 00994d2d1a..69da22d03e 100644 --- a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,14 +21,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.wso2.carbon.devicemgt - key-mgt + webapp-authenticator-framework 0.9.2-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt - org.wso2.carbon.key.mgt.handler.valve + org.wso2.carbon.webapp.authenticator.framework 0.9.2-SNAPSHOT bundle WSO2 Carbon - Key Management Handler Valve @@ -45,10 +45,15 @@ ${project.artifactId} ${project.artifactId} + org.wso2.carbon.webapp.authenticator.framework.internal.WebappAuthenticatorFrameworkBundleActivator org.wso2.carbon.tomcat.patch - org.wso2.carbon.key.mgt.handler.valve.* + org.wso2.carbon.webapp.authenticator.framework.internal + + !org.wso2.carbon.webapp.authenticator.framework.internal, + org.wso2.carbon.webapp.authenticator.framework.* + tomcat @@ -93,6 +98,10 @@ org.wso2.carbon.identity org.wso2.carbon.identity.core + + org.wso2.carbon + org.wso2.carbon.core.services + diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationException.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationException.java new file mode 100644 index 0000000000..dba70afda4 --- /dev/null +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationException.java @@ -0,0 +1,74 @@ +/* + * 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; + +public class AuthenticationException extends Exception { + + private static final long serialVersionUID = -3151279311929070297L; + + private String errorMessage; + private int errorCode; + + public AuthenticationException(int errorCode, String message) { + super(message); + this.errorCode = errorCode; + } + + public AuthenticationException(int errorCode, String message, Throwable cause) { + super(message, cause); + this.errorCode = errorCode; + } + + public int getErrorCode() { + return errorCode; + } + + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public AuthenticationException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public AuthenticationException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public AuthenticationException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public AuthenticationException() { + super(); + } + + public AuthenticationException(Throwable cause) { + super(cause); + } + +} diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/BasicAuthAuthenticator.java new file mode 100644 index 0000000000..cdff89b5ff --- /dev/null +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/BasicAuthAuthenticator.java @@ -0,0 +1,50 @@ +/* + * 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 org.apache.catalina.connector.Request; + +public class BasicAuthAuthenticator implements WebappAuthenticator { + + private static final String BASIC_AUTH_AUTHENTICATOR = "BasicAuthAuthenticator"; + + private String username; + private String password; + + public BasicAuthAuthenticator(String username, String password) { + this.username = username; + this.password = password; + } + + @Override + public boolean isAuthenticated(Request request) { + return false; + } + + @Override + public Status authenticate(Request request) { + return Status.CONTINUE; + } + + @Override + public String getAuthenticatorName() { + return BasicAuthAuthenticator.BASIC_AUTH_AUTHENTICATOR; + } + +} diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerConstants.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/HandlerConstants.java similarity index 94% rename from components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerConstants.java rename to components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/HandlerConstants.java index f11ab3846e..fa1ac7dbe4 100644 --- a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerConstants.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/HandlerConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.key.mgt.handler.valve; +package org.wso2.carbon.webapp.authenticator.framework; public class HandlerConstants { diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerUtil.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/HandlerUtil.java similarity index 91% rename from components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerUtil.java rename to components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/HandlerUtil.java index 89973dc402..53f3a69164 100644 --- a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/src/main/java/org/wso2/carbon/key/mgt/handler/valve/HandlerUtil.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/HandlerUtil.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.key.mgt.handler.valve; +package org.wso2.carbon.webapp.authenticator.framework; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; @@ -38,7 +38,6 @@ import java.io.IOException; public class HandlerUtil { - private static APIKeyValidationInfoDTO apiKeyValidationDTO; private static final Log log = LogFactory.getLog(HandlerUtil.class); /** @@ -71,7 +70,8 @@ public class HandlerUtil { String version, String context ) { String errMsg = "Resource is not matched for HTTP Verb " + httpVerb + ". API context " + context + ",version " + version + ", request " + reqUri; - APIFaultException e = new APIFaultException( APIManagerErrorConstants.API_AUTH_INCORRECT_API_RESOURCE, errMsg); + AuthenticationException e = + new AuthenticationException(APIManagerErrorConstants.API_AUTH_INCORRECT_API_RESOURCE, errMsg); String faultPayload = getFaultPayload(e, APIManagerErrorConstants.API_SECURITY_NS, APIManagerErrorConstants.API_SECURITY_NS_PREFIX).toString(); handleRestFailure(response, faultPayload); @@ -80,13 +80,13 @@ public class HandlerUtil { public static boolean doAuthenticate(String context, String version, String accessToken, String requiredAuthenticationLevel, String clientDomain) throws APIManagementException, - APIFaultException { + AuthenticationException { if (APIConstants.AUTH_NO_AUTHENTICATION.equals(requiredAuthenticationLevel)) { return true; } APITokenValidator tokenValidator = new APITokenValidator(); - apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken, + APIKeyValidationInfoDTO apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken, requiredAuthenticationLevel, clientDomain); if (apiKeyValidationDTO.isAuthorized()) { String userName = apiKeyValidationDTO.getEndUserName(); @@ -101,7 +101,7 @@ public class HandlerUtil { } return true; } else { - throw new APIFaultException(apiKeyValidationDTO.getValidationStatus(), + throw new AuthenticationException(apiKeyValidationDTO.getValidationStatus(), "Access failure for API: " + context + ", version: " + version + " with key: " + accessToken); } @@ -118,7 +118,7 @@ public class HandlerUtil { } } - public static OMElement getFaultPayload(APIFaultException exception, String FaultNS, + public static OMElement getFaultPayload(AuthenticationException exception, String FaultNS, String FaultNSPrefix) { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace ns = fac.createOMNamespace(FaultNS, FaultNSPrefix); diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/OAuthAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/OAuthAuthenticator.java new file mode 100644 index 0000000000..dc80b6ba91 --- /dev/null +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/OAuthAuthenticator.java @@ -0,0 +1,102 @@ +/* + * 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 org.apache.catalina.connector.Request; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.api.APIManagementException; +import org.wso2.carbon.apimgt.core.authenticate.APITokenValidator; +import org.wso2.carbon.apimgt.core.gateway.APITokenAuthenticator; +import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO; +import org.wso2.carbon.apimgt.impl.utils.APIUtil; + +public class OAuthAuthenticator implements WebappAuthenticator { + + private static final String OAUTH_AUTHENTICATOR = "OAuthAuthenticator"; + private static APITokenAuthenticator authenticator = new APITokenAuthenticator(); + + private String bearerToken; + private static final Log log = LogFactory.getLog(OAuthAuthenticator.class); + + public OAuthAuthenticator(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public boolean isAuthenticated(Request request) { + return false; + } + + @Override + public Status authenticate(Request request) { + String context = request.getContextPath(); + if (context == null || "".equals(context)) { + return Status.CONTINUE; + } + + boolean contextExist; + Boolean contextValueInCache = null; + if (APIUtil.getAPIContextCache().get(context) != null) { + contextValueInCache = Boolean.parseBoolean(APIUtil.getAPIContextCache().get(context).toString()); + } + + if (contextValueInCache != null) { + contextExist = contextValueInCache; + } else { + contextExist = ApiMgtDAO.isContextExist(context); + APIUtil.getAPIContextCache().put(context, contextExist); + } + + if (!contextExist) { + return Status.CONTINUE; + } + + try { + String apiVersion = HandlerUtil.getAPIVersion(request); + String domain = request.getHeader(APITokenValidator.getAPIManagerClientDomainHeader()); + String authLevel = authenticator.getResourceAuthenticationScheme(context, + apiVersion, + request.getRequestURI(), + request.getMethod()); + if (HandlerConstants.NO_MATCHING_AUTH_SCHEME.equals(authLevel)) { + HandlerUtil.handleNoMatchAuthSchemeCallForRestService(null, + request.getMethod(), request.getRequestURI(), + apiVersion, context); + return Status.CONTINUE; + } else { + boolean isAuthenticated = + HandlerUtil.doAuthenticate(context, apiVersion, bearerToken, authLevel, domain); + return (isAuthenticated) ? Status.SUCCESS : Status.FAILURE; + } + } catch (APIManagementException e) { + //ignore + } catch (AuthenticationException e) { + log.error("Error occurred while key validation", e); + } + return Status.CONTINUE; + } + + @Override + public String getAuthenticatorName() { + return OAuthAuthenticator.OAUTH_AUTHENTICATOR; + } + + +} diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticator.java new file mode 100644 index 0000000000..7bcc084de7 --- /dev/null +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticator.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.catalina.connector.Request; + +public interface WebappAuthenticator { + + enum Status { + SUCCESS, FAILURE, CONTINUE + } + + boolean isAuthenticated(Request request); + + Status authenticate(Request request); + + String getAuthenticatorName(); + +} diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFactory.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFactory.java new file mode 100644 index 0000000000..0dc842f233 --- /dev/null +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFactory.java @@ -0,0 +1,67 @@ +/* + * 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 org.apache.catalina.connector.Request; +import org.apache.catalina.util.Base64; +import org.apache.tomcat.util.buf.ByteChunk; +import org.apache.tomcat.util.buf.CharChunk; +import org.apache.tomcat.util.buf.MessageBytes; + +public class WebappAuthenticatorFactory { + + public static WebappAuthenticator getAuthenticator(Request request) { + MessageBytes authorization = request.getCoyoteRequest().getMimeHeaders().getValue("authorization"); + if (authorization != null) { + authorization.toBytes(); + ByteChunk authBC = authorization.getByteChunk(); + if (authBC.startsWithIgnoreCase("basic ", 0)) { + authBC.setOffset(authBC.getOffset() + 6); + + CharChunk authCC = authorization.getCharChunk(); + Base64.decode(authBC, authCC); + + String username; + String password = null; + + int colon = authCC.indexOf(':'); + if (colon < 0) { + username = authCC.toString(); + } else { + char[] buf = authCC.getBuffer(); + username = new String(buf, 0, colon); + password = new String(buf, colon + 1, authCC.getEnd() - colon - 1); + } + authBC.setOffset(authBC.getOffset() - 6); + return new BasicAuthAuthenticator(username, password); + } else if (authBC.startsWithIgnoreCase("bearer ", 0)) { + authBC.setOffset(authBC.getOffset() + 7); + + CharChunk authCC = authorization.getCharChunk(); + char[] buf = authCC.getBuffer(); + String bearer = new String(buf, 0, authCC.getEnd() - 1); + authBC.setOffset(authBC.getOffset() - 7); + return new OAuthAuthenticator(bearer); + } + } + throw new IllegalArgumentException("Failed to determine an appropriate authenticator to be used, based " + + "on the incoming request"); + } + +} diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java new file mode 100644 index 0000000000..fc86afa496 --- /dev/null +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java @@ -0,0 +1,46 @@ +/* + * 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 org.apache.axis2.context.MessageContext; +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.catalina.valves.ValveBase; +import org.wso2.carbon.core.services.authentication.CarbonServerAuthenticator; +import org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve; +import org.wso2.carbon.tomcat.ext.valves.CompositeValve; + +import javax.servlet.ServletException; +import java.io.IOException; + +public class WebappAuthenticatorFrameworkValve extends CarbonTomcatValve { + + @Override + public void invoke(Request request, Response response, CompositeValve compositeValve) { + WebappAuthenticator authenticator = WebappAuthenticatorFactory.getAuthenticator(request); + WebappAuthenticator.Status status = authenticator.authenticate(request); + switch (status) { + case SUCCESS: + case CONTINUE: + getNext().invoke(request, response, compositeValve); + case FAILURE: + //do something + } + } +} diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkBundleActivator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkBundleActivator.java new file mode 100644 index 0000000000..02278eb577 --- /dev/null +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkBundleActivator.java @@ -0,0 +1,59 @@ +/* + * 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.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.WebappAuthenticatorFrameworkValve; + +import java.util.ArrayList; +import java.util.List; + +public class WebappAuthenticatorFrameworkBundleActivator implements BundleActivator { + + private static final Log log = LogFactory.getLog(WebappAuthenticatorFrameworkBundleActivator.class); + + @Override + public void start(BundleContext bundleContext) throws Exception { + if (log.isDebugEnabled()) { + log.debug("Starting Web Application Authenticator Framework Bundle"); + } + try { + List valves = new ArrayList(); + valves.add(new WebappAuthenticatorFrameworkValve()); + TomcatValveContainer.addValves(valves); + + if (log.isDebugEnabled()) { + log.debug("Web Application Authenticator Framework Bundle has been started successfully"); + } + } catch (Throwable e) { + log.error("Error occurred while initializing the bundle"); + } + } + + @Override + public void stop(BundleContext bundleContext) throws Exception { + //do nothing + } + +} diff --git a/components/key-mgt/pom.xml b/components/webapp-authenticator-framework/pom.xml similarity index 94% rename from components/key-mgt/pom.xml rename to components/webapp-authenticator-framework/pom.xml index ec6d9094e6..417c9adeb3 100644 --- a/components/key-mgt/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -30,14 +30,14 @@ 4.0.0 org.wso2.carbon.devicemgt - key-mgt + webapp-authenticator-framework 0.9.2-SNAPSHOT pom WSO2 Carbon - Device Management Component http://wso2.org - org.wso2.carbon.key.mgt.handler.valve + org.wso2.carbon.webapp.authenticator.framework diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml new file mode 100644 index 0000000000..de3e9b42f4 --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -0,0 +1,106 @@ + + + + + + + org.wso2.carbon.devicemgt + device-mgt-feature + 0.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.webapp.authenticator.framework.server.feature + pom + 0.9.2-SNAPSHOT + WSO2 Carbon - Device Management Server Feature + http://wso2.org + This feature contains the core bundles required for Back-end Device Management functionality + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.webapp.authenticator.framework.server + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + org.wso2.carbon.devicemgt:org.wso2.carbon.webapp.authenticator.framework:${carbon.device.mgt.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + org.wso2.carbon.apimgt.core:${carbon.api.mgt.version} + + + + + + + + diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/build.properties b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/build.properties new file mode 100644 index 0000000000..9c86577d76 --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/cdm-config.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/cdm-config.xml new file mode 100644 index 0000000000..0991207a54 --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/cdm-config.xml @@ -0,0 +1,35 @@ + + + + + + + + jdbc/DM_DS + + + + 8 + 100 + 20 + 1000 + + + + diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/license-config.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/license-config.xml new file mode 100644 index 0000000000..e182e58bb9 --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/license-config.xml @@ -0,0 +1,50 @@ + + + + + + + wso2 + android + 1.0.0 + 1.0.0 + 01-01-2014 + 31-12-2035 + + + + wso2 + ios + 1.0.0 + 1.0.0 + 01-01-2014 + 31-12-2035 + + + + wso2 + windows + 1.0.0 + 1.0.0 + 01-01-2014 + 31-12-2035 + + + + \ No newline at end of file diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/notification-messages.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/notification-messages.xml new file mode 100644 index 0000000000..563b4a58c0 --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/notification-messages.xml @@ -0,0 +1,32 @@ + + + + + +
Dear {title} {user-name},
+ You have been registered to the WSO2 MDM. Below is the link to enroll. + {downloadUrl} +
+Best Regards, +WSO2 Carbon Team +http://www.wso2.com +
+ Enrol your device with WSO2 MDM +
+
\ No newline at end of file diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/user-api-publisher-config.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/user-api-publisher-config.xml new file mode 100644 index 0000000000..3221092ae9 --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/user-api-publisher-config.xml @@ -0,0 +1,30 @@ + + + + + + appmanager + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/h2.sql new file mode 100644 index 0000000000..561e4a635c --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -0,0 +1,60 @@ +CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( + ID INT auto_increment NOT NULL, + NAME VARCHAR(300) NULL DEFAULT NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE ( + ID INTEGER auto_increment NOT NULL, + DESCRIPTION TEXT NULL DEFAULT NULL, + NAME VARCHAR(100) NULL DEFAULT NULL, + DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL, + DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL, + OWNERSHIP VARCHAR(45) NULL DEFAULT NULL, + STATUS VARCHAR(15) NULL DEFAULT NULL, + DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL, + OWNER VARCHAR(45) NULL DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) + REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_OPERATION ( + ID INTEGER AUTO_INCREMENT NOT NULL, + TYPE VARCHAR(50) NOT NULL, + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + RECEIVED_TIMESTAMP TIMESTAMP NULL, + STATUS VARCHAR(50) NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION ( + OPERATION_ID INTEGER NOT NULL, + PRIMARY KEY (OPERATION_ID), + CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION ( + OPERATION_ID INTEGER NOT NULL, + ENABLED INTEGER NOT NULL DEFAULT 0, + PRIMARY KEY (OPERATION_ID), + CONSTRAINT fk_dm_operation_command FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_MAPPING ( + ID INTEGER AUTO_INCREMENT NOT NULL, + DEVICE_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_operation_mapping_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_operation_mapping_operation FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- TO:DO - Remove this INSERT sql statement. +Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android'); diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/mysql.sql new file mode 100644 index 0000000000..bc04de8732 --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -0,0 +1,35 @@ +-- ----------------------------------------------------- +-- Table `DM_DEVICE_TYPE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` ( + `ID` INT(11) NOT NULL , + `NAME` VARCHAR(300) NULL DEFAULT NULL , + PRIMARY KEY (`ID`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `DM_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DM_DEVICE` ( + `ID` VARCHAR(20) NOT NULL , + `DESCRIPTION` TEXT NULL DEFAULT NULL , + `NAME` VARCHAR(100) NULL DEFAULT NULL , + `DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL , + `DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL , + `OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL , + `STATUS` VARCHAR(15) NULL DEFAULT NULL , + `DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL , + `DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL , + `OWNER` VARCHAR(45) NULL DEFAULT NULL , + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (`ID`) , + INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) , + CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2` + FOREIGN KEY (`DEVICE_TYPE_ID` ) + REFERENCES `DM_DEVICE_TYPE` (`ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..36ac4e31ef --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf @@ -0,0 +1,7 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/notification-messages.xml,target:${installFolder}/../../conf/notification-messages.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/license-config.xml,target:${installFolder}/../../conf/etc/license-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/user-api-publisher-config.xml,target:${installFolder}/../../conf/etc/user-api-publisher-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\ \ No newline at end of file diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/rxts/license.rxt b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/rxts/license.rxt new file mode 100644 index 0000000000..b85f5b73fb --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/rxts/license.rxt @@ -0,0 +1,47 @@ + + + /device-mgt/license/@{overview_name}/@{overview_language}/@{overview_version} + overview_name + + + + + + + + + + + + + + + + + + + + Provider + + + Name + + + Language + + + Version + + + Validity From + + + Validity To + + + License + +
+
+
diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml new file mode 100644 index 0000000000..46810ce8f4 --- /dev/null +++ b/features/webapp-authenticator-framework/pom.xml @@ -0,0 +1,41 @@ + + + + + + + org.wso2.carbon.devicemgt + carbon-devicemgt + 0.9.2-SNAPSHOT + ../../pom.xml + + + 4.0.0 + org.wso2.carbon.devicemgt + webapp-authenticator-framework-feature + 0.9.2-SNAPSHOT + pom + WSO2 Carbon - Webapp Authenticator Framework Feature + http://wso2.org + + + org.wso2.carbon.webapp.authenticator.framework.server.feature + + + diff --git a/pom.xml b/pom.xml index 0f70a3b211..2c1619a484 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,11 @@ components/device-mgt components/policy-mgt components/user-mgt - components/key-mgt + components/webapp-authenticator-framework features/device-mgt features/policy-mgt features/user-mgt + features/webapp-authenticator-framework @@ -504,10 +505,14 @@ org.wso2.carbon.logging ${carbon.kernel.version} + + org.wso2.carbon + org.wso2.carbon.core.services + ${carbon.kernel.version} + - com.h2database.wso2 h2-database-engine