You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2015/05/14 16:41:12 UTC

[1/3] stratos git commit: this fix the issue of allowing to access metadata service without token

Repository: stratos
Updated Branches:
  refs/heads/master fa139b0d4 -> 5e5d78f19


this fix the issue of allowing to access metadata service without token


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5e5d78f1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5e5d78f1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5e5d78f1

Branch: refs/heads/master
Commit: 5e5d78f1934cd02e77b3018bb9a57d25df567429
Parents: c223eab
Author: Udara Liyanage <ud...@wso2.com>
Authored: Thu May 14 19:59:40 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Thu May 14 20:01:48 2015 +0530

----------------------------------------------------------------------
 .../AbstractAuthenticationAuthorizationHandler.java  | 15 ++++++---------
 .../metadata/service/handlers/OAuthHandler.java      |  9 ++++++---
 .../metadata/service/registry/CarbonRegistry.java    |  4 ----
 .../metadata/service/services/MetaDataAdmin.java     |  2 +-
 4 files changed, 13 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/5e5d78f1/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
index 4be5efe..a6abcd9 100644
--- 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
@@ -18,6 +18,7 @@
  */
 package org.apache.stratos.metadata.service.handlers;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
@@ -36,17 +37,13 @@ public abstract class AbstractAuthenticationAuthorizationHandler implements Requ
     @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])) {
+
+        if (!StringUtils.isEmpty(headers.getRequestHeaders().getFirst(HttpHeaders.AUTHORIZATION))) {
             return handle(message, classResourceInfo);
+        }else{
+            // Currently there is only one handler
+            return Response.status(Response.Status.FORBIDDEN).build();
         }
-        // give the control to the next handler
-        return null;
-
     }
 
     protected abstract boolean canHandle(String authHeaderPrefix);

http://git-wip-us.apache.org/repos/asf/stratos/blob/5e5d78f1/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
index 431fd2e..c53a157 100644
--- 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
@@ -76,15 +76,18 @@ public class OAuthHandler extends AbstractAuthenticationAuthorizationHandler {
             if (header.startsWith(BEARER)) {
                 String accessToken = header.substring(7).trim();
                 boolean valid;
-                String appId = extractAppIdFromIdToken(accessToken);
+                String appId_in_token = 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)) {
+                if (org.apache.commons.lang3.StringUtils.isEmpty(appId_in_token) || org.apache.commons.lang3.StringUtils.isEmpty(requestedAppId)) {
                     valid = false;
                 } else {
-                    valid = appId.equals(requestedAppId);
+                    valid = appId_in_token.equals(requestedAppId);
+                    if(!valid){
+                        log.error("The token presented is only valid for " + appId_in_token + " , but it tries to access metadata for " + requestedAppId);
+                    }
                 }
 
                 if (!valid) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/5e5d78f1/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
index 03f7d40..a84ea79 100644
--- 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
@@ -139,10 +139,6 @@ public class CarbonRegistry implements DataStore {
                     log.debug("Registry resource is create at path for application: " + nodeResource.getPath());
                 }
             }
-            
-            for(String value : property.getValues()){
-                nodeResource.addProperty(property.getKey(), value);
-            }
 
             boolean updated = false;
             for(String value : property.getValues()){

http://git-wip-us.apache.org/repos/asf/stratos/blob/5e5d78f1/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
index 4813679..2a4360c 100644
--- 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
@@ -226,7 +226,7 @@ public class MetaDataAdmin {
     }
 
     @DELETE
-    @Path("application/{application_id}")
+    @Path("application/{application_id}/properties")
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")


[3/3] stratos git commit: removing metadataservice.xml and its references

Posted by ud...@apache.org.
removing metadataservice.xml and its references


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e13e202b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e13e202b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e13e202b

Branch: refs/heads/master
Commit: e13e202b26d0466879b69011f628204ae6cff1c1
Parents: fa139b0
Author: Udara Liyanage <ud...@wso2.com>
Authored: Thu May 14 13:44:05 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Thu May 14 20:01:48 2015 +0530

----------------------------------------------------------------------
 .../service/registry/DataRegistryFactory.java   | 33 ---------
 .../service/services/MetaDataAdmin.java         |  9 +--
 .../stratos/metadata/service/util/ConfUtil.java | 74 --------------------
 .../modules/distribution/src/assembly/bin.xml   |  6 --
 .../modules/distribution/src/bin/stratos.sh     |  1 -
 .../src/main/conf/metadataservice.xml           | 43 ------------
 6 files changed, 2 insertions(+), 164 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e13e202b/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
deleted file mode 100644
index 298fffd..0000000
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/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.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/e13e202b/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
index 68b960c..4813679 100644
--- 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
@@ -18,15 +18,13 @@
  */
 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.Property;
 import org.apache.stratos.metadata.service.exception.RestAPIException;
-import org.apache.stratos.metadata.service.registry.DataRegistryFactory;
+import org.apache.stratos.metadata.service.registry.CarbonRegistry;
 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.*;
@@ -47,10 +45,7 @@ public class MetaDataAdmin {
      * 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);
+        registry = new CarbonRegistry();
     }
 
     @GET

