diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml
new file mode 100644
index 000000000..d4f9ebb73
--- /dev/null
+++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ mb-extensions
+ 3.0.22-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization
+ bundle
+ WSO2 Carbon - Component - MQTT - Authorization Manager
+ MQTT authorization manager based on Carbon device manager
+ http://wso2.org
+
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+
+
+ org.wso2.carbon
+ org.wso2.carbon.core
+
+
+ org.wso2.andes.wso2
+ andes
+
+
+ org.wso2.carbon
+ org.wso2.carbon.user.api
+
+
+ org.wso2.carbon
+ org.wso2.carbon.user.core
+
+
+ commons-lang
+ commons-lang
+
+
+ io.github.openfeign
+ feign-core
+
+
+ io.github.openfeign
+ feign-jaxrs
+
+
+ io.github.openfeign
+ feign-gson
+
+
+ javax.ws.rs
+ jsr311-api
+
+
+ org.wso2.carbon
+ javax.cache.wso2
+
+
+ io.github.openfeign
+ feign-slf4j
+
+
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+
+ org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.internal
+
+
+ !org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.internal,
+ org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.*
+
+
+ org.apache.log4j,
+ org.dna.mqtt.moquette.server,
+ org.wso2.andes.configuration.enums,
+ org.wso2.andes.mqtt,
+ org.wso2.carbon.context,
+ org.jaxen,
+ org.apache.axiom.*,
+ org.wso2.securevault,
+ org.apache.commons.*,
+ org.osgi.service.component,
+ org.wso2.carbon.user.core.service,
+ org.wso2.carbon.user.core.tenant,
+ org.wso2.carbon.user.api,
+ feign,
+ feign.auth,
+ feign.codec,
+ feign.gson,
+ javax.cache,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.wso2.carbon.base,
+ org.wso2.carbon.utils,
+ javax.net.ssl,
+ feign.slf4j
+
+
+ jsr311-api,
+ feign-jaxrs
+
+
+
+
+
+
+
+
+
diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/ApiOriginFilter.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/ApiOriginFilter.java
new file mode 100644
index 000000000..d5f093ef9
--- /dev/null
+++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/ApiOriginFilter.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ */
+package org.wso2.carbon.andes.extensions.device.mgt.jaxrs;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class ApiOriginFilter implements Filter {
+
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+ HttpServletResponse res = (HttpServletResponse) response;
+ res.addHeader("Access-Control-Allow-Origin", "*");
+ res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
+ res.addHeader("Access-Control-Allow-Headers", "Content-Type");
+ chain.doFilter(request, response);
+ }
+
+ public void destroy() {
+ //do nothing
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ //do nothing
+ }
+
+}
diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/ErrorListItem.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/ErrorListItem.java
new file mode 100644
index 000000000..ebd09a021
--- /dev/null
+++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/ErrorListItem.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ *
+ */
+package org.wso2.carbon.andes.extensions.device.mgt.jaxrs.beans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+
+@ApiModel(description = "")
+public class ErrorListItem {
+
+ @NotNull
+ private String code = null;
+ @NotNull
+ private String message = null;
+
+ @ApiModelProperty(required = true, value = "")
+ @JsonProperty("code")
+ public String getCode() {
+ return code;
+ }
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public ErrorListItem() {}
+
+ public ErrorListItem(String code, String msg) {
+ this.code = code;
+ this.message = msg;
+ }
+
+
+ /**
+ * Description about individual errors occurred
+ **/
+ @ApiModelProperty(required = true, value = "Description about individual errors occurred")
+ @JsonProperty("message")
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("errorItem {\n");
+
+ sb.append(" code: ").append(code).append("\n");
+ sb.append(" message: ").append(message).append("\n");
+ sb.append("}\n");
+ return sb.toString();
+ }
+
+}
diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/ErrorResponse.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/ErrorResponse.java
new file mode 100644
index 000000000..b8e090d38
--- /dev/null
+++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/ErrorResponse.java
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ *
+ */
+package org.wso2.carbon.andes.extensions.device.mgt.jaxrs.beans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel(description = "")
+public class ErrorResponse {
+
+ private Long code = null;
+ private String message = null;
+ private String description = null;
+ private String moreInfo = null;
+ private List errorItems = new ArrayList<>();
+
+ public ErrorResponse() {
+ }
+
+ @JsonProperty(value = "code")
+ @ApiModelProperty(required = true, value = "")
+ public Long getCode() {
+ return code;
+ }
+
+ public void setCode(Long code) {
+ this.code = code;
+ }
+
+ @JsonProperty(value = "message")
+ @ApiModelProperty(required = true, value = "ErrorResponse message.")
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @JsonProperty(value = "description")
+ @ApiModelProperty(value = "A detail description about the error message.")
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @JsonProperty(value = "moreInfo")
+ @ApiModelProperty(value = "Preferably an url with more details about the error.")
+ public String getMoreInfo() {
+ return moreInfo;
+ }
+
+ public void setMoreInfo(String moreInfo) {
+ this.moreInfo = moreInfo;
+ }
+
+ public void addErrorListItem(ErrorListItem item) {
+ this.errorItems.add(item);
+ }
+
+ /**
+ * If there are more than one error list them out. \nFor example, list out validation errors by each field.
+ */
+ @JsonProperty(value = "errorItems")
+ @ApiModelProperty(value = "If there are more than one error list them out. \n" +
+ "For example, list out validation errors by each field.")
+ public List getErrorItems() {
+ return errorItems;
+ }
+
+ public void setErrorItems(List error) {
+ this.errorItems = error;
+ }
+
+ @Override
+ public String toString() {
+// StringBuilder sb = new StringBuilder();
+// sb.append("{");
+// boolean cont = false;
+// if (code != null) {
+// cont = true;
+// sb.append(" \"code\": ").append(code);
+// }
+// if (message != null) {
+// if (cont) {
+// sb.append(",");
+// }
+// cont = true;
+// sb.append(" \"message\": \"").append(message).append("\"");
+// }
+// if (description != null) {
+// if (cont) {
+// sb.append(",");
+// }
+// cont = true;
+// sb.append(" \"description\": ").append(description).append("\"");
+// }
+// if (moreInfo != null) {
+// if (cont) {
+// sb.append(",");
+// }
+// cont = true;
+// sb.append(" \"moreInfo\": \"").append(moreInfo).append("\"");
+// }
+// if (error != null && error.size() > 0) {
+// if (cont) {
+// sb.append(",");
+// }
+// sb.append(" \"errorItems\": ").append(error);
+// }
+// sb.append("}");
+// return sb.toString();
+ return null;
+ }
+
+ public static class ErrorResponseBuilder {
+
+ private Long code = null;
+ private String message = null;
+ private String description = null;
+ private String moreInfo = null;
+ private List error;
+
+
+ public ErrorResponseBuilder() {
+ this.error = new ArrayList<>();
+ }
+
+ public ErrorResponseBuilder setCode(long code) {
+ this.code = code;
+ return this;
+ }
+
+ public ErrorResponseBuilder setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public ErrorResponseBuilder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public ErrorResponseBuilder setMoreInfo(String moreInfo) {
+ this.moreInfo = moreInfo;
+ return this;
+ }
+
+ public ErrorResponseBuilder addErrorItem(String code, String msg) {
+ ErrorListItem item = new ErrorListItem();
+ item.setCode(code);
+ item.setMessage(msg);
+ this.error.add(item);
+ return this;
+ }
+
+ public ErrorResponse build() {
+ ErrorResponse errorResponse = new ErrorResponse();
+ errorResponse.setCode(code);
+ errorResponse.setMessage(message);
+ errorResponse.setErrorItems(error);
+ errorResponse.setDescription(description);
+ errorResponse.setMoreInfo(moreInfo);
+ return errorResponse;
+ }
+ }
+
+}
+
+
diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/Scope.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/Scope.java
new file mode 100644
index 000000000..171fe7726
--- /dev/null
+++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/beans/Scope.java
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.wso2.carbon.andes.extensions.device.mgt.jaxrs.beans;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Scope", description = "Template of the authorization scope")
+public class Scope {
+
+ @ApiModelProperty(name = "scope key", value = "An unique string as a key.", required = true)
+ private String key;
+
+ @ApiModelProperty(name = "scope name", value = "Scope name.", required = true)
+ private String name;
+
+ @ApiModelProperty(name = "roles", value = "List of roles to be associated with the scope", required = true)
+ private String roles;
+
+ @ApiModelProperty(name = "scope description", value = "A description of the scope", required = true)
+ private String description;
+
+ public Scope() {
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRoles() {
+ return this.roles;
+ }
+
+ public void setRoles(String roles) {
+ this.roles = roles;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/common/GsonMessageBodyHandler.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/common/GsonMessageBodyHandler.java
new file mode 100644
index 000000000..804244945
--- /dev/null
+++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/common/GsonMessageBodyHandler.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.andes.extensions.device.mgt.jaxrs.common;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import java.io.*;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+@Provider
+@Produces(APPLICATION_JSON)
+@Consumes(APPLICATION_JSON)
+public class GsonMessageBodyHandler implements MessageBodyWriter