From edaacd4989b92315ef7df5120c8358da2e73ca9a Mon Sep 17 00:00:00 2001 From: ayyoob Date: Mon, 9 May 2016 01:05:34 +0530 Subject: [PATCH] device adapters updated --- .../input/adapter/http/HTTPEventAdapter.java | 6 +- .../adapter/http/HTTPMessageServlet.java | 190 ++++-------------- .../adapter/http/jwt/JWTAuthenticator.java | 120 +++++++++++ .../http/oauth/OAuthAuthenticator.java | 174 ++++++++++++++++ ...java => InputAdapterServiceComponent.java} | 14 +- ...ava => InputAdapterServiceDataHolder.java} | 8 +- .../adapter/xmpp/XMPPEventAdapterFactory.java | 1 - .../xmpp/{ => i18n}/MQTTEventAdapter.java | 8 +- .../{ => i18n}/MQTTEventAdapterFactory.java | 4 +- .../MQTTEventAdapterServiceComponent.java | 4 +- .../xmpp/{ => i18n}/util/Constants.java | 2 +- .../{ => i18n}/util/MQTTAdapterPublisher.java | 2 +- .../MQTTBrokerConnectionConfiguration.java | 2 +- .../util/MQTTEventAdapterConstants.java | 2 +- .../xmpp/{ => i18n}/util/MQTTUtil.java | 2 +- .../{ => i18n}/util/RegistrationProfile.java | 2 +- .../{xmpp => mqtt}/i18n/Resources.properties | 0 .../xmpp/{ => i18n}/XMPPEventAdapter.java | 8 +- .../{ => i18n}/XMPPEventAdapterFactory.java | 4 +- .../XMPPEventAdapterServiceComponent.java | 4 +- .../{ => i18n}/util/XMPPAdapterPublisher.java | 2 +- .../util/XMPPEventAdapterConstants.java | 2 +- .../XMPPServerConnectionConfiguration.java | 2 +- .../pom.xml | 128 ++++++++++++ .../src/main/resources/build.properties | 19 ++ .../src/main/resources/p2.inf | 1 + .../pom.xml | 15 -- .../iot-base-plugin-feature/pom.xml | 1 + pom.xml | 10 + 29 files changed, 534 insertions(+), 203 deletions(-) create mode 100644 components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/jwt/JWTAuthenticator.java create mode 100644 components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthAuthenticator.java rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/{EventAdapterServiceComponent.java => InputAdapterServiceComponent.java} (88%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/{EventAdapterServiceDataHolder.java => InputAdapterServiceDataHolder.java} (85%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/MQTTEventAdapter.java (96%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/MQTTEventAdapterFactory.java (97%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/internal/MQTTEventAdapterServiceComponent.java (92%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/Constants.java (94%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/MQTTAdapterPublisher.java (99%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/MQTTBrokerConnectionConfiguration.java (96%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/MQTTEventAdapterConstants.java (97%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/MQTTUtil.java (98%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/RegistrationProfile.java (95%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/{xmpp => mqtt}/i18n/Resources.properties (100%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/XMPPEventAdapter.java (96%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/XMPPEventAdapterFactory.java (97%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/internal/XMPPEventAdapterServiceComponent.java (92%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/XMPPAdapterPublisher.java (98%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/XMPPEventAdapterConstants.java (97%) rename components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/{ => i18n}/util/XMPPServerConnectionConfiguration.java (95%) create mode 100644 features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml create mode 100644 features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/build.properties create mode 100644 features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapter.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapter.java index 1bf79aca6..7f41a9c49 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapter.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapter.java @@ -20,7 +20,7 @@ import org.apache.commons.logging.LogFactory; import org.osgi.service.http.HttpService; import org.osgi.service.http.NamespaceException; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.input.adapter.internal.EventAdapterServiceDataHolder; +import org.wso2.carbon.device.mgt.iot.input.adapter.internal.InputAdapterServiceDataHolder; import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; @@ -180,7 +180,7 @@ public final class HTTPEventAdapter implements InputEventAdapter { } try { - HttpService httpService = EventAdapterServiceDataHolder.getHTTPService(); + HttpService httpService = InputAdapterServiceDataHolder.getHTTPService(); if (httpService == null) { throw new InputEventAdapterRuntimeException( "HttpService not available, Error in registering endpoint " + endpoint); @@ -195,7 +195,7 @@ public final class HTTPEventAdapter implements InputEventAdapter { } private void unregisterDynamicEndpoint(String adapterName) { - HttpService httpService = EventAdapterServiceDataHolder.getHTTPService(); + HttpService httpService = InputAdapterServiceDataHolder.getHTTPService(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); String endpoint; if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPMessageServlet.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPMessageServlet.java index 90934de30..a73dbd06f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPMessageServlet.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPMessageServlet.java @@ -26,14 +26,15 @@ import org.wso2.carbon.device.mgt.iot.input.adapter.ContentTransformer; import org.wso2.carbon.device.mgt.iot.input.adapter.DefaultContentTransformer; import org.wso2.carbon.device.mgt.iot.input.adapter.DefaultContentValidator; import org.wso2.carbon.device.mgt.iot.input.adapter.http.exception.HTTPContentInitializationException; +import org.wso2.carbon.device.mgt.iot.input.adapter.http.jwt.JWTAuthenticator; +import org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth.OAuthAuthenticator; import org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth.OAuthTokenValidaterStubFactory; import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.AuthenticationInfo; import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.HTTPEventAdapterConstants; -import org.wso2.carbon.device.mgt.iot.input.adapter.internal.EventAdapterServiceDataHolder; +import org.wso2.carbon.device.mgt.iot.input.adapter.internal.InputAdapterServiceDataHolder; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.device.mgt.iot.input.adapter.ContentValidator; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.exception.MQTTContentInitializationException; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; @@ -60,20 +61,21 @@ import java.util.regex.Pattern; */ public class HTTPMessageServlet extends HttpServlet { - private static final String AUTHORIZATION_HEADER = "Authorization"; private static final String AUTH_MESSAGE_STORE_AUTHENTICATION_INFO = "AUTH_MESSAGE_STORE_AUTHENTICATION_INFO"; private static final String AUTH_FAILURE_RESPONSE = "_AUTH_FAILURE_"; - private static final Pattern PATTERN = Pattern.compile("[B|b]earer\\s"); - private static final String TOKEN_TYPE = "bearer"; - private static String cookie; + + + private static Log log = LogFactory.getLog(HTTPMessageServlet.class); - private GenericObjectPool stubs; + private static Map contentValidationProperties; private static ContentValidator contentValidator; private static ContentTransformer contentTransformer; private InputEventAdapterListener eventAdaptorListener; private int tenantId; private String exposedTransports; + private static JWTAuthenticator jwtAuthenticator; + private static OAuthAuthenticator oAuthAuthenticator; public HTTPMessageServlet(InputEventAdapterListener eventAdaptorListener, int tenantId, InputEventAdapterConfiguration eventAdapterConfiguration) { @@ -81,7 +83,6 @@ public class HTTPMessageServlet extends HttpServlet { this.tenantId = tenantId; this.exposedTransports = eventAdapterConfiguration.getProperties().get( HTTPEventAdapterConstants.EXPOSED_TRANSPORTS); - this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(eventAdapterConfiguration)); HTTPMessageServlet.contentValidationProperties = new HashMap<>(); String contentValidationParams = eventAdapterConfiguration.getProperties().get( HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_PARAMS); @@ -134,143 +135,9 @@ public class HTTPMessageServlet extends HttpServlet { throw new HTTPContentInitializationException("Access of the instance in not allowed.", e); } } - } - private String getBearerToken(HttpServletRequest request) { - String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); - if (authorizationHeader != null) { - Matcher matcher = PATTERN.matcher(authorizationHeader); - if (matcher.find()) { - authorizationHeader = authorizationHeader.substring(matcher.end()); - } - } - return authorizationHeader; - } - - private AuthenticationInfo checkAuthentication(HttpServletRequest req) { - AuthenticationInfo authenticationInfo = (AuthenticationInfo) req.getSession().getAttribute( - AUTH_MESSAGE_STORE_AUTHENTICATION_INFO); - if (authenticationInfo != null) { - return authenticationInfo; - } - String bearerToken = getBearerToken(req); - if (bearerToken == null) { - return authenticationInfo; - } - try { - authenticationInfo = validateToken(bearerToken); - boolean success = authenticationInfo.isAuthenticated(); - if (success) { - req.getSession().setAttribute(AUTH_MESSAGE_STORE_AUTHENTICATION_INFO, authenticationInfo); - } - } catch (Exception e) { - if (log.isDebugEnabled()) { - log.debug("checkAuthentication() fail: " + e.getMessage(), e); - } - } - return authenticationInfo; - } - - /** - * This method gets a string accessToken and validates it - * - * @param token which need to be validated. - * @return AuthenticationInfo with the validated results. - */ - private AuthenticationInfo validateToken(String token) { - OAuth2TokenValidationServiceStub tokenValidationServiceStub = null; - try { - Object stub = this.stubs.borrowObject(); - if (stub != null) { - tokenValidationServiceStub = (OAuth2TokenValidationServiceStub) stub; - if (cookie != null) { - tokenValidationServiceStub._getServiceClient().getOptions().setProperty( - HTTPConstants.COOKIE_STRING, cookie); - } - return getAuthenticationInfo(token, tokenValidationServiceStub); - } else { - log.warn("Stub initialization failed."); - } - } catch (RemoteException e) { - log.error("Error on connecting with the validation endpoint.", e); - } catch (Exception e) { - log.error("Error occurred in borrowing an validation stub from the pool.", e); - - } finally { - try { - if (tokenValidationServiceStub != null) { - this.stubs.returnObject(tokenValidationServiceStub); - } - } catch (Exception e) { - log.warn("Error occurred while returning the object back to the oauth token validation service " + - "stub pool.", e); - } - } - AuthenticationInfo authenticationInfo = new AuthenticationInfo(); - authenticationInfo.setAuthenticated(false); - authenticationInfo.setTenantId(-1); - return authenticationInfo; - } - - /** - * This creates an AuthenticationInfo object that is used for authorization. This method will validate the token - * and - * sets the required parameters to the object. - * - * @param token that needs to be validated. - * @param tokenValidationServiceStub stub that is used to call the external service. - * @return AuthenticationInfo This contains the information related to authenticated client. - * @throws RemoteException that triggers when failing to call the external service.. - */ - private AuthenticationInfo getAuthenticationInfo(String token, - OAuth2TokenValidationServiceStub tokenValidationServiceStub) - throws RemoteException, UserStoreException { - AuthenticationInfo authenticationInfo = new AuthenticationInfo(); - OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); - OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken = - new OAuth2TokenValidationRequestDTO_OAuth2AccessToken(); - accessToken.setTokenType(TOKEN_TYPE); - accessToken.setIdentifier(token); - validationRequest.setAccessToken(accessToken); - boolean authenticated; - OAuth2TokenValidationResponseDTO tokenValidationResponse; - tokenValidationResponse = tokenValidationServiceStub.validate(validationRequest); - if (tokenValidationResponse == null) { - authenticationInfo.setAuthenticated(false); - return authenticationInfo; - } - authenticated = tokenValidationResponse.getValid(); - if (authenticated) { - String authorizedUser = tokenValidationResponse.getAuthorizedUser(); - String username = MultitenantUtils.getTenantAwareUsername(authorizedUser); - String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); - authenticationInfo.setUsername(username); - authenticationInfo.setTenantDomain(tenantDomain); - RealmService realmService = EventAdapterServiceDataHolder.getRealmService(); - int tenantId = realmService.getTenantManager().getTenantId(authenticationInfo.getTenantDomain()); - authenticationInfo.setTenantId(tenantId); - } else { - if (log.isDebugEnabled()) { - log.debug("Token validation failed for token: " + token); - } - } - ServiceContext serviceContext = tokenValidationServiceStub._getServiceClient() - .getLastOperationContext().getServiceContext(); - cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); - authenticationInfo.setAuthenticated(authenticated); - return authenticationInfo; - } - - - private String inputStreamToString(InputStream in) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buff = new byte[1024]; - int i; - while ((i = in.read(buff)) > 0) { - out.write(buff, 0, i); - } - out.close(); - return out.toString(); + jwtAuthenticator = new JWTAuthenticator(); + oAuthAuthenticator = new OAuthAuthenticator(eventAdapterConfiguration); } @Override @@ -361,8 +228,7 @@ public class HTTPMessageServlet extends HttpServlet { private String payload; private int tenantId; - public HTTPRequestProcessor(InputEventAdapterListener inputEventAdapterListener, - String payload, int tenantId) { + public HTTPRequestProcessor(InputEventAdapterListener inputEventAdapterListener, String payload, int tenantId) { this.inputEventAdapterListener = inputEventAdapterListener; this.payload = payload; this.tenantId = tenantId; @@ -372,11 +238,9 @@ public class HTTPMessageServlet extends HttpServlet { try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); - if (log.isDebugEnabled()) { log.debug("Event received in HTTP Event Adapter - " + payload); } - if (payload.trim() != null) { inputEventAdapterListener.onEvent(payload); } else { @@ -388,7 +252,37 @@ public class HTTPMessageServlet extends HttpServlet { PrivilegedCarbonContext.endTenantFlow(); } } + } + + private AuthenticationInfo checkAuthentication(HttpServletRequest req) { + AuthenticationInfo authenticationInfo = (AuthenticationInfo) req.getSession().getAttribute( + AUTH_MESSAGE_STORE_AUTHENTICATION_INFO); + if (authenticationInfo != null) { + return authenticationInfo; + } + if (jwtAuthenticator.isJWTHeaderExist(req)) { + authenticationInfo = jwtAuthenticator.authenticate(req); + } else { + authenticationInfo = oAuthAuthenticator.authenticate(req); + } + if (authenticationInfo != null) { + boolean success = authenticationInfo.isAuthenticated(); + if (success) { + req.getSession().setAttribute(AUTH_MESSAGE_STORE_AUTHENTICATION_INFO, authenticationInfo); + } + } + return authenticationInfo; + } + private String inputStreamToString(InputStream in) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buff = new byte[1024]; + int i; + while ((i = in.read(buff)) > 0) { + out.write(buff, 0, i); + } + out.close(); + return out.toString(); } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/jwt/JWTAuthenticator.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/jwt/JWTAuthenticator.java new file mode 100644 index 000000000..bb02a8562 --- /dev/null +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/jwt/JWTAuthenticator.java @@ -0,0 +1,120 @@ +/* + * 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.iot.input.adapter.http.jwt; + +import com.nimbusds.jose.JOSEException; +import com.nimbusds.jose.JWSVerifier; +import com.nimbusds.jose.crypto.RSASSAVerifier; +import com.nimbusds.jwt.SignedJWT; +import org.apache.axiom.util.base64.Base64Utils; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.core.util.KeyStoreManager; +import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.AuthenticationInfo; +import org.wso2.carbon.device.mgt.iot.input.adapter.internal.InputAdapterServiceDataHolder; +import org.wso2.carbon.user.api.TenantManager; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; +import javax.servlet.http.HttpServletRequest; +import java.security.interfaces.RSAPublicKey; +import java.text.ParseException; + +/** + * This authenticator authenticates HTTP requests using JWT header. + */ +public class JWTAuthenticator { + + private static final Log log = LogFactory.getLog(JWTAuthenticator.class); + public static final String SIGNED_JWT_AUTH_USERNAME = "Username"; + private static final String JWT_ASSERTION_HEADER = "X-JWT-Assertion"; + + public boolean isJWTHeaderExist(HttpServletRequest request) { + String authorizationHeader = request.getHeader(JWT_ASSERTION_HEADER); + if((authorizationHeader != null) && !authorizationHeader.isEmpty()){ + return true; + } + return false; + } + + public AuthenticationInfo authenticate(HttpServletRequest request) { + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + //Get the filesystem keystore default primary certificate + KeyStoreManager keyStoreManager = KeyStoreManager.getInstance(MultitenantConstants.SUPER_TENANT_ID); + try { + keyStoreManager.getDefaultPrimaryCertificate(); + String authorizationHeader = request.getHeader(HTTPConstants.HEADER_AUTHORIZATION); + String headerData = decodeAuthorizationHeader(authorizationHeader); + JWSVerifier verifier = + new RSASSAVerifier((RSAPublicKey) keyStoreManager.getDefaultPublicKey()); + SignedJWT jwsObject = SignedJWT.parse(headerData); + if (jwsObject.verify(verifier)) { + String username = jwsObject.getJWTClaimsSet().getStringClaim(SIGNED_JWT_AUTH_USERNAME); + String tenantDomain = MultitenantUtils.getTenantDomain(username); + username = MultitenantUtils.getTenantAwareUsername(username); + TenantManager tenantManager = InputAdapterServiceDataHolder.getRealmService(). + getTenantManager(); + int tenantId = tenantManager.getTenantId(tenantDomain); + if (tenantId == -1) { + log.error("tenantDomain is not valid. username : " + username + ", tenantDomain " + + ": " + tenantDomain); + } else { + UserStoreManager userStore = InputAdapterServiceDataHolder.getRealmService(). + getTenantUserRealm(tenantId).getUserStoreManager(); + if (userStore.isExistingUser(username)) { + authenticationInfo.setTenantId(tenantId); + authenticationInfo.setUsername(username); + authenticationInfo.setTenantDomain(tenantDomain); + authenticationInfo.setAuthenticated(true); + } + } + } + } catch (UserStoreException e) { + log.error("Error occurred while obtaining the user.", e); + } catch (ParseException e) { + log.error("Error occurred while parsing the JWT header.", e); + } catch (JOSEException e) { + log.error("Error occurred while verifying the JWT header.", e); + } catch (Exception e) { + log.error("Error occurred while verifying the JWT header.", e); + } + return authenticationInfo; + } + + private String decodeAuthorizationHeader(String authorizationHeader) { + + if(authorizationHeader == null) { + return null; + } + + String[] splitValues = authorizationHeader.trim().split(" "); + byte[] decodedBytes = Base64Utils.decode(splitValues[1].trim()); + if (decodedBytes != null) { + return new String(decodedBytes); + } else { + if (log.isDebugEnabled()) { + log.debug("Error decoding authorization header."); + } + return null; + } + } + +} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthAuthenticator.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthAuthenticator.java new file mode 100644 index 000000000..f0e28b63f --- /dev/null +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthAuthenticator.java @@ -0,0 +1,174 @@ +/* + * 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.iot.input.adapter.http.oauth; + +import org.apache.axis2.context.ServiceContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.pool.impl.GenericObjectPool; +import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.AuthenticationInfo; +import org.wso2.carbon.device.mgt.iot.input.adapter.internal.InputAdapterServiceDataHolder; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; +import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +import javax.servlet.http.HttpServletRequest; +import java.rmi.RemoteException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Authenticate use oauth validator + */ +public class OAuthAuthenticator { + private static String cookie; + private GenericObjectPool stubs; + + private static final Pattern PATTERN = Pattern.compile("[B|b]earer\\s"); + private static final String TOKEN_TYPE = "bearer"; + private static final String AUTHORIZATION_HEADER = "Authorization"; + private static Log log = LogFactory.getLog(OAuthAuthenticator.class); + + public OAuthAuthenticator(InputEventAdapterConfiguration eventAdapterConfiguration) { + this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(eventAdapterConfiguration)); + } + + public AuthenticationInfo authenticate(HttpServletRequest req) { + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + String bearerToken = getBearerToken(req); + if (bearerToken == null) { + return authenticationInfo; + } + try { + authenticationInfo = validateToken(bearerToken); + } catch (Exception e) { + if (log.isDebugEnabled()) { + log.debug("checkAuthentication() fail: " + e.getMessage(), e); + } + } + return authenticationInfo; + } + + private String getBearerToken(HttpServletRequest request) { + String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); + if (authorizationHeader != null) { + Matcher matcher = PATTERN.matcher(authorizationHeader); + if (matcher.find()) { + authorizationHeader = authorizationHeader.substring(matcher.end()); + } + } + return authorizationHeader; + } + + /** + * This creates an AuthenticationInfo object that is used for authorization. This method will validate the token + * and + * sets the required parameters to the object. + * + * @param token that needs to be validated. + * @param tokenValidationServiceStub stub that is used to call the external service. + * @return AuthenticationInfo This contains the information related to authenticated client. + * @throws RemoteException that triggers when failing to call the external service.. + */ + private AuthenticationInfo getAuthenticationInfo(String token, + OAuth2TokenValidationServiceStub tokenValidationServiceStub) + throws RemoteException, UserStoreException { + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); + OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken = + new OAuth2TokenValidationRequestDTO_OAuth2AccessToken(); + accessToken.setTokenType(TOKEN_TYPE); + accessToken.setIdentifier(token); + validationRequest.setAccessToken(accessToken); + boolean authenticated; + OAuth2TokenValidationResponseDTO tokenValidationResponse; + tokenValidationResponse = tokenValidationServiceStub.validate(validationRequest); + if (tokenValidationResponse == null) { + authenticationInfo.setAuthenticated(false); + return authenticationInfo; + } + authenticated = tokenValidationResponse.getValid(); + if (authenticated) { + String authorizedUser = tokenValidationResponse.getAuthorizedUser(); + String username = MultitenantUtils.getTenantAwareUsername(authorizedUser); + String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); + authenticationInfo.setUsername(username); + authenticationInfo.setTenantDomain(tenantDomain); + RealmService realmService = InputAdapterServiceDataHolder.getRealmService(); + int tenantId = realmService.getTenantManager().getTenantId(authenticationInfo.getTenantDomain()); + authenticationInfo.setTenantId(tenantId); + } else { + if (log.isDebugEnabled()) { + log.debug("Token validation failed for token: " + token); + } + } + ServiceContext serviceContext = tokenValidationServiceStub._getServiceClient() + .getLastOperationContext().getServiceContext(); + cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); + authenticationInfo.setAuthenticated(authenticated); + return authenticationInfo; + } + + /** + * This method gets a string accessToken and validates it + * + * @param token which need to be validated. + * @return AuthenticationInfo with the validated results. + */ + private AuthenticationInfo validateToken(String token) { + OAuth2TokenValidationServiceStub tokenValidationServiceStub = null; + try { + Object stub = this.stubs.borrowObject(); + if (stub != null) { + tokenValidationServiceStub = (OAuth2TokenValidationServiceStub) stub; + if (cookie != null) { + tokenValidationServiceStub._getServiceClient().getOptions().setProperty( + HTTPConstants.COOKIE_STRING, cookie); + } + return getAuthenticationInfo(token, tokenValidationServiceStub); + } else { + log.warn("Stub initialization failed."); + } + } catch (RemoteException e) { + log.error("Error on connecting with the validation endpoint.", e); + } catch (Exception e) { + log.error("Error occurred in borrowing an validation stub from the pool.", e); + + } finally { + try { + if (tokenValidationServiceStub != null) { + this.stubs.returnObject(tokenValidationServiceStub); + } + } catch (Exception e) { + log.warn("Error occurred while returning the object back to the oauth token validation service " + + "stub pool.", e); + } + } + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + authenticationInfo.setAuthenticated(false); + authenticationInfo.setTenantId(-1); + return authenticationInfo; + } +} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/EventAdapterServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/InputAdapterServiceComponent.java similarity index 88% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/EventAdapterServiceComponent.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/InputAdapterServiceComponent.java index 6f101164e..f58bd71fd 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/EventAdapterServiceComponent.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/InputAdapterServiceComponent.java @@ -32,16 +32,16 @@ import org.wso2.carbon.user.core.service.RealmService; */ /** - * @scr.component name="org.wso2.carbon.event.input.adapter.extension.EventAdapterServiceComponent" immediate="true" + * @scr.component name="org.wso2.carbon.event.input.adapter.extension.InputAdapterServiceComponent" immediate="true" * @scr.reference name="user.realmservice.default" * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" * policy="dynamic" bind="setRealmService" unbind="unsetRealmService" * @scr.reference name="http.service" interface="org.osgi.service.http.HttpService" * cardinality="1..1" policy="dynamic" bind="setHttpService" unbind="unsetHttpService" */ -public class EventAdapterServiceComponent { +public class InputAdapterServiceComponent { - private static final Log log = LogFactory.getLog(EventAdapterServiceComponent.class); + private static final Log log = LogFactory.getLog(InputAdapterServiceComponent.class); protected void activate(ComponentContext context) { try { @@ -63,19 +63,19 @@ public class EventAdapterServiceComponent { } protected void setRealmService(RealmService realmService) { - EventAdapterServiceDataHolder.registerRealmService(realmService); + InputAdapterServiceDataHolder.registerRealmService(realmService); } protected void unsetRealmService(RealmService realmService) { - EventAdapterServiceDataHolder.registerRealmService(null); + InputAdapterServiceDataHolder.registerRealmService(null); } protected void setHttpService(HttpService httpService) { - EventAdapterServiceDataHolder.registerHTTPService(httpService); + InputAdapterServiceDataHolder.registerHTTPService(httpService); } protected void unsetHttpService(HttpService httpService) { - EventAdapterServiceDataHolder.registerHTTPService(null); + InputAdapterServiceDataHolder.registerHTTPService(null); } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/EventAdapterServiceDataHolder.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/InputAdapterServiceDataHolder.java similarity index 85% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/EventAdapterServiceDataHolder.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/InputAdapterServiceDataHolder.java index cfa866e1b..ed2dedef7 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/EventAdapterServiceDataHolder.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/internal/InputAdapterServiceDataHolder.java @@ -20,17 +20,17 @@ import org.wso2.carbon.user.core.service.RealmService; /** * common place to hold some OSGI service references. */ -public final class EventAdapterServiceDataHolder { +public final class InputAdapterServiceDataHolder { private static RealmService realmService; private static HttpService httpService; - private EventAdapterServiceDataHolder() { + private InputAdapterServiceDataHolder() { } public static void registerRealmService( RealmService realmService) { - EventAdapterServiceDataHolder.realmService = realmService; + InputAdapterServiceDataHolder.realmService = realmService; } public static RealmService getRealmService() { @@ -39,7 +39,7 @@ public final class EventAdapterServiceDataHolder { public static void registerHTTPService( HttpService httpService) { - EventAdapterServiceDataHolder.httpService = httpService; + InputAdapterServiceDataHolder.httpService = httpService; } public static HttpService getHTTPService() { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapterFactory.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapterFactory.java index 966703ce7..2f22a012c 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapterFactory.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapterFactory.java @@ -17,7 +17,6 @@ */ package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTEventAdapterConstants; import org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util.XMPPEventAdapterConstants; import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/MQTTEventAdapter.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/MQTTEventAdapter.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/MQTTEventAdapter.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/MQTTEventAdapter.java index b8402db2d..80515c616 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/MQTTEventAdapter.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/MQTTEventAdapter.java @@ -15,19 +15,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.MQTTAdapterPublisher; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.MQTTBrokerConnectionConfiguration; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.MQTTEventAdapterConstants; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.MQTTAdapterPublisher; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.MQTTBrokerConnectionConfiguration; import org.wso2.carbon.event.output.adapter.core.EventAdapterUtil; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapter; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; import org.wso2.carbon.event.output.adapter.core.exception.TestConnectionNotSupportedException; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.MQTTEventAdapterConstants; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/MQTTEventAdapterFactory.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/MQTTEventAdapterFactory.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/MQTTEventAdapterFactory.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/MQTTEventAdapterFactory.java index fd2abb182..305742989 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/MQTTEventAdapterFactory.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/MQTTEventAdapterFactory.java @@ -15,10 +15,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.MQTTEventAdapterConstants; import org.wso2.carbon.event.output.adapter.core.*; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.MQTTEventAdapterConstants; import java.util.*; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/MQTTEventAdapterServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/internal/MQTTEventAdapterServiceComponent.java similarity index 92% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/MQTTEventAdapterServiceComponent.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/internal/MQTTEventAdapterServiceComponent.java index 8af149983..1b01793cb 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/MQTTEventAdapterServiceComponent.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/internal/MQTTEventAdapterServiceComponent.java @@ -15,12 +15,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.internal; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.MQTTEventAdapterFactory; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.MQTTEventAdapterFactory; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/Constants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/Constants.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/Constants.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/Constants.java index 7a36d247a..5b9ea5520 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/Constants.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/Constants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; /** * This holds the constants related to MQTT input adapter. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTAdapterPublisher.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTAdapterPublisher.java similarity index 99% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTAdapterPublisher.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTAdapterPublisher.java index c7e3103da..a8a04c376 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTAdapterPublisher.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTAdapterPublisher.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTBrokerConnectionConfiguration.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTBrokerConnectionConfiguration.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTBrokerConnectionConfiguration.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTBrokerConnectionConfiguration.java index 1dde59d31..0cab10eb3 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTBrokerConnectionConfiguration.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTBrokerConnectionConfiguration.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; public class MQTTBrokerConnectionConfiguration { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTEventAdapterConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTEventAdapterConstants.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTEventAdapterConstants.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTEventAdapterConstants.java index f2586c281..adf7ce05f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTEventAdapterConstants.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTEventAdapterConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; public final class MQTTEventAdapterConstants { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTUtil.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTUtil.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTUtil.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTUtil.java index 01c185495..764d14a79 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/MQTTUtil.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/MQTTUtil.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/RegistrationProfile.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/RegistrationProfile.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/RegistrationProfile.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/RegistrationProfile.java index 9dc855654..73f882c96 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/RegistrationProfile.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/RegistrationProfile.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; /** * This class represents the data that are required to register diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/Resources.properties b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/i18n/Resources.properties similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/Resources.properties rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/i18n/Resources.properties diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapter.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/XMPPEventAdapter.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapter.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/XMPPEventAdapter.java index 211ab3d84..2a5f46bc2 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapter.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/XMPPEventAdapter.java @@ -15,19 +15,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPAdapterPublisher; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPServerConnectionConfiguration; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.XMPPEventAdapterConstants; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.XMPPAdapterPublisher; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.XMPPServerConnectionConfiguration; import org.wso2.carbon.event.output.adapter.core.EventAdapterUtil; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapter; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; import org.wso2.carbon.event.output.adapter.core.exception.TestConnectionNotSupportedException; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPEventAdapterConstants; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapterFactory.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/XMPPEventAdapterFactory.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapterFactory.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/XMPPEventAdapterFactory.java index 687672120..7cf921cb9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapterFactory.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/XMPPEventAdapterFactory.java @@ -15,10 +15,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util.XMPPEventAdapterConstants; import org.wso2.carbon.event.output.adapter.core.*; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPEventAdapterConstants; import java.util.*; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/internal/XMPPEventAdapterServiceComponent.java similarity index 92% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/internal/XMPPEventAdapterServiceComponent.java index c8d1806ed..a8263683b 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/internal/XMPPEventAdapterServiceComponent.java @@ -15,12 +15,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.internal; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.XMPPEventAdapterFactory; +import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.XMPPEventAdapterFactory; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPAdapterPublisher.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPAdapterPublisher.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPAdapterPublisher.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPAdapterPublisher.java index 8ed9fcc3f..97de4fe20 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPAdapterPublisher.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPAdapterPublisher.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPEventAdapterConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPEventAdapterConstants.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPEventAdapterConstants.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPEventAdapterConstants.java index 9db36385c..57282a49f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPEventAdapterConstants.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPEventAdapterConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; public final class XMPPEventAdapterConstants { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPServerConnectionConfiguration.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPServerConnectionConfiguration.java index 51e696e20..2ca85e287 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/util/XMPPServerConnectionConfiguration.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.util; public class XMPPServerConnectionConfiguration { diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml new file mode 100644 index 000000000..b29d6385e --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml @@ -0,0 +1,128 @@ + + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-base-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.adapter.feature + pom + 2.1.0-SNAPSHOT + WSO2 Carbon - IoT Device Management Feature + http://wso2.org + This feature contains the adapter bundles required for IoT Server + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.output.adapter.mqtt + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.output.adapter.xmpp + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.input.adapter + + + + + + + maven-resources-plugin + + + 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.device.mgt.iot.adapter + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.output.adapter.mqtt:${carbon.devicemgt.plugins.version} + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.output.adapter.xmpp:${carbon.devicemgt.plugins.version} + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.input.adapter:${carbon.devicemgt.plugins.version} + + + + + org.wso2.carbon.event.output.adapter.server:${carbon.analytics.common.version} + + + org.wso2.carbon.event.input.adapter.server:${carbon.analytics.common.version} + + + org.wso2.carbon.identity.jwt.client.extension:${carbon.devicemgt.version} + + + + + + + + + diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/build.properties b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/build.properties new file mode 100644 index 000000000..33bb0980d --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/build.properties @@ -0,0 +1,19 @@ +# +# Copyright (c) 2016, 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. +# + +custom = true diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..7ab37b9d7 --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf @@ -0,0 +1 @@ +instructions.configure = \ \ No newline at end of file diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/pom.xml index dd33e8dd2..80aaa6b70 100644 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/pom.xml +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/pom.xml @@ -41,10 +41,6 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.iot - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt - org.json.wso2 json @@ -58,11 +54,6 @@ org.igniterealtime.smack.wso2 smackx - - net.sf.ehcache.wso2 - ehcache - 1.5.0.wso2v3 - @@ -144,9 +135,6 @@ org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot:${carbon.devicemgt.plugins.version} - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.output.adapter.mqtt:${carbon.devicemgt.plugins.version} - org.json.wso2:json:${commons-json.version} @@ -165,9 +153,6 @@ org.wso2.carbon.device.mgt.server:${carbon.devicemgt.version} - - org.wso2.carbon.event.output.adapter.server:${carbon.analytics.common.version} - diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml index 040202a90..a7ff1b759 100644 --- a/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml +++ b/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml @@ -35,6 +35,7 @@ org.wso2.carbon.device.mgt.iot.feature + org.wso2.carbon.device.mgt.iot.adapter.feature diff --git a/pom.xml b/pom.xml index 46e17dd0d..9819b1905 100644 --- a/pom.xml +++ b/pom.xml @@ -336,6 +336,16 @@ org.wso2.carbon.device.mgt.iot.output.adapter.mqtt ${carbon.devicemgt.plugins.version} + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.output.adapter.xmpp + ${carbon.devicemgt.plugins.version} + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.input.adapter + ${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.iot.api