http://git-wip-us.apache.org/repos/asf/stratos/blob/e13e202b/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
deleted file mode 100644
index fcf12f9..0000000
--- a/components/org.apache.stratos.metadata.service/src/main/java/org/apache/stratos/metadata/service/util/ConfUtil.java
+++ /dev/null
@@ -1,74 +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.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 static ConfUtil instance = null;
-    private XMLConfiguration config;
-
-    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/e13e202b/products/stratos/modules/distribution/src/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/assembly/bin.xml b/products/stratos/modules/distribution/src/assembly/bin.xml
index 0a02e62..f74794a 100755
--- a/products/stratos/modules/distribution/src/assembly/bin.xml
+++ b/products/stratos/modules/distribution/src/assembly/bin.xml
@@ -694,12 +694,6 @@
             <fileMode>600</fileMode>
         </file>
         <file>
-            <source>src/main/conf/metadataservice.xml</source>
-            <outputDirectory>${pom.artifactId}-${pom.version}/repository/conf</outputDirectory>
-            <filtered>true</filtered>
-            <fileMode>600</fileMode>
-        </file>
-        <file>
             <source>src/main/conf/drools/mincheck.drl</source>
             <outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/drools</outputDirectory>
             <filtered>true</filtered>

http://git-wip-us.apache.org/repos/asf/stratos/blob/e13e202b/products/stratos/modules/distribution/src/bin/stratos.sh
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/bin/stratos.sh b/products/stratos/modules/distribution/src/bin/stratos.sh
index 1935794..e88cc15 100755
--- a/products/stratos/modules/distribution/src/bin/stratos.sh
+++ b/products/stratos/modules/distribution/src/bin/stratos.sh
@@ -301,7 +301,6 @@ do
     -Ddisable.cassandra.server.startup=true \
     -Djndi.properties.dir="$CARBON_HOME/repository/conf" \
     -Dthrift.client.config.file.path="$CARBON_HOME/repository/conf/thrift-client-config.xml" \
-    -DMETADATA_CLIENT_CONFIG_FILE="$CARBON_HOME/repository/conf/metadataservice.xml" \
     -Dstratos.component.startup.synchronizer.enabled=true \
     org.wso2.carbon.bootstrap.Bootstrap $*
     status=$?

http://git-wip-us.apache.org/repos/asf/stratos/blob/e13e202b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml
deleted file mode 100644
index 3f2d217..0000000
--- a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml
+++ /dev/null
@@ -1,43 +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.
--->
-<configuration>
-	<!--
-	<metadataservice>
-	    <govenanceregistrytype>carbon</govenanceregistrytype>
-	    <serverurl>https://localhost:9445/services/</serverurl>
-		<username>admin</username>
-		<password>admin</password>
-		
-		<mainResource>stratos</mainResource>
-		<axis2Repo>repository/deployment/client</axis2Repo>
-		<axis2Conf>repository/conf/axis2/axis2_client.xml</axis2Conf>
-		<trustStore>repository/resources/security/wso2carbon.jks</trustStore>
-		<trustStorePassword>wso2carbon</trustStorePassword>
-		<trustStoreType>JKS</trustStoreType>
-	</metadataservice>
-	-->
-     <metadataService>
-         <baseUrl>https://localhost:9443/metadata/api/</baseUrl>
-         <username>admin</username>
-         <password>admin</password>
-     </metadataService>
-     <metadataClient>
-     </metadataClient>
-</configuration>


[2/3] stratos git commit: removing unused conf/multitenancy-billing-rules.drl

Posted by ud...@apache.org.
removing unused conf/multitenancy-billing-rules.drl


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c223eab2
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c223eab2
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c223eab2

Branch: refs/heads/master
Commit: c223eab2320a2fb0244d47dc52e8ba9d2b9553f6
Parents: e13e202
Author: Udara Liyanage <ud...@wso2.com>
Authored: Thu May 14 14:47:12 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Thu May 14 20:01:48 2015 +0530

----------------------------------------------------------------------
 .../stratos/conf/multitenancy-billing-rules.drl | 53 --------------------
 1 file changed, 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/c223eab2/products/stratos/conf/multitenancy-billing-rules.drl
----------------------------------------------------------------------
diff --git a/products/stratos/conf/multitenancy-billing-rules.drl b/products/stratos/conf/multitenancy-billing-rules.drl
deleted file mode 100755
index 20a45c6..0000000
--- a/products/stratos/conf/multitenancy-billing-rules.drl
+++ /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.
- */
-
-import org.wso2.carbon.billing.core.dataobjects.*;
-import org.wso2.carbon.billing.mgt.dataobjects.*;
-
-
-rule smallSubscription
-when
-$item: MultitenancyPackage(name == "SMB")
-$subItem: Item(parent == $item && name == "subscription")
-then
-$subItem.setCost(new Cash("$100"));
-$subItem.setCreditLimit(new Cash("$200"));
-end
-
-
-rule mediumSubscription
-when
-$item: MultitenancyPackage(name == "Professional")
-$subItem: Item(parent == $item && name == "subscription")
-then
-$subItem.setCost(new Cash("$500"));
-$subItem.setCreditLimit(new Cash("$1000"));
-end
-
-
-rule largeSubscription
-when
-$item: MultitenancyPackage(name == "Enterprise")
-$subItem: Item(parent == $item && name == "subscription")
-then
-$subItem.setCost(new Cash("$2000"));
-$subItem.setCreditLimit(new Cash("$4000"));
-end
-
-