http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java
deleted file mode 100644
index 828fa4d..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.definition;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.util.ArrayList;
-import java.util.List;
-
-@XmlRootElement(name="applications")
-public class ApplicationBean {
-    private String appId;
-    private List<ClusterBean> clusters;
-
-    public ApplicationBean(){
-        this.clusters = new ArrayList<ClusterBean>();
-    }
-
-    public ApplicationBean(String appId){
-        this.appId = appId;
-        this.clusters = new ArrayList<ClusterBean>();
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-
-    public void setAppId(String appId) {
-        this.appId = appId;
-    }
-
-    public List<ClusterBean> getClusters() {
-        return clusters;
-    }
-
-    public ClusterBean getCluster(String clusterId){
-
-        for(ClusterBean clusterBean : clusters){
-            if(clusterBean.getClusterId().equals(clusterId)){
-                return clusterBean;
-            }
-        }
-
-        return null;
-    }
-
-    public void setClusters(List<ClusterBean> clusters) {
-        this.clusters = clusters;
-    }
-
-    public void addCluster(ClusterBean cluster){
-        this.clusters.add(cluster);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java
deleted file mode 100644
index 1875434..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.stratos.metadataservice.definition;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "cartridgeMetaData")
-public class CartridgeMetaData {
-       public String applicationName;
-
-       public String displayName;
-
-       public String description;
-
-       public String type;
-
-       public String provider;
-
-       public String host;
-
-       public String version;
-
-       public String properties;
-
-       @Override
-       public String toString() {
-
-               return "applicationName: " + applicationName + ", displayName: 
" + displayName +
-                      ", description: " + description + ", type: " + type + ", 
provider: " + provider +
-                      ", host: " + host + ", Version: " + version + ", 
properties: " + properties;
-       }
-
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java
deleted file mode 100644
index 5c5187a..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.apache.stratos.metadataservice.definition;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.util.ArrayList;
-import java.util.List;
-
-@XmlRootElement(name="clusters")
-public class ClusterBean {
-
-    private String clusterId;
-    private List<NewProperty> properties;
-
-    public ClusterBean(){
-        this.setProperties(new ArrayList<NewProperty>());
-    }
-
-    public ClusterBean(String id){
-        this.setClusterId(id);
-        this.setProperties(new ArrayList<NewProperty>());
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public void setClusterId(String clusterId) {
-        this.clusterId = clusterId;
-    }
-
-    public List<NewProperty> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(List<NewProperty> properties) {
-        this.properties = properties;
-    }
-
-    public void addProperty(NewProperty property){
-        this.properties.add(property);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java
deleted file mode 100644
index 552d29f..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.definition;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementRef;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-@XmlRootElement(name="properties")
-public class NewProperty implements Serializable{
-
-    private String key;
-    private List<String> values = new ArrayList<String>();
-
-    public NewProperty(){}
-    public NewProperty(String key, String value){
-        this.key=key;
-        this.values.add(value);
-    }
-    
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public String[] getValues(){
-        String[] values = new String[this.values.size()];
-        values = this.values.toArray(values);
-        return values;
-    }
-
-    public void setValues(String[] values) {
-        this.values.addAll(Arrays.asList(values));
-    }
-
-
-    public void setValues(String value) {
-        this.values.add(value);
-    }
-
-    public void addValue(String value){
-        this.values.add(value);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java
deleted file mode 100644
index 1ff9586..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.definition;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "properties")
-public class PropertyBean {
-
-       private String hostname;
-
-       private String username;
-       private String password;
-
-       public String getHostname() {
-               return hostname;
-       }
-
-       public void setHostname(String hostname) {
-               this.hostname = hostname;
-       }
-
-       public String getUsername() {
-               return username;
-       }
-
-       public void setUsername(String username) {
-               this.username = username;
-       }
-
-       public String getPassword() {
-               return password;
-       }
-
-       public void setPassword(String password) {
-               this.password = password;
-       }
-
-       @Override
-       public String toString() {
-               return " [hostname: " + getHostname() + ", username: " + 
getUsername() + ", password: " + getPassword() +
-                               "]";
-       }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java
deleted file mode 100644
index 8883ab1..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.stratos.metadataservice.exception;
-
-
-public class MetadataException extends Exception {
-
-    public MetadataException(String message, Throwable cause) {
-        super(message, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java
deleted file mode 100644
index df43cc0..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.exception;
-
-import javax.ws.rs.core.Response;
-
-public class RestAPIException extends Exception {
-
-       private static final long serialVersionUID = 1L;
-
-       private String message;
-       private Response.Status httpStatusCode;
-
-       public RestAPIException() {
-               super();
-       }
-
-       public RestAPIException(String message, Throwable cause) {
-               super(message, cause);
-               this.message = message;
-       }
-
-       public RestAPIException(Response.Status httpStatusCode, String message, 
Throwable cause) {
-               super(message, cause);
-               this.message = message;
-               this.httpStatusCode = httpStatusCode;
-       }
-
-       public RestAPIException(String message) {
-               super(message);
-               this.message = message;
-       }
-
-       public RestAPIException(Response.Status httpStatusCode, String message) 
{
-               super(message);
-               this.message = message;
-               this.httpStatusCode = httpStatusCode;
-       }
-
-       public RestAPIException(Throwable cause) {
-               super(cause);
-       }
-
-       @Override
-       public String getMessage() {
-               return message;
-       }
-
-       public Response.Status getHTTPStatusCode() {
-               return httpStatusCode;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java
deleted file mode 100644
index 93bf904..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.handlers;
-
-import java.util.List;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.message.Message;
-import org.apache.stratos.metadataservice.context.AuthenticationContext;
-
-public abstract class AbstractAuthenticationAuthorizationHandler implements 
RequestHandler {
-       private final Log log = 
LogFactory.getLog(AbstractAuthenticationAuthorizationHandler.class);
-
-       @Override
-       public Response handleRequest(Message message, ClassResourceInfo 
classResourceInfo) {
-               HttpHeaders headers = new HttpHeadersImpl(message);
-               List<String> authHeader = 
headers.getRequestHeader(HttpHeaders.AUTHORIZATION);
-               if (log.isDebugEnabled()) {
-                       log.debug("Executing " + this.getClass());
-               }
-               if (!AuthenticationContext.isAthenticated() && authHeader != 
null &&
-                   authHeader.size() > 0 && 
canHandle(authHeader.get(0).trim().split(" ")[0])) {
-                       return handle(message, classResourceInfo);
-               }
-               // give the control to the next handler
-               return null;
-
-       }
-
-       protected abstract boolean canHandle(String authHeaderPrefix);
-
-       protected abstract Response handle(Message message, ClassResourceInfo 
classResourceInfo);
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java
deleted file mode 100644
index da50e3e..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.handlers;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.message.Message;
-import org.apache.stratos.metadataservice.Utils;
-import org.apache.stratos.metadataservice.context.AuthenticationContext;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-
-/*
- * authenticate an incoming request using the session availability. Session is
- * first established using the
- * basic auth authentication. This handler will be the last to get executed in
- * the current handler chain. Hence failure
- * too provide a session would result in an authentication failure.
- */
-public class CookieBasedAuthenticationHandler implements RequestHandler {
-       private final Log log = 
LogFactory.getLog(CookieBasedAuthenticationHandler.class);
-
-       @Override
-       public Response handleRequest(Message message, ClassResourceInfo 
classResourceInfo) {
-               if (AuthenticationContext.isAthenticated()) {
-                       return null;
-               }
-
-               HttpServletRequest httpServletRequest = (HttpServletRequest) 
message.get("HTTP.REQUEST");
-               HttpSession httpSession = httpServletRequest.getSession(false);
-               if (httpSession != null && isUserLoggedIn(httpSession)) { // if 
sesion
-                                                                             
// is
-                                                                             
// avaialble
-                       String userName = (String) 
httpSession.getAttribute("userName");
-                       String tenantDomain = (String) 
httpSession.getAttribute("tenantDomain");
-                       int tenantId = (Integer) 
httpSession.getAttribute("tenantId");
-                       // the following will get used by the authorization 
handler..
-                       PrivilegedCarbonContext carbonContext =
-                                                               
PrivilegedCarbonContext.getThreadLocalCarbonContext();
-                       carbonContext.setUsername(userName);
-                       carbonContext.setTenantDomain(tenantDomain);
-                       carbonContext.setTenantId(tenantId);
-
-                       AuthenticationContext.setAuthenticated(true);
-                       if (log.isDebugEnabled()) {
-                               log.debug("authenticated using the " +
-                                         
CookieBasedAuthenticationHandler.class.getName() + "for username  :" +
-                                         userName + "tenantDomain : " + 
tenantDomain + " tenantId : " + tenantId);
-                       }
-                       return null;
-
-               }
-               return 
Response.status(Response.Status.FORBIDDEN).type(MediaType.APPLICATION_JSON)
-                              .entity(Utils.buildMessage("The endpoint 
requires authentication")).build();
-       }
-
-       /*
-        * if the userName and tenantDomain is present in the session, we 
conclude
-        * this as an authenticated session.
-        * Thos params get set by the AuthenticationAdmin endpoint.
-        */
-       private boolean isUserLoggedIn(HttpSession httpSession) {
-               String userName = (String) httpSession.getAttribute("userName");
-               String tenantDomain = (String) 
httpSession.getAttribute("tenantDomain");
-               Integer tenantId = (Integer) 
httpSession.getAttribute("tenantId");
-               if (userName != null && tenantDomain != null && tenantId != 
null) {
-                       return true;
-               }
-               return false;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java
deleted file mode 100644
index 0731c99..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.handlers;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-
-import org.apache.stratos.metadataservice.Utils;
-import org.apache.stratos.metadataservice.exception.RestAPIException;
-
-public class CustomExceptionMapper implements 
ExceptionMapper<RestAPIException> {
-       @Override
-       public Response toResponse(RestAPIException restAPIException) {
-               // if no specific error message specified, spitting out a 
generaic error
-               // message
-               String errorMessage =
-                                     (restAPIException.getMessage() != null)
-                                                                            ? 
restAPIException.getMessage()
-                                                                            : 
"Error while fullfilling the request";
-               // if no specific error specified we are throwing the bad 
request http
-               // status code by default
-               Response.Status httpStatus =
-                                            
(restAPIException.getHTTPStatusCode() != null)
-                                                                               
           ? restAPIException.getHTTPStatusCode()
-                                                                               
           : Response.Status.BAD_REQUEST;
-               return 
Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON)
-                              
.entity(Utils.buildMessage(httpStatus.getStatusCode(), errorMessage))
-                              .build();
-       }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java
deleted file mode 100644
index fd0e2a5..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.stratos.metadataservice.handlers;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadataservice.Utils;
-
-public class CustomThrowableExceptionMapper implements 
ExceptionMapper<Throwable> {
-       private static Log log = 
LogFactory.getLog(CustomThrowableExceptionMapper.class);
-
-       @Override
-       public Response toResponse(Throwable throwable) {
-               if (log.isDebugEnabled()) {
-                       log.debug("Internal server error", throwable);
-               }
-
-               return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
-                              .type(MediaType.APPLICATION_JSON)
-                              
.entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
-                                                         "Internal server 
error")).build();
-       }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java
deleted file mode 100644
index 4d2fadb..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.handlers;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadataservice.Utils;
-
-/*
- * This class maps any exception thrown by the server, which is not mapped by a
- * specifi exception mapper
- * in to an appropriate format
- */
-public class GenericExceptionMapper implements 
ExceptionMapper<WebApplicationException> {
-       private static Log log = 
LogFactory.getLog(GenericExceptionMapper.class);
-
-       @Override
-       public Response toResponse(WebApplicationException 
webApplicationException) {
-               if (log.isDebugEnabled()) {
-                       log.debug("Internal erver error", 
webApplicationException);
-               }
-               // if no specific error message specified, spitting out a 
generaic error
-               // message
-               String errorMessage =
-                                     (webApplicationException.getMessage() != 
null)
-                                                                               
    ? webApplicationException.getMessage()
-                                                                               
    : "Internal server error";
-               return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
-                              .type(MediaType.APPLICATION_JSON)
-                              
.entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
-                                                         
errorMessage)).build();
-       }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java
deleted file mode 100644
index e265e7e..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.handlers;
-
-import com.nimbusds.jose.JWSVerifier;
-import com.nimbusds.jose.crypto.RSASSAVerifier;
-import com.nimbusds.jwt.SignedJWT;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.message.Message;
-import org.apache.stratos.metadataservice.context.AuthenticationContext;
-import org.wso2.carbon.base.MultitenantConstants;
-import org.wso2.carbon.core.util.KeyStoreManager;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import java.security.interfaces.RSAPublicKey;
-
-
-/**
- * This class responsible for OAuth based authentication/authorization. A 
client
- * has to bring a valid OAuth token from a
- * a OAuth provider. This class intercept the request and calls the
- * OAuthTokenValidation endpoint of the provider.
- */
-public class OAuthHandler extends AbstractAuthenticationAuthorizationHandler {
-    public static final String BEARER = "Bearer ";
-    public static final String APPLICATION = "application";
-    private static Log log = LogFactory.getLog(OAuthHandler.class);
-    private static String SUPPORTED_AUTHENTICATION_TYPE = "Bearer";
-    private static String oauthValidationEndpoint;
-    private static String username;
-    private static String password;
-
-    public void setOauthValidationEndpoint(String oauthValidationEndpoint) {
-        OAuthHandler.oauthValidationEndpoint = oauthValidationEndpoint;
-    }
-
-    public void setUsername(String username) {
-        OAuthHandler.username = username;
-    }
-
-    public void setPassword(String password) {
-        OAuthHandler.password = password;
-    }
-
-    @Override
-    public boolean canHandle(String authHeaderPrefix) {
-        return SUPPORTED_AUTHENTICATION_TYPE.equals(authHeaderPrefix);
-    }
-
-    @Override
-    public Response handle(Message message, ClassResourceInfo 
classResourceInfo) {
-        try {
-            HttpHeaders httpHeaders = new HttpHeadersImpl(message);
-            String header = 
httpHeaders.getRequestHeaders().getFirst("Authorization");
-            // if the authorization token has Bearer..
-            if (header.startsWith(BEARER)) {
-                String accessToken = header.substring(7).trim();
-                boolean valid;
-                String appId = extractAppIdFromIdToken(accessToken);
-                String requestUrl = (String) message.get(Message.REQUEST_URI);
-                String basePath = (String) message.get(Message.BASE_PATH);
-                String requestedAppId = 
extractApplicationIdFromUrl(requestUrl, basePath);
-
-                if(org.apache.commons.lang3.StringUtils.isEmpty(appId) || 
org.apache.commons.lang3.StringUtils.isEmpty(requestedAppId)){
-                    valid = false;
-                }else{
-                    valid = appId.equals(requestedAppId);
-                }
-
-                if (!valid) {
-                    return Response.status(Response.Status.FORBIDDEN).build();
-                }
-            }
-        } catch (Exception e) {
-            log.error("Error while validating access token", e);
-            return Response.status(Response.Status.FORBIDDEN).build();
-        }
-
-        AuthenticationContext.setAuthenticated(true);
-        return null;
-    }
-
-    private String extractApplicationIdFromUrl(String url, String basePath) {
-        String appId = null;
-        String segments[] = url.split("/");
-        for (int i = 0; i < segments.length; i++) {
-            if (APPLICATION.equals(segments[i])) {
-                appId = segments[i + 1];
-                break;
-            }
-        }
-        return appId;
-    }
-
-    private String extractAppIdFromIdToken(String token) {
-        String appId = null;
-        KeyStoreManager keyStoreManager = 
KeyStoreManager.getInstance(MultitenantConstants.SUPER_TENANT_ID);
-        try {
-            keyStoreManager.getDefaultPrimaryCertificate();
-            JWSVerifier verifier =
-                    new RSASSAVerifier((RSAPublicKey) 
keyStoreManager.getDefaultPublicKey());
-            SignedJWT jwsObject = SignedJWT.parse(token);
-            if (jwsObject.verify(verifier)) {
-               appId = jwsObject.getJWTClaimsSet().getStringClaim("appId");
-            }
-
-        } catch (Exception e) {
-            String message = "Could not extract application id from id token";
-            log.error(message, e);
-        }
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java
deleted file mode 100644
index fd83b8e..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.handlers;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.configuration.security.AuthorizationPolicy;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.security.SecurityContext;
-import org.apache.stratos.metadataservice.ServiceHolder;
-import org.apache.stratos.metadataservice.Utils;
-import org.apache.stratos.metadataservice.context.AuthenticationContext;
-import org.apache.stratos.metadataservice.security.StratosSecurityContext;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.core.util.AnonymousSessionUtil;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.user.api.UserRealm;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
-
-/**
- * Here we are doing the request authentication within a {@link 
RequestHandler}.
- * The request handlers
- * are get invoked just before the actual method invocation. This 
authentication
- * handler make use
- * of HTTP basic auth headers as the authentication mechanism.
- */
-public class StratosAuthenticationHandler extends 
AbstractAuthenticationAuthorizationHandler {
-       private static Log log = 
LogFactory.getLog(StratosAuthenticationHandler.class);
-       private static String SUPPORTED_AUTHENTICATION_TYPE = "Basic";
-
-       @Override
-       public boolean canHandle(String authHeaderPrefix) {
-               return SUPPORTED_AUTHENTICATION_TYPE.equals(authHeaderPrefix);
-       }
-
-       /**
-        * Authenticate the user against the user store. Once authenticate, 
populate
-        * the {@link org.wso2.carbon.context.CarbonContext} to be used by the
-        * downstream code.
-        * 
-        * @param message
-        * @param classResourceInfo
-        * @return
-        */
-       @Override
-       public Response handle(Message message, ClassResourceInfo 
classResourceInfo) {
-               // If Mutual SSL is enabled
-               HttpServletRequest request = (HttpServletRequest) 
message.get("HTTP.REQUEST");
-               Object certObject = 
request.getAttribute("javax.servlet.request.X509Certificate");
-
-               AuthorizationPolicy policy = 
message.get(AuthorizationPolicy.class);
-               String username = policy.getUserName().trim();
-               String password = policy.getPassword().trim();
-
-               // sanity check
-               if ((username == null) || username.equals("")) {
-                       log.error("username is seen as null/empty values.");
-                       return Response.status(Response.Status.UNAUTHORIZED)
-                                      .header("WWW-Authenticate", 
"Basic").type(MediaType.APPLICATION_JSON)
-                                      .entity(Utils.buildMessage("Username 
cannot be null")).build();
-               } else if (certObject == null && ((password == null) || 
password.equals(""))) {
-                       log.error("password is seen as null/empty values.");
-                       return Response.status(Response.Status.UNAUTHORIZED)
-                                      .header("WWW-Authenticate", 
"Basic").type(MediaType.APPLICATION_JSON)
-                                      .entity(Utils.buildMessage("password 
cannot be null")).build();
-               }
-
-               try {
-                       RealmService realmService = 
ServiceHolder.getRealmService();
-                       RegistryService registryService = 
ServiceHolder.getRegistryService();
-                       String tenantDomain = 
MultitenantUtils.getTenantDomain(username);
-                       int tenantId = 
realmService.getTenantManager().getTenantId(tenantDomain);
-
-                       UserRealm userRealm = null;
-                       if (certObject == null) {
-                               userRealm =
-                                           
AnonymousSessionUtil.getRealmByTenantDomain(registryService,
-                                                                               
        realmService, tenantDomain);
-                               if (userRealm == null) {
-                                       log.error("Invalid domain or 
unactivated tenant login");
-                                       // is this the correct HTTP code for 
this scenario ? (401)
-                                       return 
Response.status(Response.Status.UNAUTHORIZED)
-                                                      
.header("WWW-Authenticate", "Basic")
-                                                      
.type(MediaType.APPLICATION_JSON)
-                                                      
.entity(Utils.buildMessage("Tenant not found")).build();
-                               }
-                       }
-                       username = 
MultitenantUtils.getTenantAwareUsername(username);
-                       if (certObject != null ||
-                           
userRealm.getUserStoreManager().authenticate(username, password)) { // if
-                                                                               
                    // authenticated
-
-                               // setting the correct tenant info for 
downstream code..
-                               PrivilegedCarbonContext carbonContext =
-                                                                       
PrivilegedCarbonContext.getThreadLocalCarbonContext();
-                               carbonContext.setTenantDomain(tenantDomain);
-                               carbonContext.setTenantId(tenantId);
-                               carbonContext.setUsername(username);
-                               // populate the secuirtyContext of 
authenticated user
-                               SecurityContext securityContext = new 
StratosSecurityContext(username);
-                               message.put(SecurityContext.class, 
securityContext);
-
-                               // set the authenticated flag and let the 
request to continue
-                               AuthenticationContext.setAuthenticated(true);
-                               if (log.isDebugEnabled()) {
-                                       log.debug("authenticated using the " +
-                                                 
CookieBasedAuthenticationHandler.class.getName() + "for username  :" +
-                                                 username + "tenantDomain : " 
+ tenantDomain + " tenantId : " +
-                                                 tenantId);
-                               }
-                               return null;
-                       } else {
-                               log.warn("unable to authenticate the request");
-                               // authentication failed, request the 
authetication, add the
-                               // realm name if needed to the value of 
WWW-Authenticate
-                               return 
Response.status(Response.Status.UNAUTHORIZED)
-                                              .header("WWW-Authenticate", 
"Basic")
-                                              .type(MediaType.APPLICATION_JSON)
-                                              
.entity(Utils.buildMessage("Authentication failed. Please "
-                                                                         + 
"check your username/password"))
-                                              .build();
-                       }
-               } catch (Exception exception) {
-                       log.error("Authentication failed", exception);
-                       // server error in the eyes of the client. Hence 5xx 
HTTP code.
-                       return 
Response.status(Response.Status.INTERNAL_SERVER_ERROR)
-                                      .type(MediaType.APPLICATION_JSON)
-                                      .entity(Utils.buildMessage("Unexpected 
error. Please contact the system admin"))
-                                      .build();
-               }
-
-       }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java
deleted file mode 100644
index 46f1fd0..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.handlers;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.common.util.ClassHelper;
-import org.apache.cxf.frontend.MethodDispatcher;
-import org.apache.cxf.interceptor.security.AccessDeniedException;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.service.Service;
-import org.apache.cxf.service.model.BindingOperationInfo;
-import org.apache.stratos.metadataservice.Utils;
-import org.apache.stratos.metadataservice.context.AuthenticationContext;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.user.api.AuthorizationManager;
-import org.wso2.carbon.user.api.UserRealm;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * {@link StratosAuthorizingHandler} authorize resource requests. It collects
- * expected permission
- * details using annotations present in the service bean. This particular
- * implementation is inspired
- * by the {@link org.apache.cxf.jaxrs.security.SimpleAuthorizingFilter}
- */
-public class StratosAuthorizingHandler implements RequestHandler {
-       private final Log log = 
LogFactory.getLog(StratosAuthorizingHandler.class);
-
-       private static String SUPPORTED_AUTHENTICATION_TYPE = "Basic";
-       private static final String AUTHORIZATION_ANNOTATION_CLASS_NAME =
-                                                                         
"org.apache.stratos.metadataservice.annotation.AuthorizationAction";
-       private static final String TENANT_ANNOTATION_CLASS_NAME =
-                                                                  
"org.apache.stratos.metadataservice.annotation.SuperTenantService";
-       private static final String ACTION_ON_RESOURCE = "ui.execute";
-       private static final Set<String> SKIP_METHODS;
-       private Map<String, String> authorizationActionMap = 
Collections.emptyMap();
-       private Set<String> superTenantServiceSet = Collections.emptySet();
-
-       static {
-               SKIP_METHODS = new HashSet<String>();
-               SKIP_METHODS.addAll(Arrays.asList(new String[] { "wait", 
"notify", "notifyAll", "equals",
-                                                               "toString", 
"hashCode" }));
-       }
-
-       @Override
-       public Response handleRequest(Message message, ClassResourceInfo 
resourceClass) {
-               try {
-                       AuthenticationContext.setAuthenticated(false); // TODO 
: fix this
-                                                                      // 
properly
-                       String userName = 
CarbonContext.getThreadLocalCarbonContext().getUsername();
-                       String tenantDomain = 
CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
-                       int tenantId = 
CarbonContext.getThreadLocalCarbonContext().getTenantId();
-                       if (log.isDebugEnabled()) {
-                               log.debug("authorizing the action using" +
-                                         
StratosAuthorizingHandler.class.getName());
-                               log.debug("username :" + userName);
-                               log.debug("tenantDomain" + tenantDomain);
-                               log.debug("tenantId :" + tenantId);
-                       }
-                       Method targetMethod = getTargetMethod(message);
-                       if (!authorize(userName, tenantDomain, tenantId, 
targetMethod)) {
-                               log.warn("User :" + userName + "trying to 
perform unauthrorized action" +
-                                        " against the resource :" + 
targetMethod);
-                               return 
Response.status(Response.Status.FORBIDDEN)
-                                              .type(MediaType.APPLICATION_JSON)
-                                              .entity(Utils.buildMessage("The 
user does not have required permissions to "
-                                                                         + 
"perform this operation")).build();
-                       }
-                       return null;
-
-               } catch (Exception exception) {
-                       log.error("Unexpected error occured while REST api, 
authorization process", exception);
-                       return 
Response.status(Response.Status.INTERNAL_SERVER_ERROR)
-                                      .type(MediaType.APPLICATION_JSON)
-                                      .entity(Utils.buildMessage("Unexpected 
error. Please contact the system admin"))
-                                      .build();
-               }
-       }
-
-       private boolean authorize(String userName, String tenantDomain, int 
tenantId,
-                                 Method targetMethod) throws Exception {
-               // first we try to see whether this is a super.tenant only 
operation
-               if (superTenantServiceSet.contains(targetMethod.getName()) &&
-                   !isCurrentUserSuperTenant(tenantDomain, tenantId)) {
-                       return false;
-               }
-               // authorize using permissionString given as annotation in the 
service
-               // class
-               String permissionString = 
authorizationActionMap.get(targetMethod.getName());
-
-               // get the authorization manager for this tenant..
-               UserRealm userRealm = 
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm();
-               AuthorizationManager authorizationManager = 
userRealm.getAuthorizationManager();
-
-               boolean isAuthorized =
-                                      isAuthorized(authorizationManager, 
userName, permissionString,
-                                                   ACTION_ON_RESOURCE);
-               return isAuthorized;
-
-       }
-
-       private boolean isCurrentUserSuperTenant(String tenantDomain, int 
tenantId) {
-               if 
(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain) &&
-                   MultitenantConstants.SUPER_TENANT_ID == tenantId) {
-                       return true;
-               }
-               return false;
-       }
-
-       private boolean isAuthorized(AuthorizationManager authorizationManager, 
String username,
-                                    String permissionString, String action) 
throws UserStoreException {
-               boolean isAuthorized = false;
-               String[] resourceIds = permissionString.trim().split(",");
-               for (String resourceId : resourceIds) {
-                       if (authorizationManager.isUserAuthorized(username, 
resourceId, action)) {
-                               isAuthorized = true;
-                               break;
-                       }
-               }
-               return isAuthorized;
-       }
-
-       /**
-        * Here we are getting the target invocation method. The method get set 
as a
-        * properties in the
-        * message by the
-        * {@link org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor}
-        * 
-        * @param message
-        *            incoming message
-        * @return
-        */
-       protected Method getTargetMethod(Message message) {
-               BindingOperationInfo bop = 
message.getExchange().get(BindingOperationInfo.class);
-               if (bop != null) {
-                       MethodDispatcher md =
-                                             (MethodDispatcher) 
message.getExchange().get(Service.class)
-                                                                       
.get(MethodDispatcher.class.getName());
-                       return md.getMethod(bop);
-               }
-               Method method = (Method) 
message.get("org.apache.cxf.resource.method");
-               if (method != null) {
-                       return method;
-               }
-               log.error("The requested resource is not found. Please check 
the resource path etc..");
-               throw new AccessDeniedException("Method is not available : 
Unauthorized");
-       }
-
-       /**
-        * The instance of the secured bean get injected by the IOC framework
-        * 
-        * @param securedObject
-        */
-       public void setSecuredObject(Object securedObject) {
-               Class<?> clazz = ClassHelper.getRealClass(securedObject);
-               authorizationActionMap = getAuthorizationActionMap(clazz);
-               superTenantServiceSet = getSuperTenantServiceSet(clazz);
-
-       }
-
-       private Set<String> getSuperTenantServiceSet(Class<?> clazz) {
-               Set<String> superTenantServiceSet = new HashSet<String>();
-               findSuperTenantServices(clazz, superTenantServiceSet);
-               return superTenantServiceSet;
-       }
-
-       private Map<String, String> getAuthorizationActionMap(Class<?> clazz) {
-               Map<String, String> authorizationActionMap = new 
HashMap<String, String>();
-               findAuthorizationActions(clazz, authorizationActionMap);
-               return authorizationActionMap;
-       }
-
-       /**
-        * Goes through the class hierarchy and find the authorization 
annotations
-        * attached to a certain
-        * method.
-        * 
-        * @param clazz
-        *            class to be scanned
-        * @param authorizationActionMap
-        *            the map to be populated
-        */
-       private void findAuthorizationActions(Class<?> clazz, Map<String, 
String> authorizationActionMap) {
-               if (clazz == null || clazz == Object.class) {
-                       return;
-               }
-               String classAuthorizationActionsAllowed =
-                                                         
getAuthorizationActions(clazz.getAnnotations(),
-                                                                               
  AUTHORIZATION_ANNOTATION_CLASS_NAME);
-               for (Method m : clazz.getMethods()) {
-                       if (SKIP_METHODS.contains(m.getName())) {
-                               continue;
-                       }
-                       String methodAuthorizationActionsAllowed =
-                                                                  
getAuthorizationActions(m.getAnnotations(),
-                                                                               
           AUTHORIZATION_ANNOTATION_CLASS_NAME);
-                       String authorizationActions =
-                                                     
methodAuthorizationActionsAllowed != null
-                                                                               
               ? methodAuthorizationActionsAllowed
-                                                                               
               : classAuthorizationActionsAllowed;
-                       if (authorizationActions != null) {
-                               authorizationActionMap.put(m.getName(), 
authorizationActions);
-                       }
-               }
-               if (!authorizationActionMap.isEmpty()) {
-                       return;
-               }
-
-               findAuthorizationActions(clazz.getSuperclass(), 
authorizationActionMap);
-
-               if (!authorizationActionMap.isEmpty()) {
-                       return;
-               }
-
-               for (Class<?> interfaceCls : clazz.getInterfaces()) {
-                       findAuthorizationActions(interfaceCls, 
authorizationActionMap);
-               }
-       }
-
-       /**
-        * Goes through the class hierarchy and figure out the supertenant
-        * annotations coupled with operations/methods.
-        * 
-        * @param clazz
-        * @param superTenantServiceSet
-        */
-       private void findSuperTenantServices(Class<?> clazz, Set<String> 
superTenantServiceSet) {
-               if (clazz == null || clazz == Object.class) {
-                       return;
-               }
-               for (Method m : clazz.getMethods()) {
-                       if (SKIP_METHODS.contains(m.getName())) {
-                               continue;
-                       }
-                       boolean isSuperTenantService =
-                                                      
getSuperTenantServices(m.getAnnotations(),
-                                                                             
TENANT_ANNOTATION_CLASS_NAME);
-                       if (isSuperTenantService) {
-                               superTenantServiceSet.add(m.getName());
-                       }
-               }
-               if (!superTenantServiceSet.isEmpty()) {
-                       return;
-               }
-
-               findSuperTenantServices(clazz.getSuperclass(), 
superTenantServiceSet);
-
-               if (!superTenantServiceSet.isEmpty()) {
-                       return;
-               }
-
-               for (Class<?> interfaceCls : clazz.getInterfaces()) {
-                       findSuperTenantServices(interfaceCls, 
superTenantServiceSet);
-               }
-       }
-
-       private boolean getSuperTenantServices(Annotation[] annotations,
-                                              String 
tenantAnnotationClassName) {
-               for (Annotation ann : annotations) {
-                       if 
(ann.annotationType().getName().equals(tenantAnnotationClassName)) {
-                               try {
-                                       Method valueMethod = 
ann.annotationType().getMethod("value", new Class[] {});
-                                       boolean isSuperTenantService =
-                                                                      
(Boolean) valueMethod.invoke(ann,
-                                                                               
                    new Object[] {});
-                                       return isSuperTenantService;
-                               } catch (Exception ex) {
-                                       // ignore
-                               }
-                               break;
-                       }
-               }
-               return false;
-       }
-
-       private String getAuthorizationActions(Annotation[] annotations,
-                                              String 
authorizationAnnotationClassName) {
-               for (Annotation ann : annotations) {
-                       if 
(ann.annotationType().getName().equals(authorizationAnnotationClassName)) {
-                               try {
-                                       Method valueMethod = 
ann.annotationType().getMethod("value", new Class[] {});
-                                       String[] permissions = (String[]) 
valueMethod.invoke(ann, new Object[] {});
-                                       StringBuilder sb = new StringBuilder();
-                                       for (int i = 0; i < permissions.length; 
i++) {
-                                               sb.append(permissions[i]);
-                                               if (i + 1 < permissions.length) 
{
-                                                       sb.append(",");
-                                               }
-                                       }
-                                       return sb.toString();
-                               } catch (Exception ex) {
-                                       // ignore
-                               }
-                               break;
-                       }
-               }
-               return null;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java
deleted file mode 100644
index dbc8947..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.oauth2;
-
-import java.rmi.RemoteException;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
-import org.wso2.carbon.utils.CarbonUtils;
-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.OAuth2TokenValidationResponseDTO;
-
-/**
- * Service class wrapper for OAuthTokenValidation endpoint.
- */
-public class ValidationServiceClient {
-       private OAuth2TokenValidationServiceStub stub = null;
-       private static final Log log = 
LogFactory.getLog(OAuth2TokenValidationServiceStub.class);
-
-       public ValidationServiceClient(String backendServerURL, String 
username, String password)
-                                                                               
                 throws Exception {
-               String serviceURL = backendServerURL + 
"OAuth2TokenValidationService";
-               try {
-                       stub = new OAuth2TokenValidationServiceStub(serviceURL);
-                       CarbonUtils.setBasicAccessSecurityHeaders(username, 
password, true,
-                                                                 
stub._getServiceClient());
-               } catch (AxisFault e) {
-                       log.error("Error initializing OAuth2 Client");
-                       throw new Exception("Error initializing OAuth Client", 
e);
-               }
-       }
-
-       public OAuth2TokenValidationResponseDTO 
validateAuthenticationRequest(String accessToken)
-                                                                               
                 throws Exception {
-               OAuth2TokenValidationRequestDTO oauthReq = new 
OAuth2TokenValidationRequestDTO();
-               oauthReq.setAccessToken(accessToken);
-               oauthReq.setTokenType(OAuthConstants.BEARER_TOKEN_TYPE);
-               try {
-                       return stub.validate(oauthReq);
-               } catch (RemoteException e) {
-                       log.error("Error while validating OAuth2 request");
-                       throw new Exception("Error while validating OAuth2 
request", e);
-               }
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
deleted file mode 100644
index aef2441..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.registry;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.internal.ServiceReferenceHolder;
-import org.apache.stratos.metadataservice.definition.NewProperty;
-import org.wso2.carbon.registry.api.Registry;
-import org.wso2.carbon.registry.api.RegistryException;
-import org.wso2.carbon.registry.api.Resource;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-import java.util.*;
-
-
-/**
- * Carbon registry implementation
- *
- */
-
-public class CarbonRegistry implements DataStore {
-
-    private static Log log = LogFactory.getLog(CarbonRegistry.class);
-    @Context
-    HttpServletRequest httpServletRequest;
-
-    private static final String mainResource = "/stratos/";
-
-    public CarbonRegistry() {
-    }
-
-
-    /**
-     * Get Properties of clustor
-     * @param applicationName
-     * @param clusterId
-     * @return
-     * @throws RegistryException
-     */
-    public List<NewProperty> getPropertiesOfCluster(String applicationName, 
String clusterId) throws RegistryException {
-        Registry tempRegistry = 
ServiceReferenceHolder.getRegistryService().getRegistry();
-        String resourcePath = mainResource + applicationName + "/" + clusterId;
-        if (!tempRegistry.resourceExists(resourcePath)) {
-            return null;
-            //throw new RegistryException("Cluster does not exist at " + 
resourcePath);
-        }
-        Resource regResource = tempRegistry.get(resourcePath);
-
-        ArrayList<NewProperty> newProperties = new ArrayList<NewProperty>();
-
-        Properties props = regResource.getProperties();
-        Enumeration<?> x = props.propertyNames();
-        while (x.hasMoreElements()) {
-            String key = (String) x.nextElement();
-            List<String> values = regResource.getPropertyValues(key);
-            NewProperty property = new NewProperty();
-            property.setKey(key);
-            String[] valueArr = new String[values.size()];
-            property.setValues(values.toArray(valueArr));
-
-            newProperties.add(property);
-        }
-
-        return newProperties;
-    }
-
-    /**
-     * Add property to cluster
-     * @param applicationId
-     * @param clusterId
-     * @param property
-     * @throws RegistryException
-     */
-    public void addPropertyToCluster(String applicationId, String clusterId, 
NewProperty property) throws RegistryException {
-        Registry tempRegistry = 
ServiceReferenceHolder.getRegistryService().getRegistry();
-        String resourcePath = mainResource + applicationId + "/" + clusterId;
-        Resource regResource = createOrGetResourceforCluster(tempRegistry, 
resourcePath);
-
-        regResource.setProperty(property.getKey(), 
Arrays.asList(property.getValues()));
-        tempRegistry.put(resourcePath, regResource);
-        log.info(String.format("Property %s is added to cluster %s of 
application %s", property.getKey(), clusterId, applicationId));
-
-    }
-
-    /**
-     * Delete the resource identified by the applicationId, if exist.
-     * @param applicationId ID of the application.
-     * @return True if resource exist and able to delete, else false.
-     * @throws RegistryException
-     */
-    public boolean deleteApplication(String applicationId) throws 
RegistryException {
-        if(StringUtils.isBlank(applicationId)){
-            throw new IllegalArgumentException("Application ID can not be 
null");
-        }
-        Registry tempRegistry = 
ServiceReferenceHolder.getRegistryService().getRegistry();
-        String resourcePath = mainResource + applicationId;
-
-        if(tempRegistry.resourceExists(resourcePath)){
-            tempRegistry.delete(resourcePath);
-            log.info(String.format("Application removed from registry %s", 
applicationId));
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Add properties to cluster
-     * @param applicationName
-     * @param clusterId
-     * @param properties
-     * @throws RegistryException
-     */
-    public void addPropertiesToCluster(String applicationName, String 
clusterId, NewProperty[] properties) throws RegistryException {
-        Registry tempRegistry = 
ServiceReferenceHolder.getRegistryService().getRegistry();
-        String resourcePath = mainResource + applicationName + "/" + clusterId;
-        Resource regResource;
-        regResource = createOrGetResourceforCluster(tempRegistry, 
resourcePath);
-
-        for (NewProperty property : properties) {
-            regResource.setProperty(property.getKey(), 
(Arrays.asList(property.getValues())));
-
-        }
-        tempRegistry.put(resourcePath, regResource);
-        log.info(String.format("Properties  are added to cluster %s of 
application %s", clusterId, applicationName));
-    }
-
-    /**
-     * Create or get resource for application
-     * @param tempRegistry
-     * @param resourcePath
-     * @return
-     * @throws RegistryException
-     */
-    private Resource createOrGetResourceforApplication(Registry tempRegistry, 
String resourcePath) throws RegistryException {
-        Resource regResource;
-        if (tempRegistry.resourceExists(resourcePath)) {
-            regResource = tempRegistry.get(resourcePath);
-        } else {
-            regResource = tempRegistry.newCollection();
-            if (log.isDebugEnabled()) {
-                log.debug("Registry resource is create at path " + 
regResource.getPath() + " for application");
-            }
-        }
-        return regResource;
-    }
-
-    /**
-     * Create and get resources for Clustor
-     * @param tempRegistry
-     * @param resourcePath
-     * @return
-     * @throws RegistryException
-     */
-    private Resource createOrGetResourceforCluster(Registry tempRegistry, 
String resourcePath) throws RegistryException {
-
-        int index = resourcePath.lastIndexOf('/');
-        String applicationResourcePath = resourcePath.substring(0, index);
-        createOrGetResourceforApplication(tempRegistry, 
applicationResourcePath);
-        Resource regResource;
-        if (tempRegistry.resourceExists(resourcePath)) {
-            regResource = tempRegistry.get(resourcePath);
-        } else {
-            regResource = tempRegistry.newResource();
-            if (log.isDebugEnabled()) {
-                log.debug("Registry resource is create at path for cluster" + 
regResource.getPath() + " for cluster");
-            }
-        }
-        return regResource;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java
deleted file mode 100644
index cb43111..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.registry;
-
-/*
- * Factory for the Data Registry
- */
-public class DataRegistryFactory {
-
-       public static DataStore getDataStore(String registryName) {
-               if (registryName.equals("carbon")) {
-                       return new CarbonRegistry();
-               } else {
-                       return null;
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
deleted file mode 100644
index 230d5ae..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.registry;
-
-
-import org.apache.stratos.metadataservice.definition.NewProperty;
-import org.wso2.carbon.registry.api.RegistryException;
-
-import java.util.List;
-
-/*
- * Interface of the Data Store
- */
-public interface DataStore {
-
-    public void addPropertiesToCluster(String applicationName, String 
clusterId, NewProperty[] properties)
-            throws RegistryException;
-
-    public List<NewProperty> getPropertiesOfCluster(String applicationName, 
String clusterId)
-            throws RegistryException;
-
-    public void addPropertyToCluster(String applicationId, String clusterId, 
NewProperty property) throws RegistryException;
-
-    public boolean deleteApplication(String applicationId) throws 
RegistryException;
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java
deleted file mode 100644
index b0be94a..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF 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.apache.stratos.metadataservice.security;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.security.Principal;
-
-/**
- * {@link StratosSecurityContext} make use of principal instance. Here with 
Stratos
- * authentication/authorization framework we only need username as the 
principal details
- */
-public class StratosPrincipal implements Principal {
-    private Log log = LogFactory.getLog(StratosPrincipal.class);
-    private String userName;
-
-    public StratosPrincipal(String userName) {
-        this.userName = userName;
-    }
-
-    public boolean equals(Object another) {
-      return userName.equals((another));
-    }
-
-    public String toString() {
-        return userName.toString();
-    }
-
-    public int hashCode() {
-        return userName.hashCode();
-    }
-
-    public String getName() {
-        return userName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java
deleted file mode 100644
index 5cc64f3..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.security;
-
-import java.security.Principal;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.security.SecurityContext;
-
-/**
- * {@link StratosSecurityContext} is what get passed between authentication
- * handlers
- * and the authorization handler.
- */
-public class StratosSecurityContext implements SecurityContext {
-       private static Log log = 
LogFactory.getLog(StratosSecurityContext.class);
-       Principal principal;
-
-       public StratosSecurityContext(String user) {
-               this.principal = new StratosPrincipal(user);
-       }
-
-       @Override
-       public Principal getUserPrincipal() {
-               return principal;
-       }
-
-       @Override
-       public boolean isUserInRole(String role) {
-               return false;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
 
b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
deleted file mode 100644
index 8e0448a..0000000
--- 
a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.metadataservice.services;
-
-import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadataservice.annotation.AuthorizationAction;
-import org.apache.stratos.metadataservice.definition.NewProperty;
-import org.apache.stratos.metadataservice.exception.RestAPIException;
-import org.apache.stratos.metadataservice.registry.DataRegistryFactory;
-import org.apache.stratos.metadataservice.registry.DataStore;
-import org.apache.stratos.metadataservice.util.ConfUtil;
-import org.wso2.carbon.registry.api.RegistryException;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import java.net.URI;
-import java.util.List;
-
-@Path("/")
-public class MetaDataAdmin {
-    @Context
-    UriInfo uriInfo;
-
-    private static Log log = LogFactory.getLog(MetaDataAdmin.class);
-
-
-
-    private DataStore registry;
-
-    /**
-     * Meta data admin configuration loading
-     */
-    public MetaDataAdmin(){
-        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
-        String DEFAULT_REG_TYPE = "carbon";
-        String registryType =  
conf.getString("metadataservice.govenanceregistrytype", DEFAULT_REG_TYPE);
-        registry = DataRegistryFactory.getDataStore(registryType);
-    }
-
-    @GET
-    @Path("/application/{application_id}/cluster/{cluster_id}/properties")
-    @Produces("application/json")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response getClusterProperties(@PathParam("application_id") String 
applicationId, @PathParam("cluster_id") String clusterId) throws 
RestAPIException{
-
-        List<NewProperty> properties;
-        NewProperty[] propertiesArr = null;
-           try {
-                   properties = registry
-                                   .getPropertiesOfCluster(applicationId, 
clusterId);
-                   if (properties != null) {
-                           propertiesArr = new NewProperty[properties.size()];
-                           propertiesArr = properties.toArray(propertiesArr);
-                   }
-           } catch (RegistryException e) {
-                   String msg = "Error occurred while getting properties ";
-                   log.error(msg, e);
-                   throw new RestAPIException(msg, e);
-           }
-
-        Response.ResponseBuilder rb;
-        if (propertiesArr == null) {
-            rb = Response.status(Response.Status.NOT_FOUND);
-        } else {
-            rb = Response.ok().entity(propertiesArr);
-        }
-        return rb.build();
-    }
-
-    @GET
-    
@Path("/application/{application_id}/cluster/{cluster_id}/property/{property_name}")
-    @Produces("application/json")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response getClusterProperty(@PathParam("application_id") String 
applicationId, @PathParam("cluster_id") String clusterId, 
@PathParam("property_name") String propertyName) throws RestAPIException{
-        List<NewProperty> properties;
-
-
-        NewProperty property = null;
-
-           try {
-                   properties = registry
-                                   .getPropertiesOfCluster(applicationId, 
clusterId);
-                   if (properties == null) {
-                           return 
Response.status(Response.Status.NOT_FOUND).build();
-                   }
-                   for (NewProperty p : properties) {
-                           if (propertyName.equals(p.getKey())) {
-                                   property = p;
-                                   break;
-                           }
-                   }
-           } catch (RegistryException e) {
-                   String msg = "Error occurred while getting property";
-                   log.error(msg, e);
-                   throw new RestAPIException(msg, e);
-           }
-
-        Response.ResponseBuilder rb;
-        if (property == null) {
-            rb = Response.status(Response.Status.NOT_FOUND);
-        } else {
-            rb = Response.ok().entity(property);
-        }
-        return rb.build();
-    }
-
-    @POST
-    @Path("application/{application_id}/cluster/{cluster_id}/property")
-    @Produces("application/json")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response addPropertyToACluster(@PathParam("application_id") String 
applicationId, @PathParam("cluster_id") String clusterId, NewProperty property)
-            throws RestAPIException {
-
-        URI url =  uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + 
clusterId + "/" + property.getKey()).build();
-
-           try {
-                   registry.addPropertyToCluster(applicationId, clusterId, 
property);
-           } catch (RegistryException e) {
-                   String msg = "Error occurred while adding property";
-                   log.error(msg, e);
-                   throw new RestAPIException(msg, e);
-           }
-
-        return Response.created(url).build();
-    }
-
-    @POST
-    @Path("application/{application_id}/cluster/{cluster_id}/properties")
-    @Produces("application/json")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response addPropertiesToACluster(@PathParam("application_id") 
String applicationId, @PathParam("cluster_id") String clusterId, NewProperty[] 
properties)
-            throws RestAPIException {
-        URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + 
clusterId).build();
-
-           try {
-                   registry.addPropertiesToCluster(applicationId, clusterId, 
properties);
-           } catch (RegistryException e) {
-                   String msg = "Error occurred while adding properties ";
-                   log.error(msg, e);
-                   throw new RestAPIException(msg, e);
-           }
-
-        return Response.created(url).build();
-    }
-
-    @DELETE
-    @Path("application/{application_id}")
-    @Produces("application/json")
-    @Consumes("application/json")
-    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response deleteApplicationProperties(@PathParam("application_id") 
String applicationId)
-            throws RestAPIException {
-
-           try {
-                   boolean deleted = registry.deleteApplication(applicationId);
-                   if (!deleted) {
-                           log.warn(String.format(
-                                           "Either no metadata is associated 
with given appId %s Or resources could not be deleted",
-                                           applicationId));
-                   }
-           } catch (RegistryException e) {
-                   String msg = "Resource attached with appId could not be 
deleted";
-                   log.error(msg, e);
-                   throw new RestAPIException(msg, e);
-           }
-
-        return Response.ok().build();
-    }
-
-
-}

Reply via email to