You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/01/25 06:32:30 UTC
[1/5] stratos git commit: Renaming org.apache.stratos.metadataservice
to org.apache.stratos.metadata.service
Repository: stratos
Updated Branches:
refs/heads/master 60bca14d2 -> 958a3100a
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml
----------------------------------------------------------------------
diff --git a/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml b/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml
index cbc7100..23af86b 100644
--- a/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml
+++ b/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml
@@ -18,7 +18,8 @@
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.stratos</groupId>
@@ -46,9 +47,9 @@
<version>2.6.2</version>
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.xjc-utils</groupId>
@@ -56,9 +57,9 @@
<version>2.6.2</version>
</dependency>
<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.7</version>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
@@ -166,14 +167,14 @@
<version>1.1.1</version>
</dependency>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.1</version>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
</dependency>
<dependency>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- <version>1.0</version>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ <version>1.0</version>
</dependency>
<dependency>
@@ -221,16 +222,11 @@
<artifactId>org.wso2.carbon.registry.ws.client</artifactId>
<version>4.2.0</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.ws.stub</artifactId>
<version>4.2.0</version>
</dependency>
- <!--dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.autoscaler.service.stub</artifactId>
- <version>${project.version}</version>
- </dependency-->
</dependencies>
<build>
@@ -241,7 +237,7 @@
<resource>
<directory>${project.build.directory}/web-app/</directory>
</resource>
- <resource>
+ <resource>
<directory>src/main/resources</directory>
</resource>
</resources>
@@ -258,7 +254,7 @@
</goals>
<configuration>
<outputDirectory>${project.build.directory}/runtime/cxf</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
+ <excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
<execution>
@@ -302,9 +298,11 @@
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
</properties>
</adviceFile>
- <bundles>
- <bundleDef>org.apache.stratos:org.apache.stratos.autoscaler.service.stub:${project.version}</bundleDef>
- </bundles>
+ <bundles>
+ <bundleDef>
+ org.apache.stratos:org.apache.stratos.autoscaler.service.stub:${project.version}
+ </bundleDef>
+ </bundles>
<importFeatures>
<importFeatureDef>org.wso2.carbon.core:${wso2carbon.version}</importFeatureDef>
</importFeatures>
@@ -312,7 +310,6 @@
</execution>
</executions>
</plugin>
-
</plugins>
</build>
</project>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/products/stratos/modules/p2-profile-gen/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/p2-profile-gen/pom.xml b/products/stratos/modules/p2-profile-gen/pom.xml
index 60fa2e4..baf2a07 100644
--- a/products/stratos/modules/p2-profile-gen/pom.xml
+++ b/products/stratos/modules/p2-profile-gen/pom.xml
@@ -281,7 +281,7 @@
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.rm.server.feature:${carbon.version}</featureArtifactDef>
<featureArtifactDef>org.apache.stratos:org.apache.stratos.manager.feature:${project.version}</featureArtifactDef>
<featureArtifactDef>org.apache.stratos:org.apache.stratos.rest.endpoint.feature:${project.version}</featureArtifactDef>
- <featureArtifactDef>org.apache.stratos:org.apache.stratos.metadataservice.feature:${project.version}</featureArtifactDef>
+ <featureArtifactDef>org.apache.stratos:org.apache.stratos.metadata.service.feature:${project.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.patch.version.4.2.1}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${carbon.platform.patch.version.4.2.2}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.patch.version.4.2.2}</featureArtifactDef>
@@ -493,7 +493,7 @@
<version>${project.version}</version>
</feature>
<feature>
- <id>org.apache.stratos.metadataservice.feature.group</id>
+ <id>org.apache.stratos.metadata.service.feature.group</id>
<version>${project.version}</version>
</feature>
<feature>
@@ -620,7 +620,7 @@
<version>${carbon.platform.patch.version.4.2.1}</version>
</feature>
<feature>
- <id>org.apache.stratos.metadataservice.feature.group</id>
+ <id>org.apache.stratos.metadata.service.feature.group</id>
<version>${project.version}</version>
</feature>
<feature>
@@ -712,7 +712,7 @@
<version>${carbon.platform.patch.version.4.2.1}</version>
</feature>
<feature>
- <id>org.apache.stratos.metadataservice.feature.group</id>
+ <id>org.apache.stratos.metadata.service.feature.group</id>
<version>${project.version}</version>
</feature>
<feature>
@@ -837,7 +837,7 @@
<version>${project.version}</version>
</feature>
<feature>
- <id>org.apache.stratos.metadataservice.feature.group</id>
+ <id>org.apache.stratos.metadata.service.feature.group</id>
<version>${project.version}</version>
</feature>
<feature>
@@ -993,7 +993,7 @@
<version>${carbon.platform.version}</version>
</feature>
<feature>
- <id>org.apache.stratos.metadataservice.feature.group</id>
+ <id>org.apache.stratos.metadata.service.feature.group</id>
<version>${project.version}</version>
</feature>
<!-- Common features -->
[2/5] stratos git commit: Renaming org.apache.stratos.metadataservice
to org.apache.stratos.metadata.service
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java
deleted file mode 100644
index b6d4ce0..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java
+++ /dev/null
@@ -1,76 +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.util;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadataservice.Constants;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.io.File;
-
-/**
- * This class contains utility methods for read metadata configuration file.
- */
-public class ConfUtil {
-
- private static Log log = LogFactory.getLog(ConfUtil.class);
-
- private XMLConfiguration config;
-
- private static ConfUtil instance = null;
-
- private ConfUtil(String configFilePath) {
- log.debug("Loading configuration.....");
-
- try {
-
- File confFile;
- if (StringUtils.isNotEmpty(configFilePath)) {
- confFile = new File(configFilePath);
-
- } else {
- confFile =
- new File(CarbonUtils.getCarbonConfigDirPath(),
- Constants.METADATASERVICE_CONFIG_FILE_NAME);
- }
-
- config = new XMLConfiguration(confFile);
- } catch (ConfigurationException e) {
- log.error("Unable to load autoscaler configuration file", e);
- config = new XMLConfiguration(); // continue with default values
- }
- }
-
- public static ConfUtil getInstance(String configFilePath) {
- if (instance == null) {
- instance = new ConfUtil(configFilePath);
- }
- return instance;
- }
-
- public XMLConfiguration getConfiguration() {
- return config;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml b/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml
deleted file mode 100644
index db07954..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml
+++ /dev/null
@@ -1,299 +0,0 @@
-<!--
- ~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com)
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<axisconfig name="AxisJava2.0">
- <!-- ================================================= -->
- <!-- Parameters -->
- <!-- ================================================= -->
- <parameter name="hotdeployment">true</parameter>
- <parameter name="hotupdate">false</parameter>
- <parameter name="enableMTOM">false</parameter>
-
- <!-- commons-http-client defaultMaxConnPerHost -->
- <parameter name="defaultMaxConnPerHost">500</parameter>
- <!-- commons-http-client maxTotalConnections -->
- <parameter name="maxTotalConnections">15000</parameter>
-
- <!--If turned on with use the Accept header of the request to determine the contentType of the
- response-->
- <parameter name="httpContentNegotiation">false</parameter>
-
- <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
- <!--that behaviour.-->
- <parameter name="sendStacktraceDetailsWithFaults">true</parameter>
-
- <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
- <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
- <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
- <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
- <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
-
- <!--This is the user name and password of admin console-->
- <parameter name="userName">admin</parameter>
- <parameter name="password">axis2</parameter>
-
- <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
- <!--ServicesDirectory only works on the following cases-->
- <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
- <!---When creating URL Based configurator with URL “file://” -->
- <!--- War based configurator with expanded case , -->
-
- <!--All the other scenarios it will be ignored.-->
- <!--<parameter name="ServicesDirectory">service</parameter>-->
- <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
- <!--<parameter name="ModulesDirectory">modules</parameter>-->
-
- <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
- <!--root which can configured using the following contextRoot parameter-->
- <!--<parameter name="contextRoot">axis2</parameter>-->
-
- <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguish those endpoints-->
- <!--<parameter name="servicePath">services</parameter>-->
- <!--<parameter name="restPath">rest</parameter>-->
-
- <!-- Following parameter will completely disable REST handling in Axis2-->
- <parameter name="disableREST" locked="false">false</parameter>
-
- <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
- <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
-
- <!-- Following parameter will set the host name for the epr-->
- <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
-
- <!-- ================================================= -->
- <!-- Message Receivers -->
- <!-- ================================================= -->
- <!--This is the Default Message Receiver for the system , if you want to have MessageReceivers for -->
- <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
- <!--any operation -->
- <!--Note : You can override this for particular service by adding the same element with your requirement-->
- <messageReceivers>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
- class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
- <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
- class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- </messageReceivers>
-
- <!-- ================================================= -->
- <!-- Message Formatter -->
- <!-- ================================================= -->
- <!--Following content type to message formatter mapping can be used to implement support for different message -->
- <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageFormatters>
- <messageFormatter contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
- <messageFormatter contentType="multipart/form-data"
- class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
- <messageFormatter contentType="application/xml"
- class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
- <messageFormatter contentType="text/xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- <messageFormatter contentType="application/soap+xml"
- class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
- <!--JSON Message Formatters-->
- <messageFormatter contentType="application/json"
- class="org.apache.axis2.json.JSONMessageFormatter"/>
- <messageFormatter contentType="application/json/badgerfish"
- class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
- <messageFormatter contentType="text/javascript"
- class="org.apache.axis2.json.JSONMessageFormatter"/>
- </messageFormatters>
-
- <!-- ================================================= -->
- <!-- Message Builders -->
- <!-- ================================================= -->
- <!--Following content type to builder mapping can be used to implement support for different message -->
- <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
- <messageBuilders>
- <messageBuilder contentType="application/xml"
- class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
- <messageBuilder contentType="application/x-www-form-urlencoded"
- class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
- <!--JSON Message Builders-->
- <messageBuilder contentType="application/json"
- class="org.apache.axis2.json.JSONOMBuilder"/>
- <messageBuilder contentType="application/json/badgerfish"
- class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
- <messageBuilder contentType="text/javascript"
- class="org.apache.axis2.json.JSONOMBuilder"/>
- <!--Left commented because it adds the depandancy of servlet-api to other modules.
- Please uncomment to Receive messages in multipart/form-data format-->
- <!--<messageBuilder contentType="multipart/form-data"-->
- <!--class="org.apache.axis2.builder.MultipartFormDataBuilder"/>-->
- </messageBuilders>
-
- <!-- ================================================= -->
- <!-- Target Resolvers -->
- <!-- ================================================= -->
- <!-- Uncomment the following and specify the class name for your TargetResolver to add -->
- <!-- a TargetResolver. TargetResolvers are used to process the To EPR for example to -->
- <!-- choose a server in a cluster -->
- <!--<targetResolvers>-->
- <!--<targetResolver class="" />-->
- <!--</targetResolvers>-->
-
-
- <!-- ================================================= -->
- <!-- Transport Ins -->
- <!-- ================================================= -->
- <transportReceiver name="http"
- class="org.apache.axis2.transport.http.SimpleHTTPServer">
- <parameter name="port">6071</parameter>
- <!--If you want to give your own host address for EPR generation-->
- <!--uncomment following parameter , and set as you required.-->
- <!--<parameter name="hostname">http://myApp.com/ws</parameter>-->
- </transportReceiver>
-
- <!--Uncomment if you want to have TCP transport support-->
- <!--<transportReceiver name="tcp"
- class="org.apache.axis2.transport.tcp.TCPServer">
- <parameter name="port">6061</parameter>-->
- <!--If you want to give your own host address for EPR generation-->
- <!--uncomment following parameter , and set as you required.-->
- <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
- <!--</transportReceiver>-->
-
- <!-- ================================================= -->
- <!-- Transport Outs -->
- <!-- ================================================= -->
-
- <!--<transportSender name="jms"-->
- <!--class="org.apache.axis2.transport.jms.JMSSender"/>-->
- <transportSender name="tcp"
- class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
- <transportSender name="local"
- class="org.apache.axis2.transport.local.LocalTransportSender"/>
- <transportSender name="http"
- class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
- <parameter name="PROTOCOL">HTTP/1.1</parameter>
- <parameter name="Transfer-Encoding">chunked</parameter>
- <parameter name="SO_TIMEOUT">60000</parameter>
- <parameter name="CONNECTION_TIMEOUT">60000</parameter>
- </transportSender>
- <transportSender name="https"
- class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
- <parameter name="PROTOCOL">HTTP/1.1</parameter>
- <parameter name="Transfer-Encoding">chunked</parameter>
- <parameter name="SO_TIMEOUT">60000</parameter>
- <parameter name="CONNECTION_TIMEOUT">60000</parameter>
- </transportSender>
- <!--<transportSender name="java"-->
- <!--class="org.apache.axis2.transport.java.JavaTransportSender"/>-->
-
-
- <!-- ================================================= -->
- <!-- SOAP Role Configuration -->
- <!-- ================================================= -->
- <!-- Use the following pattern to configure this axis2
- instance to act in particular roles. Note that in
- the absence of any configuration, Axis2 will act
- only in the ultimate receiver role -->
- <!--
- <SOAPRoleConfiguration isUltimateReceiver="true">
- <role>http://my/custom/role</role>
- </SOAPRoleConfiguration>
- -->
-
- <!-- ================================================= -->
- <!-- Phases -->
- <!-- ================================================= -->
- <phaseOrder type="InFlow">
- <!-- System pre-defined phases -->
- <phase name="Transport">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
- <order phase="Transport"/>
- </handler>
- </phase>
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- System pre defined phases -->
- <!-- After Postdispatch phase module author or or service author can add any phase he want -->
- <phase name="OperationInPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutPhase"/>
- <!--system predefined phase-->
- <!--these phase will run irrespective of the service-->
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
- <phaseOrder type="InFaultFlow">
- <phase name="Addressing">
- <handler name="AddressingBasedDispatcher"
- class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
- <order phase="Addressing"/>
- </handler>
- </phase>
- <phase name="Security"/>
- <phase name="PreDispatch"/>
- <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
- <handler name="RequestURIBasedDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
- <handler name="SOAPActionBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
- <handler name="RequestURIOperationDispatcher"
- class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
- <handler name="SOAPMessageBodyBasedDispatcher"
- class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
-
- <handler name="HTTPLocationBasedDispatcher"
- class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
- </phase>
- <phase name="RMPhase"/>
- <!-- user can add his own phases to this area -->
- <phase name="OperationInFaultPhase"/>
- </phaseOrder>
- <phaseOrder type="OutFaultFlow">
- <!-- user can add his own phases to this area -->
- <phase name="OperationOutFaultPhase"/>
- <phase name="RMPhase"/>
- <phase name="PolicyDetermination"/>
- <phase name="MessageOut"/>
- <phase name="Security"/>
- </phaseOrder>
-</axisconfig>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml
deleted file mode 100644
index c62912d..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- # 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.
- -->
-
-<!--
- This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
--->
-<Classloading xmlns="http://wso2.org/projects/as/classloading">
-
- <!-- Parent-first or child-first. Default behaviour is child-first.-->
- <ParentFirst>false</ParentFirst>
-
- <!--
- Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
- Tomcat environment is the default and every webapps gets it even if they didn't specify it.
- e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
- -->
- <Environments>CXF,Carbon</Environments>
-</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml
deleted file mode 100644
index f8b8750..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- # 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.
- -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jaxrs="http://cxf.apache.org/jaxrs"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
-
- <jaxrs:server id="stratosAdmin" address="/">
- <jaxrs:serviceBeans>
- <ref bean="stratosRestEndpointTestBean"/>
- </jaxrs:serviceBeans>
-
- <jaxrs:providers>
- <ref bean="throwableExceptionHandler"/>
- <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
- <property name="dropRootElement" value="true"/>
- <property name="supportUnwrapped" value="true"/>
- </bean>>
- <ref bean="exceptionHandler"/>
- </jaxrs:providers>
- </jaxrs:server>
-
- <bean id="stratosRestEndpointTestBean" class="org.apache.stratos.rest.endpoint.mock.StratosTestAdmin"/>
- <bean id="exceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.CustomExceptionMapper"/>
- <bean id="throwableExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.CustomThrowableExceptionMapper"/>
-</beans>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/web.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/web.xml
deleted file mode 100644
index 4a752f6..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata-test/WEB-INF/web.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- # 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.
- -->
-
-<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
- <display-name>S2 Meta Data Admin Endpoint</display-name>
-
- <servlet>
- <servlet-name>StratosAdminEndpoint</servlet-name>
- <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>StratosAdminEndpoint</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/META-INF/webapp-classloading.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/META-INF/webapp-classloading.xml
deleted file mode 100644
index c62912d..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/META-INF/webapp-classloading.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- # 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.
- -->
-
-<!--
- This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
--->
-<Classloading xmlns="http://wso2.org/projects/as/classloading">
-
- <!-- Parent-first or child-first. Default behaviour is child-first.-->
- <ParentFirst>false</ParentFirst>
-
- <!--
- Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
- Tomcat environment is the default and every webapps gets it even if they didn't specify it.
- e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
- -->
- <Environments>CXF,Carbon</Environments>
-</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml
deleted file mode 100644
index 3d001bf..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- # 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.
- -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jaxrs="http://cxf.apache.org/jaxrs"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
-
- <jaxrs:server id="stratosMetaDataAdmin" address="/api">
- <jaxrs:serviceBeans>
- <ref bean="stratosRestEndpointBean"/>
- </jaxrs:serviceBeans>
-
- <jaxrs:providers>
- <ref bean="throwableExceptionHandler"/>
- <ref bean="genericExceptionHandler"/>
- <ref bean="jsonProvider"/>
- <ref bean="exceptionHandler"/>
- <ref bean="OAuthFilter"/>
- <ref bean="basicAuthenticationFilter"/>
- <ref bean="sessionAuthenticationFilter"/>
- <!--<ref bean="authorizationFilter"/>-->
- </jaxrs:providers>
- </jaxrs:server>
-
- <bean id="stratosRestEndpointBean" class="org.apache.stratos.metadataservice.services.MetaDataAdmin"/>
- <bean id="basicAuthenticationFilter" class="org.apache.stratos.metadataservice.handlers.StratosAuthenticationHandler"/>
- <bean id="sessionAuthenticationFilter" class="org.apache.stratos.metadataservice.handlers.CookieBasedAuthenticationHandler"/>
- <bean id="authorizationFilter" class="org.apache.stratos.metadataservice.handlers.StratosAuthorizingHandler">
- <property name="securedObject" ref="stratosRestEndpointBean"/>
- </bean>
- <bean id="exceptionHandler" class="org.apache.stratos.metadataservice.handlers.CustomExceptionMapper"/>
- <bean id="genericExceptionHandler" class="org.apache.stratos.metadataservice.handlers.GenericExceptionMapper"/>
- <bean id="throwableExceptionHandler" class="org.apache.stratos.metadataservice.handlers.CustomThrowableExceptionMapper"/>
- <!--The below config enables OAuth based authentication/authorization for REST API-->
- <bean id="OAuthFilter" class="org.apache.stratos.metadataservice.handlers.OAuthHandler">
- <property name="password" value="admin"/>
- <property name="username" value="admin"/>
- <property name="oauthValidationEndpoint" value="https://localhost:9443/services/"/>
- </bean>
- <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
- <property name="supportUnwrapped" value="true"/>
- <property name="serializeAsArray" value="true"/>
- <property name="dropRootElement" value="true" />
- <property name="arrayKeys">
- <list>
- <value>partitions</value>
- <value>property</value>
- <value>hostNames</value>
- <value>memberMap</value>
- <value>portMap</value>
- <value>partitionGroup</value>
- <value>partition</value>
- <value>member</value>
- <value>hostNames</value>
- <value>portMappings</value>
- <value>volumes</value>
- </list>
- </property>
- </bean>
-
-</beans>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/web.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/web.xml
deleted file mode 100644
index a46ee34..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/webapp/metadata/WEB-INF/web.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- # 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.
- -->
-
-<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
- <display-name>S2 Admin Endpoint</display-name>
- <servlet>
- <servlet-name>StratosAdminEndpoint</servlet-name>
- <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>StratosAdminEndpoint</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 86c2922..33e0533 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -79,7 +79,7 @@
<!-- Stratos manager styles bundle -->
<module>org.apache.stratos.manager.styles</module>
<module>org.apache.stratos.custom.handlers</module>
- <module>org.apache.stratos.metadataservice</module>
+ <module>org.apache.stratos.metadata.service</module>
<module>org.apache.stratos.metadata.client</module>
</modules>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/pom.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/pom.xml b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/pom.xml
new file mode 100644
index 0000000..77f6361
--- /dev/null
+++ b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/pom.xml
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>stratos-manager-features</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.metadata.service.feature</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Stratos - Meta Data Service feature</name>
+ <description>This feature packs the Meta Data Service of stratos</description>
+
+ <dependencies>
+ <!--CXF runtime environment-->
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-bundle</artifactId>
+ <version>2.7.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.xjcplugins</groupId>
+ <artifactId>cxf-xjc-dv</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.xjc-utils</groupId>
+ <artifactId>cxf-xjc-runtime</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.xjcplugins</groupId>
+ <artifactId>cxf-xjc-ts</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.xjcplugins</groupId>
+ <artifactId>cxf-xjc-boolean</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.xjcplugins</groupId>
+ <artifactId>cxf-xjc-bug671</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache-core</artifactId>
+ <version>2.5.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpasyncclient</artifactId>
+ <version>4.0-beta3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-nio</artifactId>
+ <version>4.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0-m10</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.13</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ <version>2.1.13</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>woodstox-core-asl</artifactId>
+ <version>4.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>stax2-api</artifactId>
+ <version>3.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.neethi</groupId>
+ <artifactId>neethi</artifactId>
+ <version>3.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.security</groupId>
+ <artifactId>wss4j</artifactId>
+ <version>1.6.11</version>
+ </dependency>
+ <dependency>
+ <groupId>xml-resolver</groupId>
+ <artifactId>xml-resolver</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.xmlschema</groupId>
+ <artifactId>xmlschema-core</artifactId>
+ <version>2.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.santuario</groupId>
+ <artifactId>xmlsec</artifactId>
+ <version>1.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>3.0.7.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-asm</artifactId>
+ <version>3.0.7.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.7.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.7.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.7.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-expression</artifactId>
+ <version>3.0.7.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>3.0.7.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon.webapp.ext</groupId>
+ <artifactId>carbon-cxf</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.ws.stub</artifactId>
+ <version>4.2.0</version>
+ </dependency>
+
+
+ <!--dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.autoscaler.service.stub</artifactId>
+ <version>${project.version}</version>
+ </dependency-->
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${project.build.directory}/runtime/</directory>
+ </resource>
+ <resource>
+ <directory>${project.build.directory}/web-app/</directory>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/runtime/cxf</outputDirectory>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pack-REST-webapp</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.metadata.service</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/web-app/web-app</outputDirectory>
+ <destFileName>stratosmetadataservice.war</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.wso2.maven</groupId>
+ <artifactId>carbon-p2-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>p2-feature-generation</id>
+ <phase>package</phase>
+ <goals>
+ <goal>p2-feature-gen</goal>
+ </goals>
+ <configuration>
+ <id>org.apache.stratos.metadata.service</id>
+ <propertiesFile>../../etc/feature.properties</propertiesFile>
+ <adviceFile>
+ <properties>
+ <propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
+ <propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
+ </properties>
+ </adviceFile>
+ <bundles>
+ <bundleDef>org.apache.stratos:org.apache.stratos.manager.stub:${project.version}</bundleDef>
+ </bundles>
+ <importFeatures>
+ <importFeatureDef>org.wso2.carbon.core:${wso2carbon.version}</importFeatureDef>
+ </importFeatures>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/p2.inf
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/p2.inf b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/p2.inf
new file mode 100644
index 0000000..b82f599
--- /dev/null
+++ b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/p2.inf
@@ -0,0 +1,23 @@
+# 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.
+
+instructions.configure = \
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadata.service_${feature.version}/cxf,target:${installFolder}/../../../lib/runtimes/cxf,overwrite:true);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadata.service_${feature.version}/web-app/stratosmetadataservice.war,target:${installFolder}/../../deployment/server/webapps/stratosmetadataservice.war,overwrite:true);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadata.service_${feature.version}/tomcat/webapp-classloading.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading.xml,overwrite:true);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadata.service_${feature.version}/tomcat/webapp-classloading-environments.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading-environments.xml,overwrite:true);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadata.service_${feature.version}/tomcat/context.xml,target:${installFolder}/../../conf/tomcat/context.xml,overwrite:true);\
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/context.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/context.xml b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/context.xml
new file mode 100644
index 0000000..a85c9af
--- /dev/null
+++ b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/context.xml
@@ -0,0 +1,36 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ 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.
+-->
+<!-- The contents of this file will be loaded for each web application -->
+<Context crossContext="true">
+
+ <!-- Default set of monitored resources -->
+
+ <Loader className="org.wso2.carbon.webapp.mgt.loader.CarbonWebappLoader" loaderClass="org.wso2.carbon.webapp.mgt.loader.CarbonWebappClassLoader"/>
+
+ <!-- Uncomment this to disable session persistence across Tomcat restarts -->
+ <!--
+ <Manager pathname="" />
+ -->
+
+ <!-- Uncomment this to enable Comet connection tacking (provides events
+ on session expiration as well as webapp lifecycle) -->
+ <!--
+ <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
+ -->
+
+</Context>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading-environments.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading-environments.xml b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading-environments.xml
new file mode 100644
index 0000000..7e7dd0a
--- /dev/null
+++ b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading-environments.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ ~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ This file defines the different classloading environments. This is container level config file. Individual webapps are not allowed to override these elements.
+
+ ${carbon.home} represents the carbon.home system property.
+ Other system properties can be specified in a similar manner.
+-->
+<Classloading xmlns="http://wso2.org/projects/as/classloading-environments">
+
+ <!--
+ We define three different environments.
+
+ 1) Delegated environment - This is a virtual environment where all the resources belongs to these environments are loaded from the parent. This way you can control whats being loaded from the parent classloader. Only the packages and resources specified in the delegated environments are loaded from the parent. All the others are loaded from the local webapp's classpath. If a webapps has speficied two or more delegated environments, they all get merged at runtime.
+ -->
+ <DelegatedEnvironments>
+
+ <DelegatedEnvironment>
+ <Name>Tomcat</Name>
+ <DelegatedPackages>javax.annotation.*,javax.ejb,javax.el,javax.persistence,javax.servlet.*,javax.xml,javax.xml.ws,org.apache.catalina.*,org.apache.coyote.*,org.apache.el.*,com.sun.el.*,org.apache.jasper.*,org.apache.naming.*,org.apache.tomcat.*,org.wso2.carbon.tomcat.jndi.*</DelegatedPackages>
+ </DelegatedEnvironment>
+
+ <DelegatedEnvironment>
+ <Name>Carbon</Name>
+ <DelegatedPackages>*,!org.springframework.*</DelegatedPackages>
+ </DelegatedEnvironment>
+
+ </DelegatedEnvironments>
+
+
+ <!--
+ 2) Shared environment - These environments are loaded once and shared between multiple webapps. Certain runtimes can be shared by multiple webapps. So no need to load them per webapp.
+ -->
+
+ <!--SharedEnvironments>
+ <SharedEnvironment>
+ <name>Spring</name>
+ <Classpath></Classpath>
+ </SharedEnvironment>
+ </SharedEnvironments-->
+
+ <!--
+ 3) Exclusive environment - These environments are loaded per webapp. Exclusive environments define a set of resources(jars) which should be loaded per webapp. e.g. CXF runtime.
+ -->
+ <ExclusiveEnvironments>
+ <ExclusiveEnvironment>
+ <Name>CXF</Name>
+ <Classpath>${carbon.home}/lib/runtimes/cxf/*.jar;${carbon.home}/lib/runtimes/cxf/</Classpath>
+ </ExclusiveEnvironment>
+ </ExclusiveEnvironments>
+
+</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading.xml b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading.xml
new file mode 100644
index 0000000..f42616f
--- /dev/null
+++ b/features/manager/metadataservice/org.apache.stratos.metadata.service.feature/src/main/resources/tomcat/webapp-classloading.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ ~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
+-->
+<Classloading xmlns="http://wso2.org/projects/as/classloading">
+
+ <!-- Parent-first or child-first. Default behaviour is child-first.-->
+ <ParentFirst>false</ParentFirst>
+
+ <!--
+ Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
+ Tomcat environment is the default and every webapps gets it even if they didn't specify it.
+ e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
+ -->
+ <Environments>Carbon</Environments>
+</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml
deleted file mode 100644
index 37ae4fc..0000000
--- a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml
+++ /dev/null
@@ -1,316 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.apache.stratos</groupId>
- <artifactId>stratos-manager-features</artifactId>
- <version>4.1.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.apache.stratos.metadataservice.feature</artifactId>
- <packaging>pom</packaging>
- <name>Apache Stratos - Meta Data Service feature</name>
- <description>This feature packs the Meta Data Service of stratos</description>
-
- <dependencies>
- <!--CXF runtime environment-->
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-bundle</artifactId>
- <version>2.7.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf.xjcplugins</groupId>
- <artifactId>cxf-xjc-dv</artifactId>
- <version>2.6.2</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf.xjc-utils</groupId>
- <artifactId>cxf-xjc-runtime</artifactId>
- <version>2.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.7</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf.xjcplugins</groupId>
- <artifactId>cxf-xjc-ts</artifactId>
- <version>2.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf.xjcplugins</groupId>
- <artifactId>cxf-xjc-boolean</artifactId>
- <version>2.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf.xjcplugins</groupId>
- <artifactId>cxf-xjc-bug671</artifactId>
- <version>2.6.2</version>
- </dependency>
- <dependency>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache-core</artifactId>
- <version>2.5.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpasyncclient</artifactId>
- <version>4.0-beta3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.2.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <version>4.2.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore-nio</artifactId>
- <version>4.2.4</version>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.0-m10</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.1.13</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-xjc</artifactId>
- <version>2.1.13</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>woodstox-core-asl</artifactId>
- <version>4.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>stax2-api</artifactId>
- <version>3.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- <version>1.3.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.neethi</groupId>
- <artifactId>neethi</artifactId>
- <version>3.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.ws.security</groupId>
- <artifactId>wss4j</artifactId>
- <version>1.6.11</version>
- </dependency>
- <dependency>
- <groupId>xml-resolver</groupId>
- <artifactId>xml-resolver</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.ws.xmlschema</groupId>
- <artifactId>xmlschema-core</artifactId>
- <version>2.0.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.santuario</groupId>
- <artifactId>xmlsec</artifactId>
- <version>1.5.5</version>
- </dependency>
- <dependency>
- <groupId>wsdl4j</groupId>
- <artifactId>wsdl4j</artifactId>
- <version>1.6.3</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.1</version>
- </dependency>
- <dependency>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- <version>1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>3.0.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-asm</artifactId>
- <version>3.0.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>3.0.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>3.0.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>3.0.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-expression</artifactId>
- <version>3.0.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>3.0.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon.webapp.ext</groupId>
- <artifactId>carbon-cxf</artifactId>
- <version>1.0.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.registry.ws.stub</artifactId>
- <version>4.2.0</version>
- </dependency>
-
-
- <!--dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.autoscaler.service.stub</artifactId>
- <version>${project.version}</version>
- </dependency-->
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.build.directory}/runtime/</directory>
- </resource>
- <resource>
- <directory>${project.build.directory}/web-app/</directory>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/runtime/cxf</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- <execution>
- <id>pack-REST-webapp</id>
- <phase>package</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.metadataservice</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- <outputDirectory>${project.build.directory}/web-app/web-app</outputDirectory>
- <destFileName>stratosmetadataservice.war</destFileName>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.wso2.maven</groupId>
- <artifactId>carbon-p2-plugin</artifactId>
- <executions>
- <execution>
- <id>p2-feature-generation</id>
- <phase>package</phase>
- <goals>
- <goal>p2-feature-gen</goal>
- </goals>
- <configuration>
- <id>org.apache.stratos.metadataservice</id>
- <propertiesFile>../../etc/feature.properties</propertiesFile>
- <adviceFile>
- <properties>
- <propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
- <propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
- </properties>
- </adviceFile>
- <bundles>
- <bundleDef>org.apache.stratos:org.apache.stratos.manager.stub:${project.version}</bundleDef>
- </bundles>
- <importFeatures>
- <importFeatureDef>org.wso2.carbon.core:${wso2carbon.version}</importFeatureDef>
- </importFeatures>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf
deleted file mode 100644
index 13f9684..0000000
--- a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf
+++ /dev/null
@@ -1,23 +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.
-
-instructions.configure = \
-org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/cxf,target:${installFolder}/../../../lib/runtimes/cxf,overwrite:true);\
-org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/web-app/stratosmetadataservice.war,target:${installFolder}/../../deployment/server/webapps/stratosmetadataservice.war,overwrite:true);\
-org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/webapp-classloading.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading.xml,overwrite:true);\
-org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/webapp-classloading-environments.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading-environments.xml,overwrite:true);\
-org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/context.xml,target:${installFolder}/../../conf/tomcat/context.xml,overwrite:true);\
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml
deleted file mode 100644
index a85c9af..0000000
--- a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!--
- 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.
--->
-<!-- The contents of this file will be loaded for each web application -->
-<Context crossContext="true">
-
- <!-- Default set of monitored resources -->
-
- <Loader className="org.wso2.carbon.webapp.mgt.loader.CarbonWebappLoader" loaderClass="org.wso2.carbon.webapp.mgt.loader.CarbonWebappClassLoader"/>
-
- <!-- Uncomment this to disable session persistence across Tomcat restarts -->
- <!--
- <Manager pathname="" />
- -->
-
- <!-- Uncomment this to enable Comet connection tacking (provides events
- on session expiration as well as webapp lifecycle) -->
- <!--
- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
- -->
-
-</Context>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml
deleted file mode 100644
index 7e7dd0a..0000000
--- a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!--
- ~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!--
- This file defines the different classloading environments. This is container level config file. Individual webapps are not allowed to override these elements.
-
- ${carbon.home} represents the carbon.home system property.
- Other system properties can be specified in a similar manner.
--->
-<Classloading xmlns="http://wso2.org/projects/as/classloading-environments">
-
- <!--
- We define three different environments.
-
- 1) Delegated environment - This is a virtual environment where all the resources belongs to these environments are loaded from the parent. This way you can control whats being loaded from the parent classloader. Only the packages and resources specified in the delegated environments are loaded from the parent. All the others are loaded from the local webapp's classpath. If a webapps has speficied two or more delegated environments, they all get merged at runtime.
- -->
- <DelegatedEnvironments>
-
- <DelegatedEnvironment>
- <Name>Tomcat</Name>
- <DelegatedPackages>javax.annotation.*,javax.ejb,javax.el,javax.persistence,javax.servlet.*,javax.xml,javax.xml.ws,org.apache.catalina.*,org.apache.coyote.*,org.apache.el.*,com.sun.el.*,org.apache.jasper.*,org.apache.naming.*,org.apache.tomcat.*,org.wso2.carbon.tomcat.jndi.*</DelegatedPackages>
- </DelegatedEnvironment>
-
- <DelegatedEnvironment>
- <Name>Carbon</Name>
- <DelegatedPackages>*,!org.springframework.*</DelegatedPackages>
- </DelegatedEnvironment>
-
- </DelegatedEnvironments>
-
-
- <!--
- 2) Shared environment - These environments are loaded once and shared between multiple webapps. Certain runtimes can be shared by multiple webapps. So no need to load them per webapp.
- -->
-
- <!--SharedEnvironments>
- <SharedEnvironment>
- <name>Spring</name>
- <Classpath></Classpath>
- </SharedEnvironment>
- </SharedEnvironments-->
-
- <!--
- 3) Exclusive environment - These environments are loaded per webapp. Exclusive environments define a set of resources(jars) which should be loaded per webapp. e.g. CXF runtime.
- -->
- <ExclusiveEnvironments>
- <ExclusiveEnvironment>
- <Name>CXF</Name>
- <Classpath>${carbon.home}/lib/runtimes/cxf/*.jar;${carbon.home}/lib/runtimes/cxf/</Classpath>
- </ExclusiveEnvironment>
- </ExclusiveEnvironments>
-
-</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml
----------------------------------------------------------------------
diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml
deleted file mode 100644
index f42616f..0000000
--- a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!--
- ~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!--
- This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
--->
-<Classloading xmlns="http://wso2.org/projects/as/classloading">
-
- <!-- Parent-first or child-first. Default behaviour is child-first.-->
- <ParentFirst>false</ParentFirst>
-
- <!--
- Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
- Tomcat environment is the default and every webapps gets it even if they didn't specify it.
- e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
- -->
- <Environments>Carbon</Environments>
-</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/features/manager/pom.xml
----------------------------------------------------------------------
diff --git a/features/manager/pom.xml b/features/manager/pom.xml
index fcaf93f..4f71d01 100644
--- a/features/manager/pom.xml
+++ b/features/manager/pom.xml
@@ -50,7 +50,7 @@
<module>logging-mgt</module>
<module>rest-endpoint/org.apache.stratos.rest.endpoint.feature</module>
<module>styles/org.apache.stratos.manager.styles.feature</module>
- <module>metadataservice/org.apache.stratos.metadataservice.feature</module>
+ <module>metadataservice/org.apache.stratos.metadata.service.feature</module>
</modules>
<properties>
[4/5] stratos git commit: Renaming org.apache.stratos.metadataservice
to org.apache.stratos.metadata.service
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/oauth2/ValidationServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/oauth2/ValidationServiceClient.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/oauth2/ValidationServiceClient.java
new file mode 100644
index 0000000..d4810c6
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/oauth2/ValidationServiceClient.java
@@ -0,0 +1,65 @@
+/*
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
new file mode 100644
index 0000000..32fdc56
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/CarbonRegistry.java
@@ -0,0 +1,191 @@
+/*
+ * 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.metadata.service.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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataRegistryFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataRegistryFactory.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataRegistryFactory.java
new file mode 100644
index 0000000..981560c
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataRegistryFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java
new file mode 100644
index 0000000..f9f42bb
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/registry/DataStore.java
@@ -0,0 +1,41 @@
+/*
+ * 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.metadata.service.registry;
+
+
+import org.apache.stratos.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosPrincipal.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosPrincipal.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosPrincipal.java
new file mode 100644
index 0000000..9f0c835
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosPrincipal.java
@@ -0,0 +1,53 @@
+/*
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosSecurityContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosSecurityContext.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosSecurityContext.java
new file mode 100644
index 0000000..fbc4b1a
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/security/StratosSecurityContext.java
@@ -0,0 +1,50 @@
+/*
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
new file mode 100644
index 0000000..9b8ce94
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/services/MetaDataAdmin.java
@@ -0,0 +1,195 @@
+/*
+ * 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.metadata.service.services;
+
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.metadata.service.annotation.AuthorizationAction;
+import org.apache.stratos.metadata.service.definition.NewProperty;
+import org.apache.stratos.metadata.service.exception.RestAPIException;
+import org.apache.stratos.metadata.service.registry.DataRegistryFactory;
+import org.apache.stratos.metadata.service.registry.DataStore;
+import org.apache.stratos.metadata.service.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();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/util/ConfUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/util/ConfUtil.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/util/ConfUtil.java
new file mode 100644
index 0000000..50eaa63
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/util/ConfUtil.java
@@ -0,0 +1,76 @@
+/*
+ * 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.metadata.service.util;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.metadata.service.Constants;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import java.io.File;
+
+/**
+ * This class contains utility methods for read metadata configuration file.
+ */
+public class ConfUtil {
+
+ private static Log log = LogFactory.getLog(ConfUtil.class);
+
+ private XMLConfiguration config;
+
+ private static ConfUtil instance = null;
+
+ private ConfUtil(String configFilePath) {
+ log.debug("Loading configuration.....");
+
+ try {
+
+ File confFile;
+ if (StringUtils.isNotEmpty(configFilePath)) {
+ confFile = new File(configFilePath);
+
+ } else {
+ confFile =
+ new File(CarbonUtils.getCarbonConfigDirPath(),
+ Constants.METADATASERVICE_CONFIG_FILE_NAME);
+ }
+
+ config = new XMLConfiguration(confFile);
+ } catch (ConfigurationException e) {
+ log.error("Unable to load autoscaler configuration file", e);
+ config = new XMLConfiguration(); // continue with default values
+ }
+ }
+
+ public static ConfUtil getInstance(String configFilePath) {
+ if (instance == null) {
+ instance = new ConfUtil(configFilePath);
+ }
+ return instance;
+ }
+
+ public XMLConfiguration getConfiguration() {
+ return config;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml b/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml
new file mode 100644
index 0000000..db07954
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml
@@ -0,0 +1,299 @@
+<!--
+ ~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment">true</parameter>
+ <parameter name="hotupdate">false</parameter>
+ <parameter name="enableMTOM">false</parameter>
+
+ <!-- commons-http-client defaultMaxConnPerHost -->
+ <parameter name="defaultMaxConnPerHost">500</parameter>
+ <!-- commons-http-client maxTotalConnections -->
+ <parameter name="maxTotalConnections">15000</parameter>
+
+ <!--If turned on with use the Accept header of the request to determine the contentType of the
+ response-->
+ <parameter name="httpContentNegotiation">false</parameter>
+
+ <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+ <!--that behaviour.-->
+ <parameter name="sendStacktraceDetailsWithFaults">true</parameter>
+
+ <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
+ <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+ <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+ <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+ <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
+
+ <!--This is the user name and password of admin console-->
+ <parameter name="userName">admin</parameter>
+ <parameter name="password">axis2</parameter>
+
+ <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
+ <!--ServicesDirectory only works on the following cases-->
+ <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
+ <!---When creating URL Based configurator with URL “file://” -->
+ <!--- War based configurator with expanded case , -->
+
+ <!--All the other scenarios it will be ignored.-->
+ <!--<parameter name="ServicesDirectory">service</parameter>-->
+ <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
+ <!--<parameter name="ModulesDirectory">modules</parameter>-->
+
+ <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+ <!--root which can configured using the following contextRoot parameter-->
+ <!--<parameter name="contextRoot">axis2</parameter>-->
+
+ <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguish those endpoints-->
+ <!--<parameter name="servicePath">services</parameter>-->
+ <!--<parameter name="restPath">rest</parameter>-->
+
+ <!-- Following parameter will completely disable REST handling in Axis2-->
+ <parameter name="disableREST" locked="false">false</parameter>
+
+ <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
+ <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
+
+ <!-- Following parameter will set the host name for the epr-->
+ <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Default Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can override this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+
+ <!-- ================================================= -->
+ <!-- Message Formatter -->
+ <!-- ================================================= -->
+ <!--Following content type to message formatter mapping can be used to implement support for different message -->
+ <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
+ <messageFormatters>
+ <messageFormatter contentType="application/x-www-form-urlencoded"
+ class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
+ <messageFormatter contentType="multipart/form-data"
+ class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
+ <messageFormatter contentType="application/xml"
+ class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
+ <messageFormatter contentType="text/xml"
+ class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
+ <messageFormatter contentType="application/soap+xml"
+ class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
+ <!--JSON Message Formatters-->
+ <messageFormatter contentType="application/json"
+ class="org.apache.axis2.json.JSONMessageFormatter"/>
+ <messageFormatter contentType="application/json/badgerfish"
+ class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
+ <messageFormatter contentType="text/javascript"
+ class="org.apache.axis2.json.JSONMessageFormatter"/>
+ </messageFormatters>
+
+ <!-- ================================================= -->
+ <!-- Message Builders -->
+ <!-- ================================================= -->
+ <!--Following content type to builder mapping can be used to implement support for different message -->
+ <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
+ <messageBuilders>
+ <messageBuilder contentType="application/xml"
+ class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
+ <messageBuilder contentType="application/x-www-form-urlencoded"
+ class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
+ <!--JSON Message Builders-->
+ <messageBuilder contentType="application/json"
+ class="org.apache.axis2.json.JSONOMBuilder"/>
+ <messageBuilder contentType="application/json/badgerfish"
+ class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
+ <messageBuilder contentType="text/javascript"
+ class="org.apache.axis2.json.JSONOMBuilder"/>
+ <!--Left commented because it adds the depandancy of servlet-api to other modules.
+ Please uncomment to Receive messages in multipart/form-data format-->
+ <!--<messageBuilder contentType="multipart/form-data"-->
+ <!--class="org.apache.axis2.builder.MultipartFormDataBuilder"/>-->
+ </messageBuilders>
+
+ <!-- ================================================= -->
+ <!-- Target Resolvers -->
+ <!-- ================================================= -->
+ <!-- Uncomment the following and specify the class name for your TargetResolver to add -->
+ <!-- a TargetResolver. TargetResolvers are used to process the To EPR for example to -->
+ <!-- choose a server in a cluster -->
+ <!--<targetResolvers>-->
+ <!--<targetResolver class="" />-->
+ <!--</targetResolvers>-->
+
+
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port">6071</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncomment following parameter , and set as you required.-->
+ <!--<parameter name="hostname">http://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!--Uncomment if you want to have TCP transport support-->
+ <!--<transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port">6061</parameter>-->
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncomment following parameter , and set as you required.-->
+ <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
+ <!--</transportReceiver>-->
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <!--<transportSender name="jms"-->
+ <!--class="org.apache.axis2.transport.jms.JMSSender"/>-->
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding">chunked</parameter>
+ <parameter name="SO_TIMEOUT">60000</parameter>
+ <parameter name="CONNECTION_TIMEOUT">60000</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding">chunked</parameter>
+ <parameter name="SO_TIMEOUT">60000</parameter>
+ <parameter name="CONNECTION_TIMEOUT">60000</parameter>
+ </transportSender>
+ <!--<transportSender name="java"-->
+ <!--class="org.apache.axis2.transport.java.JavaTransportSender"/>-->
+
+
+ <!-- ================================================= -->
+ <!-- SOAP Role Configuration -->
+ <!-- ================================================= -->
+ <!-- Use the following pattern to configure this axis2
+ instance to act in particular roles. Note that in
+ the absence of any configuration, Axis2 will act
+ only in the ultimate receiver role -->
+ <!--
+ <SOAPRoleConfiguration isUltimateReceiver="true">
+ <role>http://my/custom/role</role>
+ </SOAPRoleConfiguration>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="InFlow">
+ <!-- System pre-defined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ </phase>
+ <phase name="Addressing">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+ <order phase="Addressing"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+ <handler name="RequestURIOperationDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+
+ <handler name="HTTPLocationBasedDispatcher"
+ class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+ </phase>
+ <phase name="RMPhase"/>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="RMPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+ <phaseOrder type="InFaultFlow">
+ <phase name="Addressing">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+ <order phase="Addressing"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+ <handler name="RequestURIOperationDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+
+ <handler name="HTTPLocationBasedDispatcher"
+ class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+ </phase>
+ <phase name="RMPhase"/>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFaultFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="RMPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+</axisconfig>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml
new file mode 100644
index 0000000..c62912d
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/META-INF/webapp-classloading.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ # 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.
+ -->
+
+<!--
+ This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
+-->
+<Classloading xmlns="http://wso2.org/projects/as/classloading">
+
+ <!-- Parent-first or child-first. Default behaviour is child-first.-->
+ <ParentFirst>false</ParentFirst>
+
+ <!--
+ Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
+ Tomcat environment is the default and every webapps gets it even if they didn't specify it.
+ e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
+ -->
+ <Environments>CXF,Carbon</Environments>
+</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml
new file mode 100644
index 0000000..f8b8750
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/cxf-servlet.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ # 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.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
+
+ <jaxrs:server id="stratosAdmin" address="/">
+ <jaxrs:serviceBeans>
+ <ref bean="stratosRestEndpointTestBean"/>
+ </jaxrs:serviceBeans>
+
+ <jaxrs:providers>
+ <ref bean="throwableExceptionHandler"/>
+ <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
+ <property name="dropRootElement" value="true"/>
+ <property name="supportUnwrapped" value="true"/>
+ </bean>>
+ <ref bean="exceptionHandler"/>
+ </jaxrs:providers>
+ </jaxrs:server>
+
+ <bean id="stratosRestEndpointTestBean" class="org.apache.stratos.rest.endpoint.mock.StratosTestAdmin"/>
+ <bean id="exceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.CustomExceptionMapper"/>
+ <bean id="throwableExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.CustomThrowableExceptionMapper"/>
+</beans>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/web.xml b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/web.xml
new file mode 100644
index 0000000..4a752f6
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata-test/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ # 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.
+ -->
+
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>S2 Meta Data Admin Endpoint</display-name>
+
+ <servlet>
+ <servlet-name>StratosAdminEndpoint</servlet-name>
+ <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>StratosAdminEndpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/META-INF/webapp-classloading.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/META-INF/webapp-classloading.xml
new file mode 100644
index 0000000..c62912d
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/META-INF/webapp-classloading.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ # 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.
+ -->
+
+<!--
+ This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
+-->
+<Classloading xmlns="http://wso2.org/projects/as/classloading">
+
+ <!-- Parent-first or child-first. Default behaviour is child-first.-->
+ <ParentFirst>false</ParentFirst>
+
+ <!--
+ Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
+ Tomcat environment is the default and every webapps gets it even if they didn't specify it.
+ e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
+ -->
+ <Environments>CXF,Carbon</Environments>
+</Classloading>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml
new file mode 100644
index 0000000..7b0c60c
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/cxf-servlet.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ # 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.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
+
+ <jaxrs:server id="stratosMetaDataAdmin" address="/api">
+ <jaxrs:serviceBeans>
+ <ref bean="stratosRestEndpointBean"/>
+ </jaxrs:serviceBeans>
+
+ <jaxrs:providers>
+ <ref bean="throwableExceptionHandler"/>
+ <ref bean="genericExceptionHandler"/>
+ <ref bean="jsonProvider"/>
+ <ref bean="exceptionHandler"/>
+ <ref bean="OAuthFilter"/>
+ <ref bean="basicAuthenticationFilter"/>
+ <ref bean="sessionAuthenticationFilter"/>
+ <!--<ref bean="authorizationFilter"/>-->
+ </jaxrs:providers>
+ </jaxrs:server>
+
+ <bean id="stratosRestEndpointBean" class="org.apache.stratos.metadata.service.services.MetaDataAdmin"/>
+ <bean id="basicAuthenticationFilter" class="org.apache.stratos.metadata.service.handlers.StratosAuthenticationHandler"/>
+ <bean id="sessionAuthenticationFilter" class="org.apache.stratos.metadata.service.handlers.CookieBasedAuthenticationHandler"/>
+ <bean id="authorizationFilter" class="org.apache.stratos.metadata.service.handlers.StratosAuthorizingHandler">
+ <property name="securedObject" ref="stratosRestEndpointBean"/>
+ </bean>
+ <bean id="exceptionHandler" class="org.apache.stratos.metadata.service.handlers.CustomExceptionMapper"/>
+ <bean id="genericExceptionHandler" class="org.apache.stratos.metadata.service.handlers.GenericExceptionMapper"/>
+ <bean id="throwableExceptionHandler" class="org.apache.stratos.metadata.service.handlers.CustomThrowableExceptionMapper"/>
+ <!--The below config enables OAuth based authentication/authorization for REST API-->
+ <bean id="OAuthFilter" class="org.apache.stratos.metadata.service.handlers.OAuthHandler">
+ <property name="password" value="admin"/>
+ <property name="username" value="admin"/>
+ <property name="oauthValidationEndpoint" value="https://localhost:9443/services/"/>
+ </bean>
+ <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
+ <property name="supportUnwrapped" value="true"/>
+ <property name="serializeAsArray" value="true"/>
+ <property name="dropRootElement" value="true" />
+ <property name="arrayKeys">
+ <list>
+ <value>partitions</value>
+ <value>property</value>
+ <value>hostNames</value>
+ <value>memberMap</value>
+ <value>portMap</value>
+ <value>partitionGroup</value>
+ <value>partition</value>
+ <value>member</value>
+ <value>hostNames</value>
+ <value>portMappings</value>
+ <value>volumes</value>
+ </list>
+ </property>
+ </bean>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/web.xml b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/web.xml
new file mode 100644
index 0000000..a46ee34
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/webapp/metadata/WEB-INF/web.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ # 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.
+ -->
+
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>S2 Admin Endpoint</display-name>
+ <servlet>
+ <servlet-name>StratosAdminEndpoint</servlet-name>
+ <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>StratosAdminEndpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/pom.xml b/components/org.apache.stratos.metadataservice/pom.xml
deleted file mode 100644
index 0ee9a0d..0000000
--- a/components/org.apache.stratos.metadataservice/pom.xml
+++ /dev/null
@@ -1,162 +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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.stratos</groupId>
- <artifactId>stratos-components-parent</artifactId>
- <version>4.1.0-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.apache.stratos.metadataservice</artifactId>
- <packaging>war</packaging>
- <name>Apache Stratos - Meta Data Service</name>
-
- <profiles>
- <profile>
- <id>test</id>
- <activation>
- <property>
- <name>env</name>
- <value>test</value>
- </property>
- </activation>
- <properties>
- <appName>metadata-test</appName>
- </properties>
- </profile>
- <profile>
- <id>prod</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <appName>metadata</appName>
- </properties>
- </profile>
- </profiles>
-
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- <version>2.3.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.2</version>
- <configuration>
- <webResources>
- <resource>
- <!-- this is relative to the pom.xml directory -->
- <directory>src/main/webapp/${appName}</directory>
- </resource>
- </webResources>
- <warName>metadata</warName>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-bundle</artifactId>
- <version>2.7.7</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.core</artifactId>
- <version>${wso2carbon.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.utils</artifactId>
- <version>${wso2carbon.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
- <version>${wso2carbon.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.tenant.mgt</artifactId>
- <version>2.2.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.common</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.manager</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.cloud.controller.service.stub</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.autoscaler.service.stub</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.messaging</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.ntask.core</artifactId>
- <version>${wso2carbon.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.registry.ws.stub</artifactId>
- <version>${wso2carbon.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.nimbusds.wso2</groupId>
- <artifactId>nimbus-jose-jwt</artifactId>
- <version>2.26.1.wso2v2</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java
deleted file mode 100644
index f526d9e..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java
+++ /dev/null
@@ -1,28 +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;
-
-/**
- * Global constants used in this module
- */
-public class Constants {
-
- public static final String METADATASERVICE_CONFIG_FILE_NAME = "metadataservice.xml";
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java
deleted file mode 100644
index f925924..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java
+++ /dev/null
@@ -1,84 +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;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.TenantBillingService;
-import org.wso2.carbon.tenant.mgt.core.TenantPersistor;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-import org.wso2.carbon.utils.ConfigurationContextService;
-
-/**
- * Some of the admin services needs objects with states inside the runtime.
- * There are
- * two mechanisms to get those kind of objects. Either with singleton with or
- * via OSGi
- * services. OSGi services mechanism is preferred. This is a helper class for
- * doing that.
- */
-public class ServiceHolder {
- private static Log log = LogFactory.getLog(ServiceHolder.class);
-
- public static TenantManager getTenantManager() {
- PrivilegedCarbonContext carbonContext =
- PrivilegedCarbonContext.getThreadLocalCarbonContext();
- RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class);
- return realmService.getTenantManager();
- }
-
- public static TenantBillingService getBillingService() {
- PrivilegedCarbonContext carbonContext =
- PrivilegedCarbonContext.getThreadLocalCarbonContext();
- TenantBillingService tenantBillingService =
- (TenantBillingService) carbonContext.getOSGiService(TenantBillingService.class);
- return tenantBillingService;
- }
-
- public static RealmService getRealmService() {
- PrivilegedCarbonContext carbonContext =
- PrivilegedCarbonContext.getThreadLocalCarbonContext();
- RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class);
- return realmService;
- }
-
- public static RegistryService getRegistryService() {
- PrivilegedCarbonContext carbonContext =
- PrivilegedCarbonContext.getThreadLocalCarbonContext();
- RegistryService registryService =
- (RegistryService) carbonContext.getOSGiService(RegistryService.class);
- return registryService;
- }
-
- public static TenantPersistor getTenantPersistor() {
- TenantPersistor tenantPersistor = new TenantPersistor();
- return tenantPersistor;
- }
-
- public static ConfigurationContextService getConfigurationContext() {
- PrivilegedCarbonContext carbonContext =
- PrivilegedCarbonContext.getThreadLocalCarbonContext();
- ConfigurationContextService configurationContextService =
- (ConfigurationContextService) carbonContext.getOSGiService(ConfigurationContextService.class);
- return configurationContextService;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java
deleted file mode 100644
index 42b100a..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java
+++ /dev/null
@@ -1,44 +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;
-
-public class Utils {
-
- public static String buildMessage(int errorCode, String errorMessage) {
- String jsonResponse =
- "{\"Error\":{" + " \"errorCode\": \" " + errorCode + "\"," +
- " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}";
- return jsonResponse;
- }
-
- public static String buildMessage(String errorMessage) {
- String jsonResponse =
- "{\"Error\":{" + " \"errorCode\": \" " + -1234 + "\"," +
- " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}";
- return jsonResponse;
- }
-
- public static String buildAuthenticationSuccessMessage(String jSessionId) {
- String jsonResponse =
- "{\"Success\":{" + " \"sessionId\": \"" + jSessionId + "\"" + "}" +
- "}";
- return jsonResponse;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java
deleted file mode 100644
index a6c8765..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java
+++ /dev/null
@@ -1,36 +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.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Carbon kernel handles permissions by means of permission strings.
- * Permission strings are defined at the operation level. Here the admin
- * service developer has to specify authorization requirements using
- * the below annotation
- */
-@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = ElementType.METHOD)
-public @interface AuthorizationAction {
- String[] value();
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java
deleted file mode 100644
index 761faa4..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java
+++ /dev/null
@@ -1,34 +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.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * In Carbon admin authorization framework there are super-tenant only
- * admin services. We use below annotation to mark such admin services.
- */
-@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = ElementType.METHOD)
-public @interface SuperTenantService {
- boolean value();
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java
deleted file mode 100644
index 7adbff6..0000000
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.stratos.metadataservice.context;
-
-/*
- * 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.
- */
-
-public class AuthenticationContext {
- // maintaining the authenticated state in threadLocal. We want to skip
- // subsequent authentication handlers
- // once a request get authenticated by a handler.
- private static final ThreadLocal<Boolean> authenticated = new ThreadLocal<Boolean>() {
- @Override
- protected Boolean initialValue() {
- return false;
- }
- };
-
- public static boolean isAthenticated() {
- return authenticated.get();
- }
-
- public static void setAuthenticated(boolean isAuthenticated) {
- authenticated.set(isAuthenticated);
- }
-}
[3/5] stratos git commit: Renaming org.apache.stratos.metadataservice
to org.apache.stratos.metadata.service
Posted by im...@apache.org.
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();
- }
-
-
-}
[5/5] stratos git commit: Renaming org.apache.stratos.metadataservice
to org.apache.stratos.metadata.service
Posted by im...@apache.org.
Renaming org.apache.stratos.metadataservice to org.apache.stratos.metadata.service
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/958a3100
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/958a3100
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/958a3100
Branch: refs/heads/master
Commit: 958a3100a833e4de7f8fdb710099c44469853936
Parents: 60bca14
Author: Imesh Gunaratne <im...@apache.org>
Authored: Sun Jan 25 11:02:18 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sun Jan 25 11:02:19 2015 +0530
----------------------------------------------------------------------
.../org.apache.stratos.metadata.service/pom.xml | 162 +++++++++
.../stratos/metadata/service/Constants.java | 28 ++
.../stratos/metadata/service/ServiceHolder.java | 84 +++++
.../apache/stratos/metadata/service/Utils.java | 44 +++
.../service/annotation/AuthorizationAction.java | 36 ++
.../service/annotation/SuperTenantService.java | 34 ++
.../service/context/AuthenticationContext.java | 40 +++
.../service/definition/ApplicationBean.java | 70 ++++
.../service/definition/CartridgeMetaData.java | 36 ++
.../service/definition/ClusterBean.java | 59 ++++
.../service/definition/NewProperty.java | 68 ++++
.../service/definition/PropertyBean.java | 61 ++++
.../service/exception/MetadataException.java | 9 +
.../service/exception/RestAPIException.java | 70 ++++
...tractAuthenticationAuthorizationHandler.java | 56 ++++
.../CookieBasedAuthenticationHandler.java | 94 ++++++
.../service/handlers/CustomExceptionMapper.java | 47 +++
.../CustomThrowableExceptionMapper.java | 44 +++
.../handlers/GenericExceptionMapper.java | 54 +++
.../metadata/service/handlers/OAuthHandler.java | 133 ++++++++
.../handlers/StratosAuthenticationHandler.java | 156 +++++++++
.../handlers/StratosAuthorizingHandler.java | 322 ++++++++++++++++++
.../service/oauth2/ValidationServiceClient.java | 65 ++++
.../service/registry/CarbonRegistry.java | 191 +++++++++++
.../service/registry/DataRegistryFactory.java | 33 ++
.../metadata/service/registry/DataStore.java | 41 +++
.../service/security/StratosPrincipal.java | 53 +++
.../security/StratosSecurityContext.java | 50 +++
.../service/services/MetaDataAdmin.java | 195 +++++++++++
.../stratos/metadata/service/util/ConfUtil.java | 76 +++++
.../src/main/resources/axis2_client.xml | 299 +++++++++++++++++
.../META-INF/webapp-classloading.xml | 35 ++
.../metadata-test/WEB-INF/cxf-servlet.xml | 46 +++
.../main/webapp/metadata-test/WEB-INF/web.xml | 40 +++
.../metadata/META-INF/webapp-classloading.xml | 35 ++
.../webapp/metadata/WEB-INF/cxf-servlet.xml | 81 +++++
.../src/main/webapp/metadata/WEB-INF/web.xml | 39 +++
.../org.apache.stratos.metadataservice/pom.xml | 162 ---------
.../stratos/metadataservice/Constants.java | 28 --
.../stratos/metadataservice/ServiceHolder.java | 84 -----
.../apache/stratos/metadataservice/Utils.java | 44 ---
.../annotation/AuthorizationAction.java | 36 --
.../annotation/SuperTenantService.java | 34 --
.../context/AuthenticationContext.java | 40 ---
.../definition/ApplicationBean.java | 70 ----
.../definition/CartridgeMetaData.java | 36 --
.../metadataservice/definition/ClusterBean.java | 59 ----
.../metadataservice/definition/NewProperty.java | 68 ----
.../definition/PropertyBean.java | 61 ----
.../exception/MetadataException.java | 9 -
.../exception/RestAPIException.java | 70 ----
...tractAuthenticationAuthorizationHandler.java | 56 ----
.../CookieBasedAuthenticationHandler.java | 94 ------
.../handlers/CustomExceptionMapper.java | 47 ---
.../CustomThrowableExceptionMapper.java | 44 ---
.../handlers/GenericExceptionMapper.java | 54 ---
.../metadataservice/handlers/OAuthHandler.java | 133 --------
.../handlers/StratosAuthenticationHandler.java | 156 ---------
.../handlers/StratosAuthorizingHandler.java | 333 -------------------
.../oauth2/ValidationServiceClient.java | 65 ----
.../registry/CarbonRegistry.java | 191 -----------
.../registry/DataRegistryFactory.java | 33 --
.../metadataservice/registry/DataStore.java | 41 ---
.../security/StratosPrincipal.java | 53 ---
.../security/StratosSecurityContext.java | 50 ---
.../metadataservice/services/MetaDataAdmin.java | 195 -----------
.../stratos/metadataservice/util/ConfUtil.java | 76 -----
.../src/main/resources/axis2_client.xml | 299 -----------------
.../META-INF/webapp-classloading.xml | 35 --
.../metadata-test/WEB-INF/cxf-servlet.xml | 46 ---
.../main/webapp/metadata-test/WEB-INF/web.xml | 40 ---
.../metadata/META-INF/webapp-classloading.xml | 35 --
.../webapp/metadata/WEB-INF/cxf-servlet.xml | 81 -----
.../src/main/webapp/metadata/WEB-INF/web.xml | 39 ---
components/pom.xml | 2 +-
.../pom.xml | 316 ++++++++++++++++++
.../src/main/resources/p2.inf | 23 ++
.../src/main/resources/tomcat/context.xml | 36 ++
.../tomcat/webapp-classloading-environments.xml | 68 ++++
.../resources/tomcat/webapp-classloading.xml | 33 ++
.../pom.xml | 316 ------------------
.../src/main/resources/p2.inf | 23 --
.../src/main/resources/tomcat/context.xml | 36 --
.../tomcat/webapp-classloading-environments.xml | 68 ----
.../resources/tomcat/webapp-classloading.xml | 33 --
features/manager/pom.xml | 2 +-
.../pom.xml | 47 ++-
products/stratos/modules/p2-profile-gen/pom.xml | 12 +-
88 files changed, 3492 insertions(+), 3506 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/pom.xml b/components/org.apache.stratos.metadata.service/pom.xml
new file mode 100644
index 0000000..0daf649
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/pom.xml
@@ -0,0 +1,162 @@
+<!--
+ # 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>stratos-components-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.metadata.service</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Stratos - Meta Data Service</name>
+
+ <profiles>
+ <profile>
+ <id>test</id>
+ <activation>
+ <property>
+ <name>env</name>
+ <value>test</value>
+ </property>
+ </activation>
+ <properties>
+ <appName>metadata-test</appName>
+ </properties>
+ </profile>
+ <profile>
+ <id>prod</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <appName>metadata</appName>
+ </properties>
+ </profile>
+ </profiles>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ <version>2.3.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <webResources>
+ <resource>
+ <!-- this is relative to the pom.xml directory -->
+ <directory>src/main/webapp/${appName}</directory>
+ </resource>
+ </webResources>
+ <warName>metadata</warName>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-bundle</artifactId>
+ <version>2.7.7</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.core</artifactId>
+ <version>${wso2carbon.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.utils</artifactId>
+ <version>${wso2carbon.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
+ <version>${wso2carbon.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.tenant.mgt</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.common</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.manager</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.cloud.controller.service.stub</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.autoscaler.service.stub</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.messaging</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.ntask.core</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.ws.stub</artifactId>
+ <version>${wso2carbon.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.nimbusds.wso2</groupId>
+ <artifactId>nimbus-jose-jwt</artifactId>
+ <version>2.26.1.wso2v2</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Constants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Constants.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Constants.java
new file mode 100644
index 0000000..0027a47
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Constants.java
@@ -0,0 +1,28 @@
+/*
+ * 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.metadata.service;
+
+/**
+ * Global constants used in this module
+ */
+public class Constants {
+
+ public static final String METADATASERVICE_CONFIG_FILE_NAME = "metadataservice.xml";
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/ServiceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/ServiceHolder.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/ServiceHolder.java
new file mode 100644
index 0000000..4a6a8cc
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/ServiceHolder.java
@@ -0,0 +1,84 @@
+/*
+ * 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.metadata.service;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.TenantBillingService;
+import org.wso2.carbon.tenant.mgt.core.TenantPersistor;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+/**
+ * Some of the admin services needs objects with states inside the runtime.
+ * There are
+ * two mechanisms to get those kind of objects. Either with singleton with or
+ * via OSGi
+ * services. OSGi services mechanism is preferred. This is a helper class for
+ * doing that.
+ */
+public class ServiceHolder {
+ private static Log log = LogFactory.getLog(ServiceHolder.class);
+
+ public static TenantManager getTenantManager() {
+ PrivilegedCarbonContext carbonContext =
+ PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class);
+ return realmService.getTenantManager();
+ }
+
+ public static TenantBillingService getBillingService() {
+ PrivilegedCarbonContext carbonContext =
+ PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ TenantBillingService tenantBillingService =
+ (TenantBillingService) carbonContext.getOSGiService(TenantBillingService.class);
+ return tenantBillingService;
+ }
+
+ public static RealmService getRealmService() {
+ PrivilegedCarbonContext carbonContext =
+ PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class);
+ return realmService;
+ }
+
+ public static RegistryService getRegistryService() {
+ PrivilegedCarbonContext carbonContext =
+ PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ RegistryService registryService =
+ (RegistryService) carbonContext.getOSGiService(RegistryService.class);
+ return registryService;
+ }
+
+ public static TenantPersistor getTenantPersistor() {
+ TenantPersistor tenantPersistor = new TenantPersistor();
+ return tenantPersistor;
+ }
+
+ public static ConfigurationContextService getConfigurationContext() {
+ PrivilegedCarbonContext carbonContext =
+ PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ConfigurationContextService configurationContextService =
+ (ConfigurationContextService) carbonContext.getOSGiService(ConfigurationContextService.class);
+ return configurationContextService;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Utils.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Utils.java
new file mode 100644
index 0000000..951bc59
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/Utils.java
@@ -0,0 +1,44 @@
+/**
+ * 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.metadata.service;
+
+public class Utils {
+
+ public static String buildMessage(int errorCode, String errorMessage) {
+ String jsonResponse =
+ "{\"Error\":{" + " \"errorCode\": \" " + errorCode + "\"," +
+ " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}";
+ return jsonResponse;
+ }
+
+ public static String buildMessage(String errorMessage) {
+ String jsonResponse =
+ "{\"Error\":{" + " \"errorCode\": \" " + -1234 + "\"," +
+ " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}";
+ return jsonResponse;
+ }
+
+ public static String buildAuthenticationSuccessMessage(String jSessionId) {
+ String jsonResponse =
+ "{\"Success\":{" + " \"sessionId\": \"" + jSessionId + "\"" + "}" +
+ "}";
+ return jsonResponse;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/AuthorizationAction.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/AuthorizationAction.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/AuthorizationAction.java
new file mode 100644
index 0000000..16a8d14
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/AuthorizationAction.java
@@ -0,0 +1,36 @@
+/*
+ * 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.metadata.service.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Carbon kernel handles permissions by means of permission strings.
+ * Permission strings are defined at the operation level. Here the admin
+ * service developer has to specify authorization requirements using
+ * the below annotation
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = ElementType.METHOD)
+public @interface AuthorizationAction {
+ String[] value();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/SuperTenantService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/SuperTenantService.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/SuperTenantService.java
new file mode 100644
index 0000000..df75adc
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/annotation/SuperTenantService.java
@@ -0,0 +1,34 @@
+/*
+ * 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.metadata.service.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * In Carbon admin authorization framework there are super-tenant only
+ * admin services. We use below annotation to mark such admin services.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = ElementType.METHOD)
+public @interface SuperTenantService {
+ boolean value();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/context/AuthenticationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/context/AuthenticationContext.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/context/AuthenticationContext.java
new file mode 100644
index 0000000..d975ae1
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/context/AuthenticationContext.java
@@ -0,0 +1,40 @@
+package org.apache.stratos.metadata.service.context;
+
+/*
+ * 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.
+ */
+
+public class AuthenticationContext {
+ // maintaining the authenticated state in threadLocal. We want to skip
+ // subsequent authentication handlers
+ // once a request get authenticated by a handler.
+ private static final ThreadLocal<Boolean> authenticated = new ThreadLocal<Boolean>() {
+ @Override
+ protected Boolean initialValue() {
+ return false;
+ }
+ };
+
+ public static boolean isAthenticated() {
+ return authenticated.get();
+ }
+
+ public static void setAuthenticated(boolean isAuthenticated) {
+ authenticated.set(isAuthenticated);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/958a3100/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ApplicationBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ApplicationBean.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ApplicationBean.java
new file mode 100644
index 0000000..84ad76d
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ApplicationBean.java
@@ -0,0 +1,70 @@
+/**
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/CartridgeMetaData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/CartridgeMetaData.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/CartridgeMetaData.java
new file mode 100644
index 0000000..dec5739
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/CartridgeMetaData.java
@@ -0,0 +1,36 @@
+package org.apache.stratos.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ClusterBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ClusterBean.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ClusterBean.java
new file mode 100644
index 0000000..7ac81f3
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/ClusterBean.java
@@ -0,0 +1,59 @@
+package org.apache.stratos.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java
new file mode 100644
index 0000000..b933d97
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/NewProperty.java
@@ -0,0 +1,68 @@
+/**
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/PropertyBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/PropertyBean.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/PropertyBean.java
new file mode 100644
index 0000000..06f293d
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/definition/PropertyBean.java
@@ -0,0 +1,61 @@
+/*
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/MetadataException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/MetadataException.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/MetadataException.java
new file mode 100644
index 0000000..4b14fd0
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/MetadataException.java
@@ -0,0 +1,9 @@
+package org.apache.stratos.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/RestAPIException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/RestAPIException.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/RestAPIException.java
new file mode 100644
index 0000000..edb9a59
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/exception/RestAPIException.java
@@ -0,0 +1,70 @@
+/*
+ * 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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/AbstractAuthenticationAuthorizationHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/AbstractAuthenticationAuthorizationHandler.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/AbstractAuthenticationAuthorizationHandler.java
new file mode 100644
index 0000000..f96bc69
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/AbstractAuthenticationAuthorizationHandler.java
@@ -0,0 +1,56 @@
+/**
+ * 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.metadata.service.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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CookieBasedAuthenticationHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CookieBasedAuthenticationHandler.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CookieBasedAuthenticationHandler.java
new file mode 100644
index 0000000..39bbaa5
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CookieBasedAuthenticationHandler.java
@@ -0,0 +1,94 @@
+/*
+ * 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.metadata.service.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.metadata.service.Utils;
+import org.apache.stratos.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomExceptionMapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomExceptionMapper.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomExceptionMapper.java
new file mode 100644
index 0000000..7e58c5d
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomExceptionMapper.java
@@ -0,0 +1,47 @@
+/**
+ * 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.metadata.service.handlers;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import org.apache.stratos.metadata.service.Utils;
+import org.apache.stratos.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomThrowableExceptionMapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomThrowableExceptionMapper.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomThrowableExceptionMapper.java
new file mode 100644
index 0000000..8db8df6
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/CustomThrowableExceptionMapper.java
@@ -0,0 +1,44 @@
+package org.apache.stratos.metadata.service.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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/GenericExceptionMapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/GenericExceptionMapper.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/GenericExceptionMapper.java
new file mode 100644
index 0000000..97016f8
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/GenericExceptionMapper.java
@@ -0,0 +1,54 @@
+/*
+ * 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.metadata.service.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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/OAuthHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/OAuthHandler.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/OAuthHandler.java
new file mode 100644
index 0000000..33d3b31
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/OAuthHandler.java
@@ -0,0 +1,133 @@
+/*
+ * 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.metadata.service.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.metadata.service.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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthenticationHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthenticationHandler.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthenticationHandler.java
new file mode 100644
index 0000000..53749b8
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthenticationHandler.java
@@ -0,0 +1,156 @@
+/*
+ * 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.metadata.service.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.metadata.service.ServiceHolder;
+import org.apache.stratos.metadata.service.security.StratosSecurityContext;
+import org.apache.stratos.metadata.service.Utils;
+import org.apache.stratos.metadata.service.context.AuthenticationContext;
+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.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthorizingHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthorizingHandler.java b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthorizingHandler.java
new file mode 100644
index 0000000..5b1c9a4
--- /dev/null
+++ b/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/handlers/StratosAuthorizingHandler.java
@@ -0,0 +1,322 @@
+/*
+ * 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.metadata.service.handlers;
+
+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.metadata.service.Utils;
+import org.apache.stratos.metadata.service.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;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * {@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.metadata.service.annotation.AuthorizationAction";
+ private static final String TENANT_ANNOTATION_CLASS_NAME =
+ "org.apache.stratos.metadata.service.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"}));
+ }
+
+ 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;
+ }
+}