You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ma...@apache.org on 2019/08/07 03:19:00 UTC

[servicecomb-samples] branch houserush-sample updated (a868bac -> e11f3f9)

This is an automated email from the ASF dual-hosted git repository.

mabin pushed a change to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git.


    from a868bac  change misspell in Readme.md
     new 872cc38  format little change for README.md
     new 0fddf7d  first commit for house-order microservice
     new 5aee0ac  change the exception message from chinese to english
     new e11f3f9  Merge pull request #13 from alec-z/new_houserush_sample

The 32 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 houserush/README.md                                |   2 +-
 houserush/house-order/README.md                    |  95 ++++++++++++++
 .../houserush/sale/HouseOrderApplication.java      |  21 ++-
 .../practise/houserush/sale/HouseOrderConfig.java  |  12 +-
 .../houserush/sale/aggregate/HouseOrder.java       |  59 +++++++++
 .../practise/houserush/sale/aggregate/Sale.java    |  71 +++++++++++
 .../practise/houserush/sale/api/HouseOrderApi.java |  25 +++-
 .../houserush/sale/api/HouseOrderApiRestImpl.java  |  75 +++++++++++
 .../practise/houserush/sale/dao/HouseOrderDao.java |  38 ++++++
 .../practise/houserush/sale/dao/SaleDao.java       |  10 +-
 .../houserush/sale/rpc/CustomerManageApi.java      |  12 +-
 .../practise/houserush/sale/rpc/RealestateApi.java |  15 ++-
 .../practise/houserush/sale/rpc/po/Customer.java   |  17 ++-
 .../practise/houserush/sale/rpc/po/House.java      |  13 +-
 .../houserush/sale/rpc/po/Qualification.java       |  13 +-
 .../practise/houserush/sale/rpc/po/Realestate.java |  13 +-
 .../houserush/sale/service/HouseOrderService.java  |  23 +++-
 .../sale/service/HouseOrderServiceImpl.java        | 141 +++++++++++++++++++++
 .../src/main/resources/microservice.yaml           |  43 +++----
 19 files changed, 614 insertions(+), 84 deletions(-)
 create mode 100644 houserush/house-order/README.md
 copy dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderApplication.java (58%)
 copy authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderConfig.java (70%)
 create mode 100644 houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/HouseOrder.java
 create mode 100644 houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/Sale.java
 copy porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApi.java (59%)
 create mode 100644 houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApiRestImpl.java
 create mode 100644 houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/HouseOrderDao.java
 copy dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/SaleDao.java (74%)
 copy dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/CustomerManageApi.java (74%)
 copy porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/RealestateApi.java (70%)
 copy porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Customer.java (79%)
 copy authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/House.java (82%)
 copy authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Qualification.java (82%)
 copy authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Realestate.java (82%)
 copy porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java => houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderService.java (59%)
 create mode 100644 houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java
 copy {authentication/samples/ResourceServer => houserush/house-order}/src/main/resources/microservice.yaml (65%)


[servicecomb-samples] 20/32: add project index

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 8e5bdc9494ecc28001693e325de85bd92a028531
Author: liubao <ba...@huawei.com>
AuthorDate: Mon May 13 15:59:24 2019 +0800

    add project index
---
 README.md | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/README.md b/README.md
index c1d8c06..d066de4 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
 # ServiceComb samples
 
+## authentication
+A sample shows how to integrate with spring security. This project provides handler authorization and method authorization.
+
 ## porter_lightweight
 A sample shows an application with basic login, download file, delete file functions. 
 
@@ -9,6 +12,9 @@ A sample shows how to use dependency management to create spring 4, spring 5, sp
 
 # 使用ServiceComb开发微服务的示例项目
 
+## authentication
+该项目演示了基于spring security框架实现认证鉴权。项目演示了如何通过配置的方式定义每个接口的权限,也演示了如何通过@PreAuthorize的方式实现权限控制。
+
 ## porter_lightweight
 该项目演示了一个包括网关、文件下载、认证鉴权等功能的简单应用系统,同时演示了ServiceComb推荐的先写接口声明,再写业务代码的软件工程实践。
 


[servicecomb-samples] 12/32: demo enable inspector and fix context error

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 135b17a3b638839dd0f8a75d185318ca876ce2fd
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Apr 19 14:58:04 2019 +0800

    demo enable inspector and fix context error
---
 .../apache/servicecomb/samples/porter/gateway/ApiDispatcher.java    | 6 +++---
 porter_lightweight/pom.xml                                          | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
index 3057c1f..e801ebd 100644
--- a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
@@ -47,9 +47,9 @@ public class ApiDispatcher extends AbstractEdgeDispatcher {
     String path = "/" + pathParams.get("param1");
 
     EdgeInvocation invoker = new EdgeInvocation() {
-      // Authentication
-      protected void createInvocation() {
-        super.createInvocation();
+      // Authentication. Notice: adding context must after setContext or will override by network
+      protected void setContext() throws Exception {
+        super.setContext();
         // get session id from header and cookie for debug reasons
         String sessionId = context.request().getHeader("session-id");
         if (sessionId != null) {
diff --git a/porter_lightweight/pom.xml b/porter_lightweight/pom.xml
index 08a5500..1892c79 100644
--- a/porter_lightweight/pom.xml
+++ b/porter_lightweight/pom.xml
@@ -62,6 +62,10 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
+        <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
   </dependencies>
 
   <modules>


[servicecomb-samples] 07/32: spell

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 1bdcbdeb841c83ee6c0694511ab8738301447954
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Mar 8 16:15:25 2019 +0800

    spell
---
 porter_lightweight/user-service/.gitignore           |  1 -
 .../samples/porter/user/service/UserServiceImpl.java |  2 +-
 .../src/main/resources/config/create_db_user.sql     | 20 ++++++++++----------
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/porter_lightweight/user-service/.gitignore b/porter_lightweight/user-service/.gitignore
deleted file mode 100644
index b83d222..0000000
--- a/porter_lightweight/user-service/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
index 2d49b46..5f69582 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
@@ -83,7 +83,7 @@ public class UserServiceImpl implements UserService {
   }
 
   private boolean validatePassword(String plain, String encrypt) {
-    // 简单加密校验,开发者可以结合业务场景自行修改
+    // simple password encryption, please change it in product environment if necessary. e.g. add salts for each encryption.
     try {
       MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
       messageDigest.update(plain.getBytes("UTF-8"));
diff --git a/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql b/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql
index 3505f3d..a07c5d9 100644
--- a/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql
+++ b/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql
@@ -22,10 +22,10 @@ USE porter_user_db;
 DROP TABLE IF EXISTS T_USER;
 
 CREATE TABLE `T_USER` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT '用户名称',
-  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT '用户密码',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT '角色名称',
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
   PRIMARY KEY (`ID`)
 );
 
@@ -36,11 +36,11 @@ insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWa
 DROP TABLE IF EXISTS T_SESSION;
 
 CREATE TABLE `T_SESSION` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '唯一标识',
-  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT '临时会话ID',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT '用户名称',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT '角色名称',
-  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近活跃时间',
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
   PRIMARY KEY (`ID`)
 );


[servicecomb-samples] 25/32: new houserush sample framework

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 1d8098151bb081276551539e8536d9a3e1b5b8a3
Author: alec.zheng <zh...@gmail.com>
AuthorDate: Wed Jul 24 18:23:06 2019 +0800

    new houserush sample framework
---
 houserush/README.md               |   2 +
 houserush/customer-manage/pom.xml |  86 +++++++++++++++++++++
 houserush/doc/pom.xml             |  15 ++++
 houserush/doc/proposal.md         |  16 ++++
 houserush/gateway/pom.xml         |  76 ++++++++++++++++++
 houserush/house-order/pom.xml     |  70 +++++++++++++++++
 houserush/login/pom.xml           |  78 +++++++++++++++++++
 houserush/pom.xml                 | 157 ++++++++++++++++++++++++++++++++++++++
 houserush/realestate/pom.xml      |  71 +++++++++++++++++
 houserush/user-center/pom.xml     |  63 +++++++++++++++
 10 files changed, 634 insertions(+)

diff --git a/houserush/README.md b/houserush/README.md
new file mode 100644
index 0000000..105187f
--- /dev/null
+++ b/houserush/README.md
@@ -0,0 +1,2 @@
+TODO
+# houserush todo
diff --git a/houserush/customer-manage/pom.xml b/houserush/customer-manage/pom.xml
new file mode 100644
index 0000000..120d9f1
--- /dev/null
+++ b/houserush/customer-manage/pom.xml
@@ -0,0 +1,86 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>houserush</artifactId>
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>houserush-customer-manage</artifactId>
+  <name>Java Chassis::Samples::Practice::HouseRush-Customer-Manage</name>
+
+
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-data-jpa</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-provider</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-tracing-zipkin</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+
+
+
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/houserush/doc/pom.xml b/houserush/doc/pom.xml
new file mode 100644
index 0000000..d153734
--- /dev/null
+++ b/houserush/doc/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>houserush</artifactId>
+        <groupId>org.apache.servicecomb.samples.practice</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>houserush-doc</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/houserush/doc/proposal.md b/houserush/doc/proposal.md
new file mode 100644
index 0000000..3d228b6
--- /dev/null
+++ b/houserush/doc/proposal.md
@@ -0,0 +1,16 @@
+Hi, All
+
+   Recently, I communicated with some ServiceComb new users, they want an e-commerce system ServiceComb sample project with real business background. They think with this demo they can learn ServiceComb’s abilities and usages **more efficiently**. 
+   
+   Then I found this project https://github.com/apache/servicecomb-samples. So I want to develop an e-commerce system demo and **devote** it to  this project as this project’s sub-project.
+   
+   ***
+
+   ###The business background of my planing project:
+   Traditionally, a real estate developer in china will show their nearing completion buildings to the customers for a couple of days, then determine an open sale time for all customers to make real deal offline. Those customers have to get to sale place long before the open sale time and queue up,because only in this way they get the chances to pick the apartment which they like mostly. 
+   So recently, more and more real estate developers begin to build an online apartments/houses open sale system. The e-commerce system help their customer to pick the houses more easily and more fairly. This is the system which I plan to build with ServiceComb.
+
+   ###Why I choose this project as a guiding sample of ServiceComb?
+   Real estate developers use this system to make a deal with their customer online. So, yes! This is a real e-commerce system with real commercial value. But this is also a real simple e-commerce system which has no payment and shipping module. So Its simplicity is good for the guiding purpose. Meanwhile, because these trading subjects of this system are very expensive,and there will be high QPS when the open sale time just arrives. So There are high requirements for the system’s scalab [...]
+   
+   ###Any questions and suggestions?
\ No newline at end of file
diff --git a/houserush/gateway/pom.xml b/houserush/gateway/pom.xml
new file mode 100644
index 0000000..4d45787
--- /dev/null
+++ b/houserush/gateway/pom.xml
@@ -0,0 +1,76 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>houserush</artifactId>
+        <groupId>org.apache.servicecomb.samples.practice</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>houserush-webapp</artifactId>
+    <name>Java Chassis::Samples::Practice::HouseRush-webapp</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>transport-rest-vertx</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-boot-starter-servicecomb</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-boot-starter-discovery</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-cloud-zuul</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-cloud-zuul-zipkin</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20180813</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/houserush/house-order/pom.xml b/houserush/house-order/pom.xml
new file mode 100644
index 0000000..46890ab
--- /dev/null
+++ b/houserush/house-order/pom.xml
@@ -0,0 +1,70 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>houserush</artifactId>
+        <groupId>org.apache.servicecomb.samples.practice</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>houserush-house-order</artifactId>
+    <name>Java Chassis::Samples::Practice::HouseRush-House-Order</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-boot-starter-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-flowcontrol-qps</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-bizkeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-tracing-zipkin</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/houserush/login/pom.xml b/houserush/login/pom.xml
new file mode 100644
index 0000000..4162f80
--- /dev/null
+++ b/houserush/login/pom.xml
@@ -0,0 +1,78 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>houserush</artifactId>
+        <groupId>org.apache.servicecomb.samples.practice</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>houserush-login</artifactId>
+    <name>Java Chassis::Samples::Practice::HouseRush-Login</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-boot-starter-provider</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-flowcontrol-qps</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-bizkeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-tracing-zipkin</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/houserush/pom.xml b/houserush/pom.xml
new file mode 100644
index 0000000..c6e1e1f
--- /dev/null
+++ b/houserush/pom.xml
@@ -0,0 +1,157 @@
+<!--
+  ~ 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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <artifactId>houserush</artifactId>
+    <name>Java Chassis::Samples::practice::HouseRush</name>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>customer-manage</module>
+        <module>login</module>
+        <module>realestate</module>
+        <module>house-order</module>
+        <module>user-center</module>
+        <module>gateway</module>
+        <module>doc</module>
+    </modules>
+
+    <description>Quick Start Demo for Using ServiceComb Java Chassis</description>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+        <java-chassis.version>1.2.1</java-chassis.version>
+        <spring-boot-1.version>1.5.14.RELEASE</spring-boot-1.version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.servicecomb</groupId>
+                <artifactId>java-chassis-dependencies</artifactId>
+                <version>${java-chassis.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring-boot-1.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter</artifactId>
+                <version>${spring-boot-1.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <!-- 用于连接mysql的相关依赖 -->
+            <dependency>
+                <groupId>mysql</groupId>
+                <artifactId>mysql-connector-java</artifactId>
+                <version>5.1.47</version>
+            </dependency>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-data-rest</artifactId>
+                <version>${spring-boot-1.version}</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hibernate.validator</groupId>
+            <artifactId>hibernate-validator</artifactId>
+            <version>6.1.0.Alpha5</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <version>2.0.1.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.10</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-maven-plugin</artifactId>
+                    <version>2.0.1.RELEASE</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <version>0.13</version>
+                <configuration>
+                    <excludes>
+                        <exclude>.travis.yml</exclude>
+                        <exclude>**/*.md</exclude>
+                        <exclude>**/target/*</exclude>
+                        <!-- Skip the ssl configuration files -->
+                        <exculde>**/resources/ssl/**</exculde>
+                        <!-- Skip the protobuf files -->
+                        <exclude>**/*.proto</exclude>
+                        <!-- Skip the idl files -->
+                        <exclude>**/*.idl</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <repositories>
+        <repository>
+            <id>maven-apache-snapshot</id>
+            <name>Maven Apache Snapshot</name>
+            <url>https://repository.apache.org/content/groups/snapshots</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+</project>
diff --git a/houserush/realestate/pom.xml b/houserush/realestate/pom.xml
new file mode 100644
index 0000000..e425b6a
--- /dev/null
+++ b/houserush/realestate/pom.xml
@@ -0,0 +1,71 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>houserush</artifactId>
+        <groupId>org.apache.servicecomb.samples.practice</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>houserush-realestate</artifactId>
+    <name>Java Chassis::Samples::Practice::HouseRush-Realestate</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-boot-starter-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-flowcontrol-qps</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-bizkeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-tracing-zipkin</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/houserush/user-center/pom.xml b/houserush/user-center/pom.xml
new file mode 100644
index 0000000..84718ac
--- /dev/null
+++ b/houserush/user-center/pom.xml
@@ -0,0 +1,63 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>houserush</artifactId>
+        <groupId>org.apache.servicecomb.samples.practice</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>houserush-user-center</artifactId>
+    <name>Java Chassis::Samples::Practice::HouseRush-User-Center</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>spring-boot-starter-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-flowcontrol-qps</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-bizkeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicecomb</groupId>
+            <artifactId>handler-tracing-zipkin</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>


[servicecomb-samples] 03/32: separate api in different project

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 1370b2fd36b962b036be350bc208a23eb1490ab9
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Mar 8 15:14:10 2019 +0800

    separate api in different project
---
 .../{common => api/file-service/endpoint}/pom.xml  | 11 ++++++--
 .../samples/porter/file/api/FileEndpoint.java      |  3 ++-
 .../{common => api/file-service}/pom.xml           | 13 +++++++---
 .../{common => api/file-service/service}/pom.xml   |  4 +--
 .../samples/porter/file/api/FileService.java       |  2 +-
 porter_lightweight/{common => api}/pom.xml         | 11 +++++---
 .../{common => api/user-service/endpoint}/pom.xml  | 11 ++++++--
 .../samples/porter/user/api/UserEndpoint.java      |  4 ++-
 .../{common => api/user-service}/pom.xml           | 13 +++++++---
 .../{common => api/user-service/service}/pom.xml   |  4 +--
 .../samples/porter/user/api/SessionInfo.java       |  2 +-
 .../samples/porter/user/api/UserService.java       |  2 +-
 .../common/src/main/resources/microservice.yaml    | 30 ----------------------
 porter_lightweight/file-service/pom.xml            |  2 +-
 .../porter/file/service/FileServiceImpl.java       |  2 +-
 .../main/resources/META-INF/spring/file.bean.xml   |  2 --
 .../src/main/resources/microservice.yaml           |  9 +++++++
 porter_lightweight/gateway-service/pom.xml         |  2 +-
 .../samples/porter/gateway/AuthHandler.java        | 13 +++++-----
 .../src/main/resources/microservice.yaml           |  8 ++++++
 porter_lightweight/pom.xml                         |  2 +-
 porter_lightweight/user-service/pom.xml            |  2 +-
 .../samples/porter/user/dao/SessionInfoModel.java  |  2 +-
 .../samples/porter/user/dao/SessionMapper.java     |  2 +-
 .../porter/user/service/UserServiceImpl.java       |  5 ++--
 .../main/resources/META-INF/spring/user.bean.xml   |  3 ---
 .../src/main/resources/microservice.yaml           |  8 ++++++
 27 files changed, 96 insertions(+), 76 deletions(-)

diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/file-service/endpoint/pom.xml
similarity index 78%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/file-service/endpoint/pom.xml
index 772ec4e..f9ae57e 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/file-service/endpoint/pom.xml
@@ -21,11 +21,18 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>file-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>file-service-api-endpoint</artifactId>
   <packaging>jar</packaging>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>file-service-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java b/porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileEndpoint.java
similarity index 94%
rename from porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java
rename to porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileEndpoint.java
index e7c1f0c..8ff7dac 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java
+++ b/porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileEndpoint.java
@@ -15,9 +15,10 @@
  * limitations under the License.
  */
 
-package samples.porter.file.api;
+package org.apache.servicecomb.samples.porter.file.api;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.porter.file.api.FileService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.DeleteMapping;
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/file-service/pom.xml
similarity index 85%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/file-service/pom.xml
index 772ec4e..be4d84a 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/file-service/pom.xml
@@ -15,17 +15,22 @@
   ~ 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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>porter-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
-  <packaging>jar</packaging>
+  <artifactId>file-service-api</artifactId>
+  <packaging>pom</packaging>
 
-</project>
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/file-service/service/pom.xml
similarity index 92%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/file-service/service/pom.xml
index 772ec4e..a0a5dc9 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/file-service/service/pom.xml
@@ -21,11 +21,11 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>file-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>file-service-api-service</artifactId>
   <packaging>jar</packaging>
 
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java b/porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileService.java
similarity index 94%
rename from porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java
rename to porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileService.java
index 606e727..ff7777a 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java
+++ b/porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileService.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package samples.porter.file.api;
+package org.apache.servicecomb.samples.porter.file.api;
 
 import org.springframework.web.multipart.MultipartFile;
 
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/pom.xml
similarity index 88%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/pom.xml
index 772ec4e..018a879 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/pom.xml
@@ -15,6 +15,7 @@
   ~ 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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
@@ -25,7 +26,11 @@
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
-  <packaging>jar</packaging>
+  <artifactId>porter-api</artifactId>
+  <packaging>pom</packaging>
 
-</project>
+  <modules>
+    <module>file-service</module>
+    <module>user-service</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/user-service/endpoint/pom.xml
similarity index 78%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/user-service/endpoint/pom.xml
index 772ec4e..5c96d3a 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/user-service/endpoint/pom.xml
@@ -21,11 +21,18 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>user-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>user-service-api-endpoint</artifactId>
   <packaging>jar</packaging>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>user-service-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java b/porter_lightweight/api/user-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserEndpoint.java
similarity index 91%
rename from porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java
rename to porter_lightweight/api/user-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserEndpoint.java
index 8a248d3..40df5bb 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java
+++ b/porter_lightweight/api/user-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserEndpoint.java
@@ -15,9 +15,11 @@
  * limitations under the License.
  */
 
-package samples.porter.user.api;
+package org.apache.servicecomb.samples.porter.user.api;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/user-service/pom.xml
similarity index 85%
copy from porter_lightweight/common/pom.xml
copy to porter_lightweight/api/user-service/pom.xml
index 772ec4e..31e433d 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/user-service/pom.xml
@@ -15,17 +15,22 @@
   ~ 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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>porter-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
-  <packaging>jar</packaging>
+  <artifactId>user-service-api</artifactId>
+  <packaging>pom</packaging>
 
-</project>
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/api/user-service/service/pom.xml
similarity index 92%
rename from porter_lightweight/common/pom.xml
rename to porter_lightweight/api/user-service/service/pom.xml
index 772ec4e..083b309 100644
--- a/porter_lightweight/common/pom.xml
+++ b/porter_lightweight/api/user-service/service/pom.xml
@@ -21,11 +21,11 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>user-service-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-common</artifactId>
+  <artifactId>user-service-api-service</artifactId>
   <packaging>jar</packaging>
 
 </project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/SessionInfo.java
similarity index 96%
rename from porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java
rename to porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/SessionInfo.java
index 2aca62b..6358104 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java
+++ b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/SessionInfo.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package samples.porter.user.api;
+package org.apache.servicecomb.samples.porter.user.api;
 
 public class SessionInfo {
   private String sessiondId;
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserService.java
similarity index 94%
rename from porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java
rename to porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserService.java
index a37ffa3..aa882f9 100644
--- a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java
+++ b/porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/UserService.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package samples.porter.user.api;
+package org.apache.servicecomb.samples.porter.user.api;
 
 public interface UserService {
   public SessionInfo login(String userName,
diff --git a/porter_lightweight/common/src/main/resources/microservice.yaml b/porter_lightweight/common/src/main/resources/microservice.yaml
deleted file mode 100644
index 9e3de6e..0000000
--- a/porter_lightweight/common/src/main/resources/microservice.yaml
+++ /dev/null
@@ -1,30 +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.
-## ---------------------------------------------------------------------------
-
-servicecomb-config-order: 10
-
-APPLICATION_ID: porter-application
-service_description:
-  version: 0.0.1
-
-servicecomb:
-  service:
-    registry:
-      address: http://localhost:30100
-      instance:
-        watch: false
\ No newline at end of file
diff --git a/porter_lightweight/file-service/pom.xml b/porter_lightweight/file-service/pom.xml
index d42ed5c..6ae53d6 100644
--- a/porter_lightweight/file-service/pom.xml
+++ b/porter_lightweight/file-service/pom.xml
@@ -31,7 +31,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
-      <artifactId>porter-common</artifactId>
+      <artifactId>file-service-api-endpoint</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
   </dependencies>
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java
index 78aea60..5053aee 100644
--- a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java
@@ -25,7 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 @Service
-public class FileServiceImpl implements samples.porter.file.api.FileService {
+public class FileServiceImpl implements org.apache.servicecomb.samples.porter.file.api.FileService {
     @Autowired
     private FileStoreService fileService;
 
diff --git a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
index 4a3846c..c679960 100644
--- a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
+++ b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
@@ -24,6 +24,4 @@
         http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
-    <!-- Only scan file components. Other beans in common module like org.apache.servicecomb.samples.porter.user.api.UserEndpoint ignored. -->
-    <context:component-scan base-package="samples.porter.file" />
 </beans>
\ No newline at end of file
diff --git a/porter_lightweight/file-service/src/main/resources/microservice.yaml b/porter_lightweight/file-service/src/main/resources/microservice.yaml
index bb71959..44654c4 100644
--- a/porter_lightweight/file-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/file-service/src/main/resources/microservice.yaml
@@ -19,10 +19,19 @@
 # override common configurations in common module
 servicecomb-config-order: 10
 
+APPLICATION_ID: porter-application
+
 service_description:
+  version: 0.0.1
   name: file-service
 
 servicecomb:
+  service:
+    registry:
+      address: http://localhost:30120
+      instance:
+        watch: false
+
   rest:
     address: 0.0.0.0:9091
 
diff --git a/porter_lightweight/gateway-service/pom.xml b/porter_lightweight/gateway-service/pom.xml
index 427c75e..c0188fa 100644
--- a/porter_lightweight/gateway-service/pom.xml
+++ b/porter_lightweight/gateway-service/pom.xml
@@ -35,7 +35,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
-      <artifactId>porter-common</artifactId>
+      <artifactId>user-service-api-service</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
     <dependency>
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
index 73cc06d..13a7e9a 100644
--- a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
@@ -23,6 +23,7 @@ import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.foundation.common.utils.JsonUtils;
 import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
 import org.apache.servicecomb.swagger.invocation.AsyncResponse;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
@@ -33,13 +34,11 @@ import org.springframework.util.concurrent.ListenableFutureCallback;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 
-import samples.porter.user.api.SessionInfo;
-
 
 public class AuthHandler implements Handler {
   private CseAsyncRestTemplate restTemplate = new CseAsyncRestTemplate();
 
-  //服务端会话过期是10分钟,客户端缓存1分钟会话。
+  // session expires in 10 minutes, cache for 1 seconds to get rid of concurrent scenarios.
   private Cache<String, String> sessionCache = CacheBuilder.newBuilder()
       .expireAfterAccess(30, TimeUnit.SECONDS)
       .build();
@@ -49,7 +48,7 @@ public class AuthHandler implements Handler {
     if (invocation.getMicroserviceName().equals("user-service")
         && (invocation.getOperationName().equals("login")
             || (invocation.getOperationName().equals("getSession")))) {
-      // login: 直接返回认证结果。  开发者需要在JS里面设置cookie。 
+      // login:return session id, set cookie by javascript
       invocation.next(asyncResponse);
     } else {
       // check session
@@ -61,7 +60,7 @@ public class AuthHandler implements Handler {
       String sessionInfo = sessionCache.getIfPresent(sessionId);
       if (sessionInfo != null) {
         try {
-          // 将会话信息传递给后面的微服务。后面的微服务可以从context获取到会话信息,从而可以进行鉴权等。 
+          // session info stored in InvocationContext. Microservices can get it. 
           invocation.addContext("session-id", sessionId);
           invocation.addContext("session-info", sessionInfo);
           invocation.next(asyncResponse);
@@ -71,7 +70,7 @@ public class AuthHandler implements Handler {
         return;
       }
 
-      // 在网关执行的Hanlder逻辑,是reactive模式的,不能使用阻塞调用。
+      // In edge, handler is executed in reactively. Must have no blocking logic.
       ListenableFuture<ResponseEntity<SessionInfo>> sessionInfoFuture =
           restTemplate.getForEntity("cse://user-service/v1/user/session?sessionId=" + sessionId, SessionInfo.class);
       sessionInfoFuture.addCallback(
@@ -89,7 +88,7 @@ public class AuthHandler implements Handler {
                 return;
               }
               try {
-                // 将会话信息传递给后面的微服务。后面的微服务可以从context获取到会话信息,从而可以进行鉴权等。 
+                // session info stored in InvocationContext. Microservices can get it. 
                 invocation.addContext("session-id", sessionId);
                 String sessionInfoStr = JsonUtils.writeValueAsString(sessionInfo);
                 invocation.addContext("session-info", sessionInfoStr);
diff --git a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
index 5623c60..a3edac1 100644
--- a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
@@ -19,10 +19,18 @@
 # override common configurations in common module
 servicecomb-config-order: 100
 
+APPLICATION_ID: porter-application
 service_description:
+  version: 0.0.1
   name: gateway-service
 
 servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
   rest:
     address: 0.0.0.0:9090?sslEnabled=false
 
diff --git a/porter_lightweight/pom.xml b/porter_lightweight/pom.xml
index 5a7e539..f891518 100644
--- a/porter_lightweight/pom.xml
+++ b/porter_lightweight/pom.xml
@@ -65,7 +65,7 @@
   </dependencies>
 
   <modules>
-    <module>common</module>
+    <module>api</module>
     <module>file-service</module>
     <module>user-service</module>
     <module>gateway-service</module>
diff --git a/porter_lightweight/user-service/pom.xml b/porter_lightweight/user-service/pom.xml
index 04c50ae..7e8c20f 100644
--- a/porter_lightweight/user-service/pom.xml
+++ b/porter_lightweight/user-service/pom.xml
@@ -36,7 +36,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
-      <artifactId>porter-common</artifactId>
+      <artifactId>user-service-api-endpoint</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
     <dependency>
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
index f363af5..fa60d33 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.samples.porter.user.dao;
 
-import samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
 
 public class SessionInfoModel {
   private int id;
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java
index fb3306b..e09df8e 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.samples.porter.user.dao;
 
-import samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
 
 public interface SessionMapper {
     void createSession(SessionInfo sessionInfo);
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
index 2633d57..2d49b46 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
@@ -24,6 +24,8 @@ import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.codec.binary.Base64;
+import org.apache.servicecomb.samples.porter.user.api.SessionInfo;
+import org.apache.servicecomb.samples.porter.user.api.UserService;
 import org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel;
 import org.apache.servicecomb.samples.porter.user.dao.SessionMapper;
 import org.apache.servicecomb.samples.porter.user.dao.UserInfo;
@@ -36,9 +38,6 @@ import org.springframework.stereotype.Service;
 
 import com.netflix.config.DynamicPropertyFactory;
 
-import samples.porter.user.api.SessionInfo;
-import samples.porter.user.api.UserService;
-
 @Service
 public class UserServiceImpl implements UserService {
   private static Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);
diff --git a/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
index e1cdd94..3cc2dd2 100644
--- a/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
+++ b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
@@ -26,9 +26,6 @@
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
-    <context:component-scan base-package="samples.porter.user" >
-    </context:component-scan>
-
     <bean id="dataSource"
         class="org.apache.commons.dbcp2.BasicDataSource"
         destroy-method="close">
diff --git a/porter_lightweight/user-service/src/main/resources/microservice.yaml b/porter_lightweight/user-service/src/main/resources/microservice.yaml
index 81ef89e..9c25055 100644
--- a/porter_lightweight/user-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/user-service/src/main/resources/microservice.yaml
@@ -19,9 +19,17 @@
 # override common configurations in common module
 servicecomb-config-order: 10
 
+APPLICATION_ID: porter-application
 service_description:
+  version: 0.0.1
   name: user-service
 
 servicecomb:
+  service:
+    registry:
+      address: http://localhost:30120
+      instance:
+        watch: false
+
   rest:
     address: 0.0.0.0:9093
\ No newline at end of file


[servicecomb-samples] 23/32: using oauth 2 password mode to grant tokens

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit db8821565eb92ad727d0cc0076d231fa7c87d4ce
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 17 17:12:32 2019 +0800

    using oauth 2 password mode to grant tokens
---
 authentication/README.md                           |  4 +-
 .../TokenEndpoint.java}                            | 68 +++++++++++++---------
 .../authentication/{api => server}/Token.java      |  2 +-
 .../TokenConst.java}                               | 23 +++-----
 .../TokenService.java}                             | 19 ++----
 .../edge/AuthenticationEndpoint.java               | 44 --------------
 .../edge/CustomVertxRestDispatcher.java            |  1 +
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  2 +-
 .../authentication/AuthenticationTestCase.java     | 12 ++--
 .../authentication/BootEventListener.java          | 12 ++--
 .../authentication/gateway/ApiDispatcher.java      |  1 +
 .../src/main/resources/microservice.yaml           |  2 +-
 12 files changed, 74 insertions(+), 116 deletions(-)

diff --git a/authentication/README.md b/authentication/README.md
index 2274bb4..6d477bb 100644
--- a/authentication/README.md
+++ b/authentication/README.md
@@ -87,4 +87,6 @@ http://localhost:9093/v1/test/start
 
 测试项目同时展示了这个项目的功能,比如: AuthenticationTestCase 的测试逻辑展示了基本的认证功能,从登陆,到接口的权限检查。 
 
-
+# TODO LIST
+1. provide TLS for authentication server & edge service
+2. grant scope for INTERNAL access & EXTERNAL access 
diff --git a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
similarity index 51%
rename from authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
rename to authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
index c777bc5..67c7ba4 100644
--- a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
@@ -15,26 +15,32 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
+
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.authentication.jwt.JWTClaims;
 import org.apache.servicecomb.authentication.jwt.JsonParser;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.jwt.Jwt;
 import org.springframework.security.jwt.JwtHelper;
 import org.springframework.security.jwt.crypto.sign.Signer;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 
-@RestSchema(schemaId = "AuthenticationEndpoint")
-@RequestMapping(path = "/v1/auth")
-public class AuthenticationEndpoint implements AuthenticationService {
+@RestSchema(schemaId = "TokenEndpoint")
+@RequestMapping(path = "/v1/oauth/token")
+public class TokenEndpoint implements TokenService {
   @Autowired
   @Qualifier("authUserDetailsService")
   private UserDetailsService userDetailsService;
@@ -48,33 +54,41 @@ public class AuthenticationEndpoint implements AuthenticationService {
   private Signer signer;
 
   @Override
-  @PostMapping(path = "login")
-  public Token login(@RequestParam(name = "userName") String userName,
-      @RequestParam(name = "password") String password) {
-    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
-    if (passwordEncoder.matches(password, userDetails.getPassword())) {
-      JWTClaims claims = new JWTClaims();
-      if (userDetails.getAuthorities() != null) {
-        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
-      }
-      String content = JsonParser.unparse(claims);
-      Jwt accessToken = JwtHelper.encode(content, signer);
+  @PostMapping(path = "/", consumes = MediaType.APPLICATION_FORM_URLENCODED)
+  public Token getAccessToken(@RequestBody Map<String, String> parameters) {
+    String grantType = parameters.get(TokenConst.PARAM_GRANT_TYPE);
+
+    if (TokenConst.GRANT_TYPE_PASSWORD.equals(grantType)) {
+
+      String username = parameters.get(TokenConst.PARAM_USERNAME);
+      String password = parameters.get(TokenConst.PARAM_PASSWORD);
 
-      Token token = new Token();
-      token.setScope(claims.getScope());
-      token.setExpires_in(10 * 60);
-      token.setToken_type("bearer");
-      token.setAccess_token(accessToken.getEncoded());
-      return token;
+      try {
+        UserDetails userDetails = userDetailsService.loadUserByUsername(username);
+        if (passwordEncoder.matches(password, userDetails.getPassword())) {
+          JWTClaims claims = new JWTClaims();
+          if (userDetails.getAuthorities() != null) {
+            userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
+          }
+          String content = JsonParser.unparse(claims);
+          Jwt accessToken = JwtHelper.encode(content, signer);
+
+          Token token = new Token();
+          token.setScope(claims.getScope());
+          token.setExpires_in(10 * 60);
+          token.setToken_type("bearer");
+          token.setAccess_token(accessToken.getEncoded());
+          return token;
+        } else {
+          return null;
+        }
+      } catch (UsernameNotFoundException e) {
+        throw new InvocationException(403, "", "forbidden");
+      }
     } else {
       return null;
     }
-  }
 
-  @Override
-  @PostMapping(path = "refresh")
-  public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
-    return null;
   }
 
 }
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/Token.java
similarity index 97%
rename from authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/Token.java
index 94ce237..8758bd1 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
+++ b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/Token.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
 
 import java.util.Map;
 import java.util.Set;
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
similarity index 59%
copy from authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
copy to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
index 77635ad..a46a7b9 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
+++ b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
@@ -15,21 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
 
-public interface AuthenticationService {
-  /**
-   * login using user name and password.
-   * @param userName user name
-   * @param password password
-   * @return After successfully login, token is created. Or null is returned. 
-   */
-  Token login(String userName, String password);
+public class TokenConst {
+  public static final String PARAM_GRANT_TYPE = "grant_type";
 
-  /**
-   * acquired new token using refresh token.
-   * @param refreshToken refresh token
-   * @return After successfully authenticated, token is created. Or null is returned. 
-   */
-  Token refresh(String refreshToken);
+  public static final String PARAM_USERNAME = "username";
+
+  public static final String PARAM_PASSWORD = "password";
+  
+  public static final String GRANT_TYPE_PASSWORD = "password";
 }
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java
similarity index 59%
rename from authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java
index 77635ad..b0cea22 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
+++ b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java
@@ -15,21 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
 
-public interface AuthenticationService {
-  /**
-   * login using user name and password.
-   * @param userName user name
-   * @param password password
-   * @return After successfully login, token is created. Or null is returned. 
-   */
-  Token login(String userName, String password);
+import java.util.Map;
 
-  /**
-   * acquired new token using refresh token.
-   * @param refreshToken refresh token
-   * @return After successfully authenticated, token is created. Or null is returned. 
-   */
-  Token refresh(String refreshToken);
+public interface TokenService {
+  Token getAccessToken(Map<String, String> parameters);
 }
diff --git a/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java b/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
deleted file mode 100644
index 68fe5d7..0000000
--- a/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.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.servicecomb.authentication.edge;
-
-import org.apache.servicecomb.authentication.api.AuthenticationService;
-import org.apache.servicecomb.authentication.api.Token;
-import org.apache.servicecomb.provider.pojo.RpcReference;
-import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@RestSchema(schemaId = "AuthenticationEndpoint")
-@RequestMapping(path = "/v1/auth")
-public class AuthenticationEndpoint {
-  @RpcReference(microserviceName = "authentication-server", schemaId = "AuthenticationEndpoint")
-  private AuthenticationService authenticationService;
-
-  @PostMapping(path = "login")
-  public Token login(@RequestParam(name = "userName") String userName,
-      @RequestParam(name = "password") String password) {
-    return authenticationService.login(userName, password);
-  }
-
-  @PostMapping(path = "refresh")
-  public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
-    return authenticationService.refresh(refreshToken);
-  }
-}
diff --git a/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
index d1c6ef4..521b71c 100644
--- a/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
@@ -45,6 +45,7 @@ import io.vertx.ext.web.RoutingContext;
 import io.vertx.ext.web.handler.CookieHandler;
 
 // copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher 1.2.0
+// TODO: using 1.2.2+ to make it simpler
 public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
   private static final Logger LOGGER = LoggerFactory.getLogger(VertxRestDispatcher.class);
 
diff --git a/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index 53481f1..32c1583 100644
--- a/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.authentication.edge.CustomVertxRestDispatcher
\ No newline at end of file
+# org.apache.servicecomb.authentication.edge.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
index 61ba97f..50a4519 100644
--- a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
+++ b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.authentication;
 
-import org.apache.servicecomb.authentication.api.Token;
+import org.apache.servicecomb.authentication.server.Token;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -38,13 +38,14 @@ public class AuthenticationTestCase implements TestCase {
   private void testHanlderAuth() {
     // get token
     MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
-    map.add("userName", "admin");
+    map.add("grant_type", "password");
+    map.add("username", "admin");
     map.add("password", "changeMyPassword");
     HttpHeaders headers = new HttpHeaders();
     headers.setContentType(MediaType.MULTIPART_FORM_DATA);
 
     Token token =
-        BootEventListener.gateEndpoint.postForObject("/v1/auth/login",
+        BootEventListener.authenticationServerTokenEndpoint.postForObject("/",
             new HttpEntity<>(map, headers),
             Token.class);
     TestMgr.check("bearer", token.getToken_type());
@@ -85,13 +86,14 @@ public class AuthenticationTestCase implements TestCase {
   private void testMethodAuth() {
     // get token
     MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
-    map.add("userName", "admin");
+    map.add("grant_type", "password");
+    map.add("username", "admin");
     map.add("password", "changeMyPassword");
     HttpHeaders headers = new HttpHeaders();
     headers.setContentType(MediaType.MULTIPART_FORM_DATA);
 
     Token token =
-        BootEventListener.gateEndpoint.postForObject("/v1/auth/login",
+        BootEventListener.authenticationServerTokenEndpoint.postForObject("/",
             new HttpEntity<>(map, headers),
             Token.class);
     TestMgr.check("bearer", token.getToken_type());
diff --git a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
index 5512f8c..08d1bb3 100644
--- a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
+++ b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
@@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
 
 @Component
 public class BootEventListener implements BootListener {
-  public static GateRestTemplate authenticationServerAuthenticationEndpoint;
+  public static GateRestTemplate authenticationServerTokenEndpoint;
   public static GateRestTemplate gateEndpoint;
   public static GateRestTemplate resouceServerHandlerAuthEndpoint;
   public static GateRestTemplate resouceServerMethodAuthEndpoint;
@@ -30,14 +30,14 @@ public class BootEventListener implements BootListener {
   @Override
   public void onBootEvent(BootEvent event) {
     if (EventType.AFTER_REGISTRY.equals(event.getEventType())) {
-      authenticationServerAuthenticationEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", "authentication-server", "AuthenticationEndpoint").init();
+      authenticationServerTokenEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("edge-service", "authentication-server", "TokenEndpoint").init();
       gateEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", null, null).init();
+          GateRestTemplate.createEdgeRestTemplate("edge-service", null, null).init();
       resouceServerHandlerAuthEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "HandlerAuthEndpoint").init();
+          GateRestTemplate.createEdgeRestTemplate("edge-service", "resource-server", "HandlerAuthEndpoint").init();
       resouceServerMethodAuthEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "PreMethodAuthEndpoint").init();
+          GateRestTemplate.createEdgeRestTemplate("edge-service", "resource-server", "PreMethodAuthEndpoint").init();
     }
 
   }
diff --git a/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
index 9f45550..7642268 100644
--- a/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
+++ b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
@@ -27,6 +27,7 @@ import io.vertx.ext.web.Router;
 import io.vertx.ext.web.RoutingContext;
 import io.vertx.ext.web.handler.CookieHandler;
 
+//TODO: using 1.2.2+ to make it simpler
 public class ApiDispatcher extends AbstractEdgeDispatcher {
   @Override
   public int getOrder() {
diff --git a/authentication/samples/EdgeService/src/main/resources/microservice.yaml b/authentication/samples/EdgeService/src/main/resources/microservice.yaml
index 2eda242..7531d52 100644
--- a/authentication/samples/EdgeService/src/main/resources/microservice.yaml
+++ b/authentication/samples/EdgeService/src/main/resources/microservice.yaml
@@ -22,7 +22,7 @@ servicecomb-config-order: 100
 APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
-  name: gateway
+  name: edge-service
   environment: development
 
 servicecomb:


[servicecomb-samples] 24/32: 支持refresh流程

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 2ed65addee6f3c0e4382dd2da96b3fe1b0ce8f34
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 24 14:30:42 2019 +0800

    支持refresh流程
---
 authentication/README.md                           |  18 ++++
 .../server/PasswordTokenGranter.java               | 100 +++++++++++++++++++++
 .../server/RefreshTokenTokenGranter.java           |  95 ++++++++++++++++++++
 .../authentication/server/TokenEndpoint.java       |  54 ++---------
 .../authentication/server/TokenGranter.java}       |  24 +++--
 .../authentication/server/TokenConst.java          |   8 +-
 .../authentication/edge/AuthHandler.java           |   2 +-
 .../resource/ResourceAuthHandler.java              |   2 +-
 .../AuthenticationConfiguration.java               |   6 ++
 .../authentication/AuthenticationTestCase.java     |  54 +++++++++++
 .../gateway/AuthenticationConfiguration.java       |   6 +-
 .../resource/AuthenticationConfiguration.java      |   6 +-
 12 files changed, 313 insertions(+), 62 deletions(-)

diff --git a/authentication/README.md b/authentication/README.md
index 6d477bb..c91d67e 100644
--- a/authentication/README.md
+++ b/authentication/README.md
@@ -90,3 +90,21 @@ http://localhost:9093/v1/test/start
 # TODO LIST
 1. provide TLS for authentication server & edge service
 2. grant scope for INTERNAL access & EXTERNAL access 
+3. access token support: a. use access token to get optional scope or roles token. 这个可以解决角色过多的时候, token过大的一些问题
+4. 实现注销逻辑(会话管理)
+5. 支持分层的角色机制
+
+       ROLE_LEVEL1
+        /       \
+   ROLE_LEVEL2  ROLE_LEVEL2
+
+ TOKEN里面只返回ROLE_LEVEL1,设置为ROLE_LEVEL2访问的操作,也可以访问。
+
+6. REFRESH_TOKEN可以用来实现申请不同SCOPE的TOKEN。 
+7. 设计目标:无状态。认证服务器和资源服务器均可以多实例部署,每个实例之间不共享状态。在实现很多功能的时候,都遵循这个约束。包括通过refresh token获取新的access token的时候。遵循这个约束,意味着请求需要同时传递refresh token和access token。 
+8, 重新设计TOKEN(代码重构、支持会话管理),支持OpenID Connect。
+
+OAUTH的不好的地方:TOKEN在有效期内,容易被利用,无法注销;TOKEN过期后,必须重新认证,和用户是否在一直操作无关,体验不好,虽然可以通过refresh_token获取新的token提升体验,但是refresh_token有效期如果设置的太长,会降低安全性。Token在有效期内,如果修改了权限等信息,无法及时感知,需要重新登录。
+OAUTH的好的地方:TOKEN签发、认证都可以由微服务实例独自完成,不需要共用的数据存储,比如数据库、Redis等,效率更高,弹性扩容。
+
+
diff --git a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/PasswordTokenGranter.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/PasswordTokenGranter.java
new file mode 100644
index 0000000..7d16268
--- /dev/null
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/PasswordTokenGranter.java
@@ -0,0 +1,100 @@
+/*
+ * 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.servicecomb.authentication.server;
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+import org.springframework.security.jwt.crypto.sign.Signer;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+@Component(value = "passwordTokenGranter")
+public class PasswordTokenGranter implements TokenGranter {
+  @Autowired
+  @Qualifier("authUserDetailsService")
+  private UserDetailsService userDetailsService;
+
+  @Autowired
+  @Qualifier("authPasswordEncoder")
+  private PasswordEncoder passwordEncoder;
+
+  @Autowired
+  @Qualifier("authSigner")
+  private Signer signer;
+
+  @Override
+  public Token grant(Map<String, String> parameters) {
+    String username = parameters.get(TokenConst.PARAM_USERNAME);
+    String password = parameters.get(TokenConst.PARAM_PASSWORD);
+
+    UserDetails userDetails = userDetailsService.loadUserByUsername(username);
+    if (passwordEncoder.matches(password, userDetails.getPassword())) {
+      JWTClaims claims = new JWTClaims();
+      if (userDetails.getAuthorities() != null) {
+        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
+      }
+      claims.setJti(UUID.randomUUID().toString());
+      claims.setIat(System.currentTimeMillis());
+      claims.setExp(5 * 60);
+      
+      String content = JsonParser.unparse(claims);
+      Jwt accessToken = JwtHelper.encode(content, signer);
+
+      Token token = new Token();
+      token.setScope(claims.getScope());
+      token.setExpires_in(10 * 60);
+      token.setToken_type("bearer");
+      token.setAccess_token(accessToken.getEncoded());
+      
+      JWTClaims accessTokenClaims = new JWTClaims();
+      accessTokenClaims.setJti(UUID.randomUUID().toString());
+      accessTokenClaims.setIat(System.currentTimeMillis());
+      accessTokenClaims.setExp(60 * 60);
+      Jwt refreshToken = JwtHelper.encode(JsonParser.unparse(claims), signer);
+      token.setRefresh_token(refreshToken.getEncoded());
+      
+      return token;
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public String grantType() {
+    return TokenConst.GRANT_TYPE_PASSWORD;
+  }
+
+  @Override
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty("servicecomb.authentication.granter.password.enabled", true)
+        .get();
+  }
+
+}
diff --git a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/RefreshTokenTokenGranter.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/RefreshTokenTokenGranter.java
new file mode 100644
index 0000000..ffbf9c5
--- /dev/null
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/RefreshTokenTokenGranter.java
@@ -0,0 +1,95 @@
+/*
+ * 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.servicecomb.authentication.server;
+
+import java.util.Map;
+
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+import org.springframework.security.jwt.crypto.sign.Signer;
+import org.springframework.security.jwt.crypto.sign.SignerVerifier;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+@Component(value = "fefreshTokenTokenGranter")
+public class RefreshTokenTokenGranter implements TokenGranter {
+  @Autowired
+  @Qualifier("authSignerVerifier")
+  private SignerVerifier signerVerifier;
+
+  @Autowired
+  @Qualifier("authSigner")
+  private Signer signer;
+
+  @Override
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty("servicecomb.authentication.granter.refreshToken.enabled", true)
+        .get();
+  }
+
+  @Override
+  public String grantType() {
+    return TokenConst.GRANT_TYPE_REFRESH_TOKEN;
+  }
+
+  @Override
+  public Token grant(Map<String, String> parameters) {
+    String refreshToken = parameters.get(TokenConst.PARAM_REFRESH_TOKEN);
+    String accessToken = parameters.get(TokenConst.PARAM_ACCESS_TOKEN);
+
+    // verify refresh tokens
+    Jwt jwt = JwtHelper.decode(refreshToken);
+    JWTClaims claims;
+    try {
+      jwt.verifySignature(signerVerifier);
+      claims = JsonParser.parse(jwt.getClaims(), JWTClaims.class);
+      // TODO: verify claims.
+    } catch (Exception e) {
+      return null;
+    }
+
+    // verify access tokens
+    jwt = JwtHelper.decode(accessToken);
+    claims = null;
+    try {
+      jwt.verifySignature(signerVerifier);
+      claims = JsonParser.parse(jwt.getClaims(), JWTClaims.class);
+      // TODO: verify claims.
+    } catch (Exception e) {
+      return null;
+    }
+
+    claims.setIat(System.currentTimeMillis());
+    String content = JsonParser.unparse(claims);
+    Jwt newAccessToken = JwtHelper.encode(content, signer);
+
+    Token token = new Token();
+    token.setScope(claims.getScope());
+    token.setExpires_in(10 * 60);
+    token.setToken_type("bearer");
+    token.setAccess_token(newAccessToken.getEncoded());
+    return token;
+  }
+
+}
diff --git a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
index 67c7ba4..775d332 100644
--- a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
@@ -17,23 +17,13 @@
 
 package org.apache.servicecomb.authentication.server;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.ws.rs.core.MediaType;
 
-import org.apache.servicecomb.authentication.jwt.JWTClaims;
-import org.apache.servicecomb.authentication.jwt.JsonParser;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.jwt.Jwt;
-import org.springframework.security.jwt.JwtHelper;
-import org.springframework.security.jwt.crypto.sign.Signer;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -42,53 +32,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
 @RequestMapping(path = "/v1/oauth/token")
 public class TokenEndpoint implements TokenService {
   @Autowired
-  @Qualifier("authUserDetailsService")
-  private UserDetailsService userDetailsService;
-
-  @Autowired
-  @Qualifier("authPasswordEncoder")
-  private PasswordEncoder passwordEncoder;
-
-  @Autowired
-  @Qualifier("authSigner")
-  private Signer signer;
+  private List<TokenGranter> granters;
 
   @Override
   @PostMapping(path = "/", consumes = MediaType.APPLICATION_FORM_URLENCODED)
   public Token getAccessToken(@RequestBody Map<String, String> parameters) {
     String grantType = parameters.get(TokenConst.PARAM_GRANT_TYPE);
 
-    if (TokenConst.GRANT_TYPE_PASSWORD.equals(grantType)) {
-
-      String username = parameters.get(TokenConst.PARAM_USERNAME);
-      String password = parameters.get(TokenConst.PARAM_PASSWORD);
-
-      try {
-        UserDetails userDetails = userDetailsService.loadUserByUsername(username);
-        if (passwordEncoder.matches(password, userDetails.getPassword())) {
-          JWTClaims claims = new JWTClaims();
-          if (userDetails.getAuthorities() != null) {
-            userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
-          }
-          String content = JsonParser.unparse(claims);
-          Jwt accessToken = JwtHelper.encode(content, signer);
-
-          Token token = new Token();
-          token.setScope(claims.getScope());
-          token.setExpires_in(10 * 60);
-          token.setToken_type("bearer");
-          token.setAccess_token(accessToken.getEncoded());
+    for (TokenGranter granter : granters) {
+      if (granter.enabled()) {
+        Token token = granter.grant(grantType, parameters);
+        if (token != null) {
           return token;
-        } else {
-          return null;
         }
-      } catch (UsernameNotFoundException e) {
-        throw new InvocationException(403, "", "forbidden");
       }
-    } else {
-      return null;
     }
 
+    return null;
   }
 
 }
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenGranter.java
similarity index 67%
copy from authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
copy to authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenGranter.java
index a46a7b9..9ba0861 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenGranter.java
@@ -17,12 +17,24 @@
 
 package org.apache.servicecomb.authentication.server;
 
-public class TokenConst {
-  public static final String PARAM_GRANT_TYPE = "grant_type";
+import java.util.Map;
 
-  public static final String PARAM_USERNAME = "username";
+/**
+ * Token granter is used to grant access tokens. 
+ * @author Administrator
+ *
+ */
+public interface TokenGranter {
+  boolean enabled();
+
+  String grantType();
+
+  default Token grant(String grantType, Map<String, String> parameters) {
+    if (grantType().equals(grantType)) {
+      return grant(parameters);
+    }
+    return null;
+  }
 
-  public static final String PARAM_PASSWORD = "password";
-  
-  public static final String GRANT_TYPE_PASSWORD = "password";
+  Token grant(Map<String, String> parameters);
 }
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
index a46a7b9..915a515 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
+++ b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
@@ -23,6 +23,12 @@ public class TokenConst {
   public static final String PARAM_USERNAME = "username";
 
   public static final String PARAM_PASSWORD = "password";
-  
+
+  public static final String PARAM_REFRESH_TOKEN = "refresh_token";
+
+  public static final String PARAM_ACCESS_TOKEN = "access_token";
+
   public static final String GRANT_TYPE_PASSWORD = "password";
+  
+  public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token";
 }
diff --git a/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
index 2c8d63c..40ef32d 100644
--- a/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
@@ -38,7 +38,7 @@ public class AuthHandler implements Handler {
     }
     Jwt jwt = JwtHelper.decode(token);
     try {
-      jwt.verifySignature(BeanUtils.getBean("authSigner"));
+      jwt.verifySignature(BeanUtils.getBean("authSignerVerifier"));
     } catch (InvalidSignatureException e) {
       asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
       return;
diff --git a/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
index 37de72d..1d8e32b 100644
--- a/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
+++ b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
@@ -59,7 +59,7 @@ public class ResourceAuthHandler implements Handler {
     Jwt jwt = JwtHelper.decode(token);
     JWTClaims claims;
     try {
-      jwt.verifySignature(BeanUtils.getBean("authSigner"));
+      jwt.verifySignature(BeanUtils.getBean("authSignerVerifier"));
       claims = JsonParser.parse(jwt.getClaims(), JWTClaims.class);
       // TODO: verify claims.
     } catch (Exception e) {
diff --git a/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
index 7d9d076..2fdbd4c 100644
--- a/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
+++ b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
@@ -31,6 +31,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
 import org.springframework.security.jwt.crypto.sign.MacSigner;
 import org.springframework.security.jwt.crypto.sign.Signer;
+import org.springframework.security.jwt.crypto.sign.SignerVerifier;
 import org.springframework.security.provisioning.InMemoryUserDetailsManager;
 
 @Configuration
@@ -46,6 +47,11 @@ public class AuthenticationConfiguration {
 
   @Bean(name = "authSigner")
   public Signer authSigner() {
+    return authSignerVerifier();
+  }
+  
+  @Bean(name = "authSignerVerifier")
+  public SignerVerifier authSignerVerifier() {
     return new MacSigner("Please change this key.");
   }
 
diff --git a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
index 50a4519..13bfaba 100644
--- a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
+++ b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
@@ -17,10 +17,13 @@
 
 package org.apache.servicecomb.authentication;
 
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
 import org.apache.servicecomb.authentication.server.Token;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
+import org.springframework.security.jwt.JwtHelper;
 import org.springframework.stereotype.Component;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
@@ -80,6 +83,56 @@ public class AuthenticationTestCase implements TestCase {
       TestMgr.check(403, e.getStatusCode().value());
     }
     TestMgr.check(null, name);
+    
+    // refresh token
+    // get token
+    map = new LinkedMultiValueMap<>();
+    map.add("grant_type", "refresh_token");
+    map.add("refresh_token", token.getRefresh_token());
+    map.add("access_token", token.getAccess_token());
+    headers = new HttpHeaders();
+    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
+
+    Token tokenNew =
+        BootEventListener.authenticationServerTokenEndpoint.postForObject("/",
+            new HttpEntity<>(map, headers),
+            Token.class);
+    TestMgr.check(token.getToken_type(), tokenNew.getToken_type());
+   
+    JWTClaims claims = JsonParser.parse(JwtHelper.decode(token.getAccess_token()).getClaims(), JWTClaims.class);
+    JWTClaims newClaims = JsonParser.parse(JwtHelper.decode(tokenNew.getAccess_token()).getClaims(), JWTClaims.class);
+    TestMgr.check(claims.getJti(), newClaims.getJti());
+    TestMgr.check(claims.getIat() < newClaims.getIat(), true);
+
+    // get resources
+    headers = new HttpHeaders();
+    headers.add("Authorization", "Bearer " + tokenNew.getAccess_token());
+    headers.setContentType(MediaType.APPLICATION_JSON);
+
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/everyoneSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/adminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/guestOrAdminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = null;
+    try {
+      name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/guestSayHello?name=Hi",
+          new HttpEntity<>(headers),
+          String.class);
+    } catch (HttpClientErrorException e) {
+      TestMgr.check(403, e.getStatusCode().value());
+    }
+    TestMgr.check(null, name);
   }
 
 
@@ -98,6 +151,7 @@ public class AuthenticationTestCase implements TestCase {
             Token.class);
     TestMgr.check("bearer", token.getToken_type());
     TestMgr.check(true, token.getAccess_token().length() > 10);
+    TestMgr.check(true, token.getRefresh_token().length() > 10);
 
     // get resources
     headers = new HttpHeaders();
diff --git a/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
index 87837eb..1e913fb 100644
--- a/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
+++ b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
@@ -20,12 +20,12 @@ package org.apache.servicecomb.authentication.gateway;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.jwt.crypto.sign.MacSigner;
-import org.springframework.security.jwt.crypto.sign.Signer;
+import org.springframework.security.jwt.crypto.sign.SignerVerifier;
 
 @Configuration
 public class AuthenticationConfiguration {
-  @Bean(name = "authSigner")
-  public Signer authSigner() {
+  @Bean(name = "authSignerVerifier")
+  public SignerVerifier authSignerVerifier() {
     return new MacSigner("Please change this key.");
   }
 }
diff --git a/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
index 0e58c30..712030d 100644
--- a/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
+++ b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
@@ -20,12 +20,12 @@ package org.apache.servicecomb.authentication.resource;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.jwt.crypto.sign.MacSigner;
-import org.springframework.security.jwt.crypto.sign.Signer;
+import org.springframework.security.jwt.crypto.sign.SignerVerifier;
 
 @Configuration
 public class AuthenticationConfiguration {
-  @Bean(name = "authSigner")
-  public Signer authSigner() {
+  @Bean(name = "authSignerVerifier")
+  public SignerVerifier authSignerVerifier() {
     return new MacSigner("Please change this key.");
   }
 }


[servicecomb-samples] 08/32: 默认使用log4j2

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit f83c17336ce98f57d6ff952c10ff80ed9a74d8c4
Author: liubao <ba...@huawei.com>
AuthorDate: Mon Mar 11 10:23:10 2019 +0800

    默认使用log4j2
---
 .../servicecomb/samples/porter/file/FileMain.java  |  2 -
 .../file-service/src/main/resources/log4j2.xml     | 43 ++++++++++++++++++++++
 .../samples/porter/gateway/GatewayMain.java        |  2 -
 .../gateway-service/src/main/resources/log4j2.xml  | 43 ++++++++++++++++++++++
 .../servicecomb/samples/porter/user/UserMain.java  |  2 -
 .../user-service/src/main/resources/log4j2.xml     | 43 ++++++++++++++++++++++
 6 files changed, 129 insertions(+), 6 deletions(-)

diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java
index 9b13142..ff57da5 100644
--- a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java
@@ -18,11 +18,9 @@
 package org.apache.servicecomb.samples.porter.file;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
 
 public class FileMain {
     public static void main(String[] args) throws Exception {
-        Log4jUtils.init();
         BeanUtils.init();
     }
 }
diff --git a/porter_lightweight/file-service/src/main/resources/log4j2.xml b/porter_lightweight/file-service/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..e3afdb6
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./file/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
index 48c1824..a219d2d 100644
--- a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
@@ -18,11 +18,9 @@
 package org.apache.servicecomb.samples.porter.gateway;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
 
 public class GatewayMain {
     public static void main(String[] args) throws Exception {
-        Log4jUtils.init();
         BeanUtils.init();
     }
 }
diff --git a/porter_lightweight/gateway-service/src/main/resources/log4j2.xml b/porter_lightweight/gateway-service/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..b51f28e
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./gateway/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java
index 390b040..dc7b3ed 100644
--- a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java
@@ -18,11 +18,9 @@
 package org.apache.servicecomb.samples.porter.user;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
 
 public class UserMain {
   public static void main(String[] args) throws Exception {
-    Log4jUtils.init();
     BeanUtils.init();
   }
 }
diff --git a/porter_lightweight/user-service/src/main/resources/log4j2.xml b/porter_lightweight/user-service/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3c70391
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./user/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file


[servicecomb-samples] 10/32: 项目升级到1.2.0,并且增加相关的说明

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 9c9b18d326223868083b5eae15810703824773e1
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Apr 12 12:01:36 2019 +0800

    项目升级到1.2.0,并且增加相关的说明
---
 README.md                                 |  14 +++-
 dependency_management/README.md           |  19 ++++++
 dependency_management/spring4/pom.xml     |   4 +-
 dependency_management/spring5/pom.xml     |   4 +-
 dependency_management/springboot1/pom.xml |  10 ++-
 dependency_management/springboot2/pom.xml |   3 +-
 porter_lightweight/README.md              | 109 ++++++++++++++++++++++++++++++
 porter_lightweight/pom.xml                |   2 +-
 8 files changed, 155 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index 0c15baf..c1d8c06 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,17 @@
-# servicecomb samples
+# ServiceComb samples
 
 ## porter_lightweight
 A sample shows an application with basic login, download file, delete file functions. 
 
 ## dependency_management
-A sample shows how to use dependency management to create spring 4, spring 5, spring boot 1 or spring boot 2 application. 
\ No newline at end of file
+A sample shows how to use dependency management to create spring 4, spring 5, spring boot 1 or spring boot 2 application. 
+
+
+# 使用ServiceComb开发微服务的示例项目
+
+## porter_lightweight
+该项目演示了一个包括网关、文件下载、认证鉴权等功能的简单应用系统,同时演示了ServiceComb推荐的先写接口声明,再写业务代码的软件工程实践。
+
+## dependency_management
+该项目演示了ServiceComb如何依赖spring4, spring 5, spring boot1 和 spring boot 2。
+
diff --git a/dependency_management/README.md b/dependency_management/README.md
new file mode 100644
index 0000000..6caac86
--- /dev/null
+++ b/dependency_management/README.md
@@ -0,0 +1,19 @@
+## dependency_management
+
+A sample shows how to use dependency management to create spring 4, spring 5, spring boot 1 or spring boot 2 application. 
+
+Compile each project and run with IDE or command line. Each servcie provide a simple REST api. This api can be access using
+```
+http://localhost:9090/hello?name=jack
+```
+
+# dependency_management
+
+该项目演示了ServiceComb如何依赖spring4, spring 5, spring boot1 和 spring boot 2。
+
+启动项目后,可以通过:
+```
+http://localhost:9090/hello?name=jack
+```
+
+来访问微服务。
diff --git a/dependency_management/spring4/pom.xml b/dependency_management/spring4/pom.xml
index 9ee8710..cd5e946 100644
--- a/dependency_management/spring4/pom.xml
+++ b/dependency_management/spring4/pom.xml
@@ -29,11 +29,10 @@
 
   <dependencyManagement>
     <dependencies>
-      <!-- need to compile lastest java-chassis code -->
       <dependency>
         <groupId>org.apache.servicecomb</groupId>
         <artifactId>java-chassis-dependencies-spring4</artifactId>
-        <version>1.2.0-SNAPSHOT</version>
+        <version>1.2.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -52,6 +51,7 @@
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
+        <version>1.5.14.RELEASE</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/dependency_management/spring5/pom.xml b/dependency_management/spring5/pom.xml
index 375c070..343b60f 100644
--- a/dependency_management/spring5/pom.xml
+++ b/dependency_management/spring5/pom.xml
@@ -29,11 +29,10 @@
 
   <dependencyManagement>
     <dependencies>
-      <!-- need to compile lastest java-chassis code -->
       <dependency>
         <groupId>org.apache.servicecomb</groupId>
         <artifactId>java-chassis-dependencies-spring5</artifactId>
-        <version>1.2.0-SNAPSHOT</version>
+        <version>1.2.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -52,6 +51,7 @@
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
+        <version>2.1.2.RELEASE</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/dependency_management/springboot1/pom.xml b/dependency_management/springboot1/pom.xml
index da6b1a7..417164c 100644
--- a/dependency_management/springboot1/pom.xml
+++ b/dependency_management/springboot1/pom.xml
@@ -29,14 +29,19 @@
 
   <dependencyManagement>
     <dependencies>
-      <!-- need to compile lastest java-chassis code -->
       <dependency>
         <groupId>org.apache.servicecomb</groupId>
         <artifactId>java-chassis-dependencies-springboot1</artifactId>
-        <version>1.2.0-SNAPSHOT</version>
+        <version>1.2.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
+      <!-- spring boot 1.5.14.RELEASE use a low version of validation-api, must override it -->
+      <dependency>
+        <groupId>javax.validation</groupId>
+        <artifactId>validation-api</artifactId>
+        <version>2.0.0.Final</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
@@ -66,6 +71,7 @@
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
+        <version>1.5.14.RELEASE</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/dependency_management/springboot2/pom.xml b/dependency_management/springboot2/pom.xml
index 8cb3bd9..215afd9 100644
--- a/dependency_management/springboot2/pom.xml
+++ b/dependency_management/springboot2/pom.xml
@@ -33,7 +33,7 @@
       <dependency>
         <groupId>org.apache.servicecomb</groupId>
         <artifactId>java-chassis-dependencies-springboot2</artifactId>
-        <version>1.2.0-SNAPSHOT</version>
+        <version>1.2.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -62,6 +62,7 @@
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
+        <version>2.1.2.RELEASE</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/porter_lightweight/README.md b/porter_lightweight/README.md
index 9870398..93d7bd5 100644
--- a/porter_lightweight/README.md
+++ b/porter_lightweight/README.md
@@ -79,4 +79,113 @@ java $JAVA_OPT -Dgateway.webroot=webapp -jar porter-gateway-service-0.0.1-SNAPSH
 2. 选择一个文件上传,上传成功,上传成功后的文件会保存在file-service的当前目录, 文件名称是一个随机的数字,这个数字就是文件ID。
 3. 删除文件:输入上一步的文件ID,点击删除。 如果是admin用户,上传成功;如果是guest用户,上传失败。
 
+# 接口使用说明
+ServiceComb推荐先定义接口,再定义实现的开发模式。将接口定义为一个独立项目,可以由设计者统一管控,对于接口的修改,需要设计者进行审核。先定义接口还可以让开发者培养良好的开发习惯,避免将对外接口采用内部实现数据结构(比如JsonObject)、运行平台有关的数据结构(比如HttpServletResponse)来定义,使得以后将项目改在为其他技术框架变得复杂。采用这种方式组织的项目,用户很容易在不同的开发框架上进行迁移,比如gRPC、Spring Cloud等。这里的接口定义代码,对于这些运行框架都是通用的,并且具备跨平台特性。
 
+## 对于接口实现者(provider)
+  * 依赖api对应的jar包
+
+```
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>user-service-api-endpoint</artifactId>
+    </dependency>
+  </dependencies>
+```
+
+  * 实现Service接口
+```
+@Service
+public class UserServiceImpl implements UserService
+```
+
+## 对于接口使用者(consumer)
+  * 依赖service对应的jar包(只包含model和接口)
+
+```
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>user-service-api-service</artifactId>
+    </dependency>
+  </dependencies>
+```
+
+  * 采用RCP方式调用
+```
+  @RpcReference(microserviceName = "user-service", schemaId = "user")
+  private static UserService sserService
+```
+
+# REST接口常见争议问题和处理
+
+## 查询接口参数很复杂
+
+比如:
+
+```
+public List<Goods> queryGoodsByTags(String orgId, List<GoodsTag> tags)
+```
+
+当查询参数很复杂的时候,不建议采用query参数或者path参数。主要有如下原因:
+
+* HTTP对于URL的长度有限制
+* 复杂参数可能包含特殊字符,需要客户端在拼接URL的时候,进行URL转码,客户端开发者通常会遗漏。
+* 对象无法和query参数进行合理的映射。
+* query参数或者path参数会被proxy、web server等记录到日志里面,导致日志过大,或者造成敏感信息泄露。
+
+对于复杂的查询操作,建议使用POST方法,相关复杂参数都封装为body。比如:
+
+```
+@PostMapping(path = "queryGoodsByTags")
+public List<Goods> queryGoodsByTags(@RequestParam(name = "orgId") String orgId, @RequestBody List<GoodsTag> tags)
+```
+
+一般的,通过query传递参数的场景,尽可能要保证参数个数少,参数类型为基础类型(字符串、数字等)。参数比较多的场景采用POST来传参。
+
+本项目的处理原则是“尽可能遵循HTTP REST语义,但是不盲目,以系统可靠优先”。
+
+对于DELETE请求,也有类似的情况。在设计GET和DELETE方法时,建议都不使用body参数,尽管HTTP协议并没有强制要求不能使用body,但是由于历史因素,很多WEB服务器支持上会有问题,接口设计应该尽可能避免不必要的麻烦和陷阱。只在POST、PUT、PATCH方法中使用body参数。
+
+## REST接口的Path是否包含操作
+
+比如:下面的接口定义path是否包含deleteGoodsUnitConvertor。 
+
+```
+  @DeleteMapping(path = "deleteGoodsUnitConvertor")
+  public ResponseBase deleteGoodsUnitConvertor(String goodsUnitConvertorId)
+```
+
+由于HTTP的方法POST/PUT/PATCH/GET/DELETE已经包含了增、改、查、删语义,path里面包含delete显得多余。不过由于项目的接口通常比较多,过多的思考接口语义反而增加了理解的难度。所以本项目path全部都包含了方法名字。包含名称有个好处,可以从URL中看出operation id,从而很简单的将URL和契约对应起来,方便查找。此外就是上面提到的原因,并不是所有的删除操作都一定对应于DELETE操作,出于系统可靠性、安全等方面考虑,可能使用POST/PATCH等代表查询或者删除操作。
+
+## 多个对象参数
+
+由于HTTP只能有一个body,所有多个对象参数需要包装为一个参数。 比如:
+
+```
+public ResponseBase inboundOrder(InboundOrder inboundOrder, Set<InboundOrderItem> inboundOrderItems)
+```
+
+封装为下面的REST接口定义:
+
+```
+  @PostMapping(path = "inboundOrder")
+  public ResponseBase inboundOrder(@RequestBody InboundOrderRequest inboundOrderRequest) {
+    return stockService.inboundOrder(inboundOrderRequest.getInboundOrder(), inboundOrderRequest.getInboundOrderItems());
+  }
+```
+
+## 敏感信息不能采用query参数
+
+Query参数可能被各种proxy、web server记录,因此对于用户敏感信息,不能使用query参数。 比如:
+
+```
+public ResponseBase rechargePrepaidCard(String cardId, double amount)
+```
+
+涉及到卡号和金额的数据,需要采用POST提交,参数存储在body。 虽然有些接口仅仅只是查询, 但也可能被设计为POST。 调整后的接口:
+
+```
+public ResponseBase rechargePrepaidCard(@RequestBody PrepaidAmountRequest prepaidAmountRequest)
+```
diff --git a/porter_lightweight/pom.xml b/porter_lightweight/pom.xml
index f891518..08a5500 100644
--- a/porter_lightweight/pom.xml
+++ b/porter_lightweight/pom.xml
@@ -50,7 +50,7 @@
       <dependency>
         <groupId>org.apache.servicecomb</groupId>
         <artifactId>java-chassis-dependencies</artifactId>
-        <version>1.2.0-SNAPSHOT</version>
+        <version>1.2.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>


[servicecomb-samples] 09/32: [SCB-1193]upgread spring boot versions and add easy to use dependency - samples

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 015e63035ac4f162b9c33a0d3cc4e59060a4a835
Author: liubao <ba...@huawei.com>
AuthorDate: Tue Mar 12 20:24:50 2019 +0800

    [SCB-1193]upgread spring boot versions and add easy to use dependency - samples
---
 README.md                                          |  3 +
 dependency_management/spring4/pom.xml              | 67 ++++++++++++++++++
 .../samples/dependencyManagement/Application.java  | 26 +++++++
 .../dependencyManagement/HelloEndpoint.java        | 32 +++++++++
 .../spring4/src/main/resources/log4j2.xml          | 43 ++++++++++++
 .../spring4/src/main/resources/microservice.yaml   | 36 ++++++++++
 dependency_management/spring5/pom.xml              | 67 ++++++++++++++++++
 .../samples/dependencyManagement/Application.java  | 26 +++++++
 .../dependencyManagement/HelloEndpoint.java        | 32 +++++++++
 .../spring5/src/main/resources/log4j2.xml          | 43 ++++++++++++
 .../spring5/src/main/resources/microservice.yaml   | 36 ++++++++++
 dependency_management/springboot1/pom.xml          | 81 ++++++++++++++++++++++
 .../samples/dependencyManagement/Application.java  | 30 ++++++++
 .../dependencyManagement/HelloEndpoint.java        | 32 +++++++++
 .../springboot1/src/main/resources/application.yml | 35 ++++++++++
 dependency_management/springboot2/pom.xml          | 77 ++++++++++++++++++++
 .../samples/dependencyManagement/Application.java  | 30 ++++++++
 .../dependencyManagement/HelloEndpoint.java        | 32 +++++++++
 .../springboot2/src/main/resources/application.yml | 35 ++++++++++
 19 files changed, 763 insertions(+)

diff --git a/README.md b/README.md
index ac5abc5..0c15baf 100644
--- a/README.md
+++ b/README.md
@@ -2,3 +2,6 @@
 
 ## porter_lightweight
 A sample shows an application with basic login, download file, delete file functions. 
+
+## dependency_management
+A sample shows how to use dependency management to create spring 4, spring 5, spring boot 1 or spring boot 2 application. 
\ No newline at end of file
diff --git a/dependency_management/spring4/pom.xml b/dependency_management/spring4/pom.xml
new file mode 100644
index 0000000..9ee8710
--- /dev/null
+++ b/dependency_management/spring4/pom.xml
@@ -0,0 +1,67 @@
+<!-- ~ 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId>
+  <artifactId>spring4</artifactId>
+  <version>0.0.1</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <java.version>1.8</java.version>
+    <argLine>-Dfile.encoding=UTF-8</argLine>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- need to compile lastest java-chassis code -->
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies-spring4</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
new file mode 100644
index 0000000..335c7a5
--- /dev/null
+++ b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
@@ -0,0 +1,26 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class Application {
+    public static void main(String[] args) throws Exception {
+        BeanUtils.init();
+    }
+}
diff --git a/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
new file mode 100644
index 0000000..51923d8
--- /dev/null
+++ b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
@@ -0,0 +1,32 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "hello")
+@RequestMapping(path = "/")
+public class HelloEndpoint {
+  @GetMapping(path = "/hello")
+  public String hello(@RequestParam(name = "name") String name) {
+    return name;
+  }
+}
diff --git a/dependency_management/spring4/src/main/resources/log4j2.xml b/dependency_management/spring4/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..e3afdb6
--- /dev/null
+++ b/dependency_management/spring4/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./file/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/dependency_management/spring4/src/main/resources/microservice.yaml b/dependency_management/spring4/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..e5e3410
--- /dev/null
+++ b/dependency_management/spring4/src/main/resources/microservice.yaml
@@ -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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 10
+
+APPLICATION_ID: dependency_management
+
+service_description:
+  version: 0.0.1
+  name: spring4
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9090
\ No newline at end of file
diff --git a/dependency_management/spring5/pom.xml b/dependency_management/spring5/pom.xml
new file mode 100644
index 0000000..375c070
--- /dev/null
+++ b/dependency_management/spring5/pom.xml
@@ -0,0 +1,67 @@
+<!-- ~ 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId>
+  <artifactId>spring5</artifactId>
+  <version>0.0.1</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <java.version>1.8</java.version>
+    <argLine>-Dfile.encoding=UTF-8</argLine>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- need to compile lastest java-chassis code -->
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies-spring5</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
new file mode 100644
index 0000000..335c7a5
--- /dev/null
+++ b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
@@ -0,0 +1,26 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class Application {
+    public static void main(String[] args) throws Exception {
+        BeanUtils.init();
+    }
+}
diff --git a/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
new file mode 100644
index 0000000..51923d8
--- /dev/null
+++ b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
@@ -0,0 +1,32 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "hello")
+@RequestMapping(path = "/")
+public class HelloEndpoint {
+  @GetMapping(path = "/hello")
+  public String hello(@RequestParam(name = "name") String name) {
+    return name;
+  }
+}
diff --git a/dependency_management/spring5/src/main/resources/log4j2.xml b/dependency_management/spring5/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..e3afdb6
--- /dev/null
+++ b/dependency_management/spring5/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./file/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/dependency_management/spring5/src/main/resources/microservice.yaml b/dependency_management/spring5/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..3efb2e2
--- /dev/null
+++ b/dependency_management/spring5/src/main/resources/microservice.yaml
@@ -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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 10
+
+APPLICATION_ID: dependency_management
+
+service_description:
+  version: 0.0.1
+  name: spring5
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9090
\ No newline at end of file
diff --git a/dependency_management/springboot1/pom.xml b/dependency_management/springboot1/pom.xml
new file mode 100644
index 0000000..da6b1a7
--- /dev/null
+++ b/dependency_management/springboot1/pom.xml
@@ -0,0 +1,81 @@
+<!-- ~ 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId>
+  <artifactId>springboot1</artifactId>
+  <version>0.0.1</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <java.version>1.8</java.version>
+    <argLine>-Dfile.encoding=UTF-8</argLine>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- need to compile lastest java-chassis code -->
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies-springboot1</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.logging.log4j</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-transport</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-web</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
new file mode 100644
index 0000000..072a201
--- /dev/null
+++ b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableServiceComb
+public class Application {
+  public static void main(String[] args) throws Exception {
+    SpringApplication.run(Application.class, args);
+  }
+}
diff --git a/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
new file mode 100644
index 0000000..51923d8
--- /dev/null
+++ b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
@@ -0,0 +1,32 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "hello")
+@RequestMapping(path = "/")
+public class HelloEndpoint {
+  @GetMapping(path = "/hello")
+  public String hello(@RequestParam(name = "name") String name) {
+    return name;
+  }
+}
diff --git a/dependency_management/springboot1/src/main/resources/application.yml b/dependency_management/springboot1/src/main/resources/application.yml
new file mode 100644
index 0000000..590d7b6
--- /dev/null
+++ b/dependency_management/springboot1/src/main/resources/application.yml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+server:
+  port: 9090
+
+APPLICATION_ID: dependency_management
+
+service_description:
+  version: 0.0.1
+  name: springboot1
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9090
\ No newline at end of file
diff --git a/dependency_management/springboot2/pom.xml b/dependency_management/springboot2/pom.xml
new file mode 100644
index 0000000..8cb3bd9
--- /dev/null
+++ b/dependency_management/springboot2/pom.xml
@@ -0,0 +1,77 @@
+<!-- ~ 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId>
+  <artifactId>springboot2</artifactId>
+  <version>0.0.1</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <java.version>1.8</java.version>
+    <argLine>-Dfile.encoding=UTF-8</argLine>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- need to compile lastest java-chassis code -->
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies-springboot2</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.logging.log4j</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot2-starter-servlet</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
new file mode 100644
index 0000000..876b1a2
--- /dev/null
+++ b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.SpringApplication;
+
+@SpringBootApplication
+@EnableServiceComb
+public class Application {
+  public static void main(String[] args) throws Exception {
+    SpringApplication.run(Application.class, args);
+  }
+}
diff --git a/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
new file mode 100644
index 0000000..51923d8
--- /dev/null
+++ b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java
@@ -0,0 +1,32 @@
+/*
+ * 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.servicecomb.samples.dependencyManagement;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "hello")
+@RequestMapping(path = "/")
+public class HelloEndpoint {
+  @GetMapping(path = "/hello")
+  public String hello(@RequestParam(name = "name") String name) {
+    return name;
+  }
+}
diff --git a/dependency_management/springboot2/src/main/resources/application.yml b/dependency_management/springboot2/src/main/resources/application.yml
new file mode 100644
index 0000000..cab54c0
--- /dev/null
+++ b/dependency_management/springboot2/src/main/resources/application.yml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+server:
+  port: 9090
+
+APPLICATION_ID: dependency_management
+
+service_description:
+  version: 0.0.1
+  name: springboot2
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9090
\ No newline at end of file


[servicecomb-samples] 13/32: 增加分布式运维的例子

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit e51b877c927d39f421ea3a215625b78012ee340b
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Apr 26 17:56:08 2019 +0800

    增加分布式运维的例子
---
 .../api/{ => common/endpoint}/pom.xml              |  20 +-
 .../samples/porter/file/api/InspectorEndpoint.java | 206 +++++++++++++++++++++
 .../samples/porter/file/api/LogEndpoint.java       |  72 +++++++
 porter_lightweight/api/{ => common}/pom.xml        |   8 +-
 .../api/{ => common/service}/pom.xml               |  13 +-
 .../samples/porter/common/api/LogService.java      |  26 +++
 porter_lightweight/api/pom.xml                     |   1 +
 porter_lightweight/file-service/pom.xml            |   9 +
 .../main/resources/META-INF/spring/file.bean.xml   |   3 +-
 .../src/main/resources/microservice.yaml           |  13 +-
 porter_lightweight/gateway-service/pom.xml         |   9 +
 .../porter/gateway/CustomVertxRestDispatcher.java  | 196 ++++++++++++++++++++
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |   3 +-
 .../main/resources/META-INF/spring/cse.bean.xml}   |  16 +-
 .../src/main/resources/microservice.yaml           |  13 ++
 porter_lightweight/user-service/pom.xml            |   9 +
 .../main/resources/META-INF/spring/user.bean.xml   |   4 +-
 .../src/main/resources/microservice.yaml           |  13 +-
 18 files changed, 599 insertions(+), 35 deletions(-)

diff --git a/porter_lightweight/api/pom.xml b/porter_lightweight/api/common/endpoint/pom.xml
similarity index 77%
copy from porter_lightweight/api/pom.xml
copy to porter_lightweight/api/common/endpoint/pom.xml
index 018a879..df1628b 100644
--- a/porter_lightweight/api/pom.xml
+++ b/porter_lightweight/api/common/endpoint/pom.xml
@@ -15,22 +15,24 @@
   ~ 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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>common-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-api</artifactId>
-  <packaging>pom</packaging>
+  <artifactId>common-api-endpoint</artifactId>
+  <packaging>jar</packaging>
 
-  <modules>
-    <module>file-service</module>
-    <module>user-service</module>
-  </modules>
-</project>
\ No newline at end of file
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>common-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/porter_lightweight/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java b/porter_lightweight/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
new file mode 100644
index 0000000..731f6ac
--- /dev/null
+++ b/porter_lightweight/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
@@ -0,0 +1,206 @@
+/*
+ * 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.servicecomb.samples.porter.file.api;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.Map.Entry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.servlet.http.Part;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.servicecomb.common.rest.resource.ClassPathStaticResourceHandler;
+import org.apache.servicecomb.common.rest.resource.StaticResourceHandler;
+import org.apache.servicecomb.config.inject.ConfigObjectFactory;
+import org.apache.servicecomb.foundation.common.part.InputStreamPart;
+import org.apache.servicecomb.inspector.internal.InspectorConfig;
+import org.apache.servicecomb.inspector.internal.swagger.AppendStyleProcessor;
+import org.apache.servicecomb.inspector.internal.swagger.SchemaFormat;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.swagger.SwaggerUtils;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.asciidoctor.Asciidoctor;
+import org.asciidoctor.Asciidoctor.Factory;
+import org.asciidoctor.Attributes;
+import org.asciidoctor.AttributesBuilder;
+import org.asciidoctor.OptionsBuilder;
+import org.asciidoctor.SafeMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Ordering;
+
+import io.github.swagger2markup.Swagger2MarkupConfig;
+import io.github.swagger2markup.Swagger2MarkupConverter;
+import io.github.swagger2markup.Swagger2MarkupConverter.Builder;
+import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.models.parameters.Parameter;
+
+// copied from org.apache.servicecomb.inspector.internal.InspectorImpl;
+@RestSchema(schemaId = "inspector")
+@Path("/inspector")
+public class InspectorEndpoint {
+  private static final Logger LOGGER = LoggerFactory.getLogger(InspectorEndpoint.class);
+
+  private InspectorConfig inspectorConfig;
+
+  private volatile Asciidoctor asciidoctor;
+
+  private StaticResourceHandler resourceHandler = new ClassPathStaticResourceHandler();
+
+  public InspectorEndpoint() {
+    this.inspectorConfig = new ConfigObjectFactory().create(InspectorConfig.class);
+  }
+
+  @Path("/schemas")
+  @GET
+  public Collection<String> getSchemaIds() {
+    return RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().keySet();
+  }
+
+  @Path("/download/schemas")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response downloadSchemas(@QueryParam("format") SchemaFormat format) {
+    if (format == null) {
+      format = SchemaFormat.SWAGGER;
+    }
+
+    // normally, schema will not be too big, just save them in memory temporarily
+    ByteArrayOutputStream os = new ByteArrayOutputStream();
+    try (ZipOutputStream zos = new ZipOutputStream(os)) {
+      for (Entry<String, String> entry : RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().entrySet()) {
+        // begin writing a new ZIP entry, positions the stream to the start of the entry data
+        zos.putNextEntry(new ZipEntry(entry.getKey() + format.getSuffix()));
+
+        String content = entry.getValue();
+        if (SchemaFormat.HTML.equals(format)) {
+          content = swaggerToHtml(content);
+        }
+        zos.write(content.getBytes(StandardCharsets.UTF_8));
+        zos.closeEntry();
+      }
+    } catch (Throwable e) {
+      String msg = "failed to create schemas zip file, format=" + format + ".";
+      LOGGER.error(msg, e);
+      return Response.failResp(new InvocationException(Status.INTERNAL_SERVER_ERROR, msg));
+    }
+
+    Part part = new InputStreamPart(null, new ByteArrayInputStream(os.toByteArray()))
+        .setSubmittedFileName(RegistryUtils.getMicroservice().getServiceName() + format.getSuffix() + ".zip");
+    return Response.ok(part);
+  }
+
+  @Path("/schemas/{schemaId}")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response getSchemaContentById(@PathParam("schemaId") String schemaId,
+      @QueryParam("format") SchemaFormat format, @QueryParam("download") boolean download) {
+    String swaggerContent = RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().get(schemaId);
+    if (swaggerContent == null) {
+      return Response.failResp(new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase()));
+    }
+
+    if (format == null) {
+      format = SchemaFormat.SWAGGER;
+    }
+
+    byte[] bytes;
+    if (SchemaFormat.HTML.equals(format)) {
+      String html = swaggerToHtml(swaggerContent);
+      bytes = html.getBytes(StandardCharsets.UTF_8);
+    } else {
+      bytes = swaggerContent.getBytes(StandardCharsets.UTF_8);
+    }
+
+    Part part = new InputStreamPart(null, new ByteArrayInputStream(bytes))
+        .setSubmittedFileName(schemaId + format.getSuffix());
+
+    Response response = Response.ok(part);
+    if (!download) {
+      response.getHeaders().addHeader(HttpHeaders.CONTENT_DISPOSITION, "inline");
+    }
+    response.getHeaders().addHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML);
+    return response;
+  }
+
+  // swagger not support cookie parameter
+  // so if swaggerContent contains cookie parameter, will cause problem.
+  private String swaggerToHtml(String swaggerContent) {
+    if (asciidoctor == null) {
+      synchronized (this) {
+        if (asciidoctor == null) {
+          // very slow, need a few seconds
+          LOGGER.info("create AsciiDoctor start.");
+          asciidoctor = Factory.create();
+          asciidoctor.javaExtensionRegistry().docinfoProcessor(AppendStyleProcessor.class);
+          LOGGER.info("create AsciiDoctor end.");
+        }
+      }
+    }
+
+    // swagger to markup
+    Builder markupBuilder = Swagger2MarkupConverter.from(SwaggerUtils.parseSwagger(swaggerContent));
+    // default not support cookie parameter
+    // so must customize config
+    Swagger2MarkupConfig markupConfig = new Swagger2MarkupConfigBuilder()
+        .withParameterOrdering(Ordering
+            .explicit("path", "query", "header", "cookie", "formData", "body")
+            .onResultOf(Parameter::getIn))
+        .build();
+    String markup = markupBuilder.withConfig(markupConfig).build().toString();
+
+    // markup to html
+    OptionsBuilder builder = OptionsBuilder.options();
+    builder.docType("book")
+        .backend("html5")
+        .headerFooter(true)
+        .safe(SafeMode.UNSAFE)
+        .attributes(AttributesBuilder.attributes()
+            .attribute("toclevels", 3)
+            .attribute(Attributes.TOC_2, true)
+            .attribute(Attributes.TOC_POSITION, "left")
+            .attribute(Attributes.LINK_CSS, true)
+            .attribute(Attributes.STYLESHEET_NAME, inspectorConfig.getAsciidoctorCss())
+            .attribute(Attributes.SECTION_NUMBERS, true)
+            .attribute(Attributes.SECT_NUM_LEVELS, 4));
+    return asciidoctor.convert(markup, builder.asMap());
+  }
+
+  @Path("/{path : .+}")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response getStaticResource(@PathParam("path") String path) {
+    return resourceHandler.handle(path);
+  }
+}
+
diff --git a/porter_lightweight/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java b/porter_lightweight/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
new file mode 100644
index 0000000..8e49a6e
--- /dev/null
+++ b/porter_lightweight/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
@@ -0,0 +1,72 @@
+/*
+ * 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.servicecomb.samples.porter.file.api;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.porter.common.api.LogService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+@RestSchema(schemaId = "log")
+@RequestMapping(path = "/v1/log")
+public class LogEndpoint implements LogService {
+  // protect your file in real applications
+  private static final File LOG_DIR =
+      new File(DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.samples.logdir", ".").get());
+
+  private static final String FILE_POST_FIX = ".log";
+
+  @Override
+  @GetMapping(path = "/getLogFileList")
+  public List<String> getLogFileList() {
+    File[] files = LOG_DIR.listFiles(new FileFilter() {
+      @Override
+      public boolean accept(File file) {
+        return isLogFile(file);
+      }
+    });
+
+    List<String> result = new ArrayList<>(files.length);
+    for (int i = 0; i < files.length; i++) {
+      result.add(files[i].getName());
+    }
+    return result;
+  }
+
+  @Override
+  @GetMapping(path = "/getLogFileContent")
+  public File getLogFileContent(@RequestParam(name = "fileName") String fileName) {
+    File file = new File(LOG_DIR, fileName);
+    if (isLogFile(file)) {
+      return file;
+    }
+    return null;
+  }
+
+  private boolean isLogFile(File file) {
+    return file.isFile() && file.canRead() && file.getName().endsWith(FILE_POST_FIX);
+  }
+}
diff --git a/porter_lightweight/api/pom.xml b/porter_lightweight/api/common/pom.xml
similarity index 88%
copy from porter_lightweight/api/pom.xml
copy to porter_lightweight/api/common/pom.xml
index 018a879..5c28887 100644
--- a/porter_lightweight/api/pom.xml
+++ b/porter_lightweight/api/common/pom.xml
@@ -22,15 +22,15 @@
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>porter-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-api</artifactId>
+  <artifactId>common-api</artifactId>
   <packaging>pom</packaging>
 
   <modules>
-    <module>file-service</module>
-    <module>user-service</module>
+    <module>service</module>
+    <module>endpoint</module>
   </modules>
 </project>
\ No newline at end of file
diff --git a/porter_lightweight/api/pom.xml b/porter_lightweight/api/common/service/pom.xml
similarity index 84%
copy from porter_lightweight/api/pom.xml
copy to porter_lightweight/api/common/service/pom.xml
index 018a879..41a7d85 100644
--- a/porter_lightweight/api/pom.xml
+++ b/porter_lightweight/api/common/service/pom.xml
@@ -15,22 +15,17 @@
   ~ 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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.apache.servicecomb.samples.porter</groupId>
-    <artifactId>porter-application</artifactId>
+    <artifactId>common-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>porter-api</artifactId>
-  <packaging>pom</packaging>
+  <artifactId>common-api-service</artifactId>
+  <packaging>jar</packaging>
 
-  <modules>
-    <module>file-service</module>
-    <module>user-service</module>
-  </modules>
-</project>
\ No newline at end of file
+</project>
diff --git a/porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java b/porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
new file mode 100644
index 0000000..9991543
--- /dev/null
+++ b/porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
@@ -0,0 +1,26 @@
+/*
+ * 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.servicecomb.samples.porter.common.api;
+
+import java.io.File;
+import java.util.List;
+
+public interface LogService {
+  List<String> getLogFileList();
+  File getLogFileContent(String fileName);
+}
diff --git a/porter_lightweight/api/pom.xml b/porter_lightweight/api/pom.xml
index 018a879..faa2d56 100644
--- a/porter_lightweight/api/pom.xml
+++ b/porter_lightweight/api/pom.xml
@@ -30,6 +30,7 @@
   <packaging>pom</packaging>
 
   <modules>
+    <module>common</module>
     <module>file-service</module>
     <module>user-service</module>
   </modules>
diff --git a/porter_lightweight/file-service/pom.xml b/porter_lightweight/file-service/pom.xml
index 6ae53d6..02eea87 100644
--- a/porter_lightweight/file-service/pom.xml
+++ b/porter_lightweight/file-service/pom.xml
@@ -30,10 +30,19 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
       <artifactId>file-service-api-endpoint</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>common-api-endpoint</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
   </dependencies>
   <properties>
     <main.class>org.apache.servicecomb.samples.porter.file.FileMain</main.class>
diff --git a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
index c679960..692102e 100644
--- a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
+++ b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
@@ -23,5 +23,6 @@
     xsi:schemaLocation="
         http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
 </beans>
\ No newline at end of file
diff --git a/porter_lightweight/file-service/src/main/resources/microservice.yaml b/porter_lightweight/file-service/src/main/resources/microservice.yaml
index dc4a845..f473dbe 100644
--- a/porter_lightweight/file-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/file-service/src/main/resources/microservice.yaml
@@ -36,4 +36,15 @@ servicecomb:
     address: 0.0.0.0:9091
 
   uploads:
-    directory: tmp_for_upload_file
\ No newline at end of file
+    directory: tmp_for_upload_file
+
+  samples:
+    logdir: D:\code\servicecomb-samples\porter_lightweight\file-service
+    
+  inspector:
+    enabled: false
+
+  executors:
+   Provider:
+     log: servicecomb.samples.executor.groupThreadPool
+     inspector: servicecomb.samples.executor.groupThreadPool
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/pom.xml b/porter_lightweight/gateway-service/pom.xml
index 252935e..343beb3 100644
--- a/porter_lightweight/gateway-service/pom.xml
+++ b/porter_lightweight/gateway-service/pom.xml
@@ -34,11 +34,20 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
       <artifactId>user-service-api-service</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>common-api-endpoint</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>edge-core</artifactId>
     </dependency>
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
new file mode 100644
index 0000000..245e0af
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
@@ -0,0 +1,196 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.servicecomb.common.rest.AbstractRestInvocation;
+import org.apache.servicecomb.common.rest.RestConst;
+import org.apache.servicecomb.common.rest.VertxRestInvocation;
+import org.apache.servicecomb.core.Const;
+import org.apache.servicecomb.core.CseContext;
+import org.apache.servicecomb.core.Transport;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
+import org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest;
+import org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.apache.servicecomb.transport.rest.vertx.AbstractVertxHttpDispatcher;
+import org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
+import io.vertx.core.json.JsonObject;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.CookieHandler;
+
+// copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher
+public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
+  private static final Logger LOGGER = LoggerFactory.getLogger(VertxRestDispatcher.class);
+
+  private Transport transport;
+
+  @Override
+  public int getOrder() {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public boolean enabled() {
+    return true;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "[/v1/log/|/inspector](.*)";
+    router.routeWithRegex(regex).handler(CookieHandler.create());
+    router.routeWithRegex(regex).handler(createBodyHandler());
+    router.routeWithRegex(regex).failureHandler(this::failureHandler).handler(this::onRequest);
+  }
+
+  private void failureHandler(RoutingContext context) {
+    LOGGER.error("http server failed.", context.failure());
+
+    AbstractRestInvocation restProducerInvocation = context.get(RestConst.REST_PRODUCER_INVOCATION);
+    Throwable e = context.failure();
+    if (ErrorDataDecoderException.class.isInstance(e)) {
+      Throwable cause = e.getCause();
+      if (InvocationException.class.isInstance(cause)) {
+        e = cause;
+      }
+    }
+
+    // only when unexpected exception happens, it will run into here.
+    // the connection should be closed.
+    handleFailureAndClose(context, restProducerInvocation, e);
+  }
+
+  /**
+   * Try to find out the failure information and send it in response.
+   */
+  private void handleFailureAndClose(RoutingContext context, AbstractRestInvocation restProducerInvocation,
+      Throwable e) {
+    if (null != restProducerInvocation) {
+      // if there is restProducerInvocation, let it send exception in response. The exception is allowed to be null.
+      sendFailResponseByInvocation(context, restProducerInvocation, e);
+      return;
+    }
+
+    if (null != e) {
+      // if there exists exception, try to send this exception by RoutingContext
+      sendExceptionByRoutingContext(context, e);
+      return;
+    }
+
+    // if there is no exception, the response is determined by status code.
+    sendFailureRespDeterminedByStatus(context);
+  }
+
+  /**
+   * Try to determine response by status code, and send response.
+   */
+  private void sendFailureRespDeterminedByStatus(RoutingContext context) {
+    Family statusFamily = Family.familyOf(context.statusCode());
+    if (Family.CLIENT_ERROR.equals(statusFamily) || Family.SERVER_ERROR.equals(statusFamily) || Family.OTHER
+        .equals(statusFamily)) {
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(context.statusCode()).end();
+    } else {
+      // it seems the status code is not set properly
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode())
+          .setStatusMessage(Status.INTERNAL_SERVER_ERROR.getReasonPhrase())
+          .end(wrapResponseBody(Status.INTERNAL_SERVER_ERROR.getReasonPhrase()));
+    }
+    context.response().close();
+  }
+
+  /**
+   * Use routingContext to send failure information in throwable.
+   */
+  private void sendExceptionByRoutingContext(RoutingContext context, Throwable e) {
+    if (InvocationException.class.isInstance(e)) {
+      InvocationException invocationException = (InvocationException) e;
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(invocationException.getStatusCode()).setStatusMessage(invocationException.getReasonPhrase())
+          .end(wrapResponseBody(invocationException.getReasonPhrase()));
+    } else {
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).end(wrapResponseBody(e.getMessage()));
+    }
+    context.response().close();
+  }
+
+  /**
+   * Consumer will treat the response body as json by default, so it's necessary to wrap response body as Json string
+   * to avoid deserialization error.
+   *
+   * @param message response body
+   * @return response body wrapped as Json string
+   */
+  String wrapResponseBody(String message) {
+    if (isValidJson(message)) {
+      return message;
+    }
+
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.put("message", message);
+
+    return jsonObject.toString();
+  }
+
+  /**
+   * Check if the message is a valid Json string.
+   * @param message the message to be checked.
+   * @return true if message is a valid Json string, otherwise false.
+   */
+  private boolean isValidJson(String message) {
+    try {
+      new JsonObject(message);
+    } catch (Exception ignored) {
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Use restProducerInvocation to send failure message. The throwable is allowed to be null.
+   */
+  private void sendFailResponseByInvocation(RoutingContext context, AbstractRestInvocation restProducerInvocation,
+      Throwable e) {
+    restProducerInvocation.sendFailResponse(e);
+    context.response().close();
+  }
+
+  private void onRequest(RoutingContext context) {
+    if (transport == null) {
+      transport = CseContext.getInstance().getTransportManager().findTransport(Const.RESTFUL);
+    }
+    HttpServletRequestEx requestEx = new VertxServerRequestToHttpServletRequest(context);
+    HttpServletResponseEx responseEx = new VertxServerResponseToHttpServletResponse(context.response());
+
+    VertxRestInvocation vertxRestInvocation = new VertxRestInvocation();
+    context.put(RestConst.REST_PRODUCER_INVOCATION, vertxRestInvocation);
+    vertxRestInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
+  }
+}
diff --git a/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index 71009db..bada1de 100644
--- a/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -16,4 +16,5 @@
 #
 
 org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
-org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
\ No newline at end of file
+org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
+org.apache.servicecomb.samples.porter.gateway.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml b/porter_lightweight/gateway-service/src/main/resources/META-INF/spring/cse.bean.xml
similarity index 60%
copy from porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
copy to porter_lightweight/gateway-service/src/main/resources/META-INF/spring/cse.bean.xml
index c679960..b5816c3 100644
--- a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
+++ b/porter_lightweight/gateway-service/src/main/resources/META-INF/spring/cse.bean.xml
@@ -16,12 +16,12 @@
   ~ limitations under the License.
   -->
 
-<beans xmlns="http://www.springframework.org/schema/beans"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-    xmlns:util="http://www.springframework.org/schema/util"
-    xmlns:context="http://www.springframework.org/schema/context"
-    xsi:schemaLocation="
-        http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
-        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:context="http://www.springframework.org/schema/context"
+  xsi:schemaLocation="
+		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
 
-</beans>
\ No newline at end of file
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+</beans>
diff --git a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
index 2462c7f..c05dc5a 100644
--- a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
@@ -42,6 +42,19 @@ servicecomb:
   uploads:
     directory: tmp_for_upload_gateway
 
+  samples:
+    logdir: D:\code\servicecomb-samples\porter_lightweight\gateway-service
+    
+  inspector:
+    enabled: false
+
+  executors:
+   Provider:
+     log: servicecomb.samples.executor.groupThreadPool
+     inspector: servicecomb.samples.executor.groupThreadPool
+
 servicecomb.http.dispatcher.edge.default.enabled: false
+# StaticWebpageDispatcher checking file exists is async, and will mark request status to ended, and VertxRestDispatcher read 
+# body will print exception. 
 servicecomb.http.dispatcher.rest.enabled: false
 gateway.webroot: /code/servicecomb-samples/porter_lightweight/gateway-service/src/main/resources
diff --git a/porter_lightweight/user-service/pom.xml b/porter_lightweight/user-service/pom.xml
index 7e8c20f..100bdcf 100644
--- a/porter_lightweight/user-service/pom.xml
+++ b/porter_lightweight/user-service/pom.xml
@@ -35,11 +35,20 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb.samples.porter</groupId>
       <artifactId>user-service-api-endpoint</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>common-api-endpoint</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <dependency>
       <groupId>org.mybatis</groupId>
       <artifactId>mybatis</artifactId>
     </dependency>
diff --git a/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
index 3cc2dd2..661608f 100644
--- a/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
+++ b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
@@ -25,7 +25,9 @@
 		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+    
     <bean id="dataSource"
         class="org.apache.commons.dbcp2.BasicDataSource"
         destroy-method="close">
diff --git a/porter_lightweight/user-service/src/main/resources/microservice.yaml b/porter_lightweight/user-service/src/main/resources/microservice.yaml
index 5daaea5..af37379 100644
--- a/porter_lightweight/user-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/user-service/src/main/resources/microservice.yaml
@@ -32,4 +32,15 @@ servicecomb:
         watch: false
 
   rest:
-    address: 0.0.0.0:9093
\ No newline at end of file
+    address: 0.0.0.0:9093
+
+  samples:
+    logdir: D:\code\servicecomb-samples\porter_lightweight\user-service
+    
+  inspector:
+    enabled: false
+
+  executors:
+   Provider:
+     log: servicecomb.samples.executor.groupThreadPool
+     inspector: servicecomb.samples.executor.groupThreadPool
\ No newline at end of file


[servicecomb-samples] 21/32: refract project structures

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 161f7960091dd8ef486707882d872d90d861f7be
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 17 10:51:09 2019 +0800

    refract project structures
---
 .../main/resources/META-INF/spring/user.bean.xml   |  24 ---
 .../resources/META-INF/spring/resource.bean.xml    |  30 ---
 .../endpoint/pom.xml                               |   0
 .../authentication/api/AuthenticationEndpoint.java |   0
 .../pom.xml                                        |   0
 .../service/pom.xml                                |   0
 .../authentication/api/AuthenticationService.java  |   0
 .../servicecomb/authentication/api/Token.java      |   0
 .../samples/porter/file/api/InspectorEndpoint.java | 206 ---------------------
 .../samples/porter/file/api/LogEndpoint.java       |  72 -------
 .../samples/porter/common/api/LogService.java      |  26 ---
 authentication/api/edge-service/endpoint/pom.xml   |  38 ++++
 .../edge}/AuthenticationEndpoint.java              |   2 +-
 .../cse.bean.xml => api/edge-service/pom.xml}      |  25 ++-
 authentication/api/edge-service/service/pom.xml    |  42 +++++
 .../authentication/edge}/AuthHandler.java          |   2 +-
 .../authentication/edge}/AuthenticationFilter.java |   2 +-
 .../edge}/CustomVertxRestDispatcher.java           |   2 +-
 .../edge}/InternalAccessHandler.java               |   2 +-
 ...servicecomb.common.rest.filter.HttpServerFilter |   2 +-
 ...ecomb.transport.rest.vertx.VertxHttpDispatcher} |   2 +-
 .../src/main/resources/config/cse.handler.xml      |   4 +-
 authentication/api/pom.xml                         |   4 +-
 .../endpoint/pom.xml                               |   6 +-
 .../pom.xml                                        |   2 +-
 authentication/api/resource-server/service/pom.xml |  42 +++++
 .../resource/AccessConfiguration.java              |   0
 .../resource/AccessConfigurationManager.java       |   0
 ...eptionExceptionToProducerResponseConverter.java |   0
 .../resource/ResourceAuthHandler.java              |   0
 .../resource/SimpleAuthentication.java             |   0
 ....exception.ExceptionToProducerResponseConverter |   0
 .../src/main/resources/config/cse.handler.xml      |   0
 .../{ => samples}/AuthenticationServer/pom.xml     |   8 +-
 .../AuthenticationConfiguration.java               |   0
 .../authentication/AuthenticationServerMain.java   |   0
 .../service/AuthenticationServiceImpl.java         |   0
 .../src/main/resources/log4j2.xml                  |   0
 .../src/main/resources/microservice.yaml           |   0
 authentication/{ => samples}/Client/pom.xml        |   9 +-
 .../authentication/AuthenticationClientMain.java   |   0
 .../authentication/AuthenticationTestCase.java     |   0
 .../authentication/BootEventListener.java          |   0
 .../authentication/GateRestTemplate.java           |   0
 .../authentication/ITUriTemplateHandler.java       |   0
 .../servicecomb/authentication/TestCase.java       |   0
 .../servicecomb/authentication/TestEndpoint.java   |   0
 .../apache/servicecomb/authentication/TestMgr.java |   0
 .../Client/src/main/resources/log4j2.xml           |   0
 .../Client/src/main/resources/microservice.yaml    |   0
 .../{Gateway => samples/EdgeService}/pom.xml       |  15 +-
 .../authentication/gateway/ApiDispatcher.java      |   0
 .../gateway/AuthenticationConfiguration.java       |   0
 .../gateway/AuthenticationEdgeMain.java}           |   2 +-
 .../authentication/gateway/EdgeSSLCustom.java      |   0
 .../gateway/StaticWebpageDispatcher.java           |   0
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |   3 +-
 .../EdgeService}/src/main/resources/log4j2.xml     |   0
 .../src/main/resources/microservice.yaml           |   0
 .../src/main/resources/ui/css/style.css            |   0
 .../src/main/resources/ui/js/jquery-1.11.1.min.js  |   0
 .../EdgeService}/src/main/resources/ui/js/login.js |   0
 .../src/main/resources/ui/js/upload.js             |   0
 .../EdgeService}/src/main/resources/ui/login.html  |   0
 .../EdgeService}/src/main/resources/ui/upload.html |   0
 .../authentication/test/PatternTest.java           |   0
 .../{ => samples}/ResourceServer/pom.xml           |  22 +--
 .../resource/AuthenticationConfiguration.java      |   0
 .../authentication/resource/FileEndpoint.java      |   0
 .../authentication/resource/FileStoreService.java  |   0
 .../resource/HandlerAuthEndpoint.java              |   0
 .../resource/LocalFileStoreService.java            |   0
 .../resource/MethodSecurityConfiguration.java      |   0
 .../resource/PreMethodAuthEndpoint.java            |   0
 .../resource}/ResourceServerMain.java              |   2 +-
 .../ResourceServer}/src/main/resources/log4j2.xml  |   0
 .../src/main/resources/microservice.yaml           |   0
 authentication/{api => samples}/pom.xml            |   6 +-
 78 files changed, 194 insertions(+), 408 deletions(-)

diff --git a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
deleted file mode 100644
index b33e5c9..0000000
--- a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
+++ /dev/null
@@ -1,24 +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:p="http://www.springframework.org/schema/p"
-  xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
-  xmlns:tx="http://www.springframework.org/schema/tx"
-  xsi:schemaLocation="
-		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
-        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
-		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init" />
-</beans>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml b/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
deleted file mode 100644
index fd84e44..0000000
--- a/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
+++ /dev/null
@@ -1,30 +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:p="http://www.springframework.org/schema/p"
-    xmlns:util="http://www.springframework.org/schema/util"
-    xmlns:context="http://www.springframework.org/schema/context"
-    xmlns:tx="http://www.springframework.org/schema/tx"
-    xsi:schemaLocation="
-		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
-        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
-		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init"/>
-</beans>
\ No newline at end of file
diff --git a/authentication/api/AuthenticationServer/endpoint/pom.xml b/authentication/api/authentication-server/endpoint/pom.xml
similarity index 100%
copy from authentication/api/AuthenticationServer/endpoint/pom.xml
copy to authentication/api/authentication-server/endpoint/pom.xml
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
similarity index 100%
rename from authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
rename to authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
diff --git a/authentication/api/AuthenticationServer/pom.xml b/authentication/api/authentication-server/pom.xml
similarity index 100%
copy from authentication/api/AuthenticationServer/pom.xml
copy to authentication/api/authentication-server/pom.xml
diff --git a/authentication/api/AuthenticationServer/service/pom.xml b/authentication/api/authentication-server/service/pom.xml
similarity index 100%
rename from authentication/api/AuthenticationServer/service/pom.xml
rename to authentication/api/authentication-server/service/pom.xml
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
similarity index 100%
rename from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
similarity index 100%
rename from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
diff --git a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
deleted file mode 100644
index 731f6ac..0000000
--- a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
+++ /dev/null
@@ -1,206 +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.servicecomb.samples.porter.file.api;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.Map.Entry;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import javax.servlet.http.Part;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response.Status;
-
-import org.apache.servicecomb.common.rest.resource.ClassPathStaticResourceHandler;
-import org.apache.servicecomb.common.rest.resource.StaticResourceHandler;
-import org.apache.servicecomb.config.inject.ConfigObjectFactory;
-import org.apache.servicecomb.foundation.common.part.InputStreamPart;
-import org.apache.servicecomb.inspector.internal.InspectorConfig;
-import org.apache.servicecomb.inspector.internal.swagger.AppendStyleProcessor;
-import org.apache.servicecomb.inspector.internal.swagger.SchemaFormat;
-import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.apache.servicecomb.serviceregistry.RegistryUtils;
-import org.apache.servicecomb.swagger.SwaggerUtils;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-import org.asciidoctor.Asciidoctor;
-import org.asciidoctor.Asciidoctor.Factory;
-import org.asciidoctor.Attributes;
-import org.asciidoctor.AttributesBuilder;
-import org.asciidoctor.OptionsBuilder;
-import org.asciidoctor.SafeMode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Ordering;
-
-import io.github.swagger2markup.Swagger2MarkupConfig;
-import io.github.swagger2markup.Swagger2MarkupConverter;
-import io.github.swagger2markup.Swagger2MarkupConverter.Builder;
-import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.models.parameters.Parameter;
-
-// copied from org.apache.servicecomb.inspector.internal.InspectorImpl;
-@RestSchema(schemaId = "inspector")
-@Path("/inspector")
-public class InspectorEndpoint {
-  private static final Logger LOGGER = LoggerFactory.getLogger(InspectorEndpoint.class);
-
-  private InspectorConfig inspectorConfig;
-
-  private volatile Asciidoctor asciidoctor;
-
-  private StaticResourceHandler resourceHandler = new ClassPathStaticResourceHandler();
-
-  public InspectorEndpoint() {
-    this.inspectorConfig = new ConfigObjectFactory().create(InspectorConfig.class);
-  }
-
-  @Path("/schemas")
-  @GET
-  public Collection<String> getSchemaIds() {
-    return RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().keySet();
-  }
-
-  @Path("/download/schemas")
-  @GET
-  @ApiResponse(code = 200, message = "", response = File.class)
-  public Response downloadSchemas(@QueryParam("format") SchemaFormat format) {
-    if (format == null) {
-      format = SchemaFormat.SWAGGER;
-    }
-
-    // normally, schema will not be too big, just save them in memory temporarily
-    ByteArrayOutputStream os = new ByteArrayOutputStream();
-    try (ZipOutputStream zos = new ZipOutputStream(os)) {
-      for (Entry<String, String> entry : RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().entrySet()) {
-        // begin writing a new ZIP entry, positions the stream to the start of the entry data
-        zos.putNextEntry(new ZipEntry(entry.getKey() + format.getSuffix()));
-
-        String content = entry.getValue();
-        if (SchemaFormat.HTML.equals(format)) {
-          content = swaggerToHtml(content);
-        }
-        zos.write(content.getBytes(StandardCharsets.UTF_8));
-        zos.closeEntry();
-      }
-    } catch (Throwable e) {
-      String msg = "failed to create schemas zip file, format=" + format + ".";
-      LOGGER.error(msg, e);
-      return Response.failResp(new InvocationException(Status.INTERNAL_SERVER_ERROR, msg));
-    }
-
-    Part part = new InputStreamPart(null, new ByteArrayInputStream(os.toByteArray()))
-        .setSubmittedFileName(RegistryUtils.getMicroservice().getServiceName() + format.getSuffix() + ".zip");
-    return Response.ok(part);
-  }
-
-  @Path("/schemas/{schemaId}")
-  @GET
-  @ApiResponse(code = 200, message = "", response = File.class)
-  public Response getSchemaContentById(@PathParam("schemaId") String schemaId,
-      @QueryParam("format") SchemaFormat format, @QueryParam("download") boolean download) {
-    String swaggerContent = RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().get(schemaId);
-    if (swaggerContent == null) {
-      return Response.failResp(new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase()));
-    }
-
-    if (format == null) {
-      format = SchemaFormat.SWAGGER;
-    }
-
-    byte[] bytes;
-    if (SchemaFormat.HTML.equals(format)) {
-      String html = swaggerToHtml(swaggerContent);
-      bytes = html.getBytes(StandardCharsets.UTF_8);
-    } else {
-      bytes = swaggerContent.getBytes(StandardCharsets.UTF_8);
-    }
-
-    Part part = new InputStreamPart(null, new ByteArrayInputStream(bytes))
-        .setSubmittedFileName(schemaId + format.getSuffix());
-
-    Response response = Response.ok(part);
-    if (!download) {
-      response.getHeaders().addHeader(HttpHeaders.CONTENT_DISPOSITION, "inline");
-    }
-    response.getHeaders().addHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML);
-    return response;
-  }
-
-  // swagger not support cookie parameter
-  // so if swaggerContent contains cookie parameter, will cause problem.
-  private String swaggerToHtml(String swaggerContent) {
-    if (asciidoctor == null) {
-      synchronized (this) {
-        if (asciidoctor == null) {
-          // very slow, need a few seconds
-          LOGGER.info("create AsciiDoctor start.");
-          asciidoctor = Factory.create();
-          asciidoctor.javaExtensionRegistry().docinfoProcessor(AppendStyleProcessor.class);
-          LOGGER.info("create AsciiDoctor end.");
-        }
-      }
-    }
-
-    // swagger to markup
-    Builder markupBuilder = Swagger2MarkupConverter.from(SwaggerUtils.parseSwagger(swaggerContent));
-    // default not support cookie parameter
-    // so must customize config
-    Swagger2MarkupConfig markupConfig = new Swagger2MarkupConfigBuilder()
-        .withParameterOrdering(Ordering
-            .explicit("path", "query", "header", "cookie", "formData", "body")
-            .onResultOf(Parameter::getIn))
-        .build();
-    String markup = markupBuilder.withConfig(markupConfig).build().toString();
-
-    // markup to html
-    OptionsBuilder builder = OptionsBuilder.options();
-    builder.docType("book")
-        .backend("html5")
-        .headerFooter(true)
-        .safe(SafeMode.UNSAFE)
-        .attributes(AttributesBuilder.attributes()
-            .attribute("toclevels", 3)
-            .attribute(Attributes.TOC_2, true)
-            .attribute(Attributes.TOC_POSITION, "left")
-            .attribute(Attributes.LINK_CSS, true)
-            .attribute(Attributes.STYLESHEET_NAME, inspectorConfig.getAsciidoctorCss())
-            .attribute(Attributes.SECTION_NUMBERS, true)
-            .attribute(Attributes.SECT_NUM_LEVELS, 4));
-    return asciidoctor.convert(markup, builder.asMap());
-  }
-
-  @Path("/{path : .+}")
-  @GET
-  @ApiResponse(code = 200, message = "", response = File.class)
-  public Response getStaticResource(@PathParam("path") String path) {
-    return resourceHandler.handle(path);
-  }
-}
-
diff --git a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
deleted file mode 100644
index 8e49a6e..0000000
--- a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
+++ /dev/null
@@ -1,72 +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.servicecomb.samples.porter.file.api;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.apache.servicecomb.samples.porter.common.api.LogService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-import com.netflix.config.DynamicPropertyFactory;
-
-@RestSchema(schemaId = "log")
-@RequestMapping(path = "/v1/log")
-public class LogEndpoint implements LogService {
-  // protect your file in real applications
-  private static final File LOG_DIR =
-      new File(DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.samples.logdir", ".").get());
-
-  private static final String FILE_POST_FIX = ".log";
-
-  @Override
-  @GetMapping(path = "/getLogFileList")
-  public List<String> getLogFileList() {
-    File[] files = LOG_DIR.listFiles(new FileFilter() {
-      @Override
-      public boolean accept(File file) {
-        return isLogFile(file);
-      }
-    });
-
-    List<String> result = new ArrayList<>(files.length);
-    for (int i = 0; i < files.length; i++) {
-      result.add(files[i].getName());
-    }
-    return result;
-  }
-
-  @Override
-  @GetMapping(path = "/getLogFileContent")
-  public File getLogFileContent(@RequestParam(name = "fileName") String fileName) {
-    File file = new File(LOG_DIR, fileName);
-    if (isLogFile(file)) {
-      return file;
-    }
-    return null;
-  }
-
-  private boolean isLogFile(File file) {
-    return file.isFile() && file.canRead() && file.getName().endsWith(FILE_POST_FIX);
-  }
-}
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
deleted file mode 100644
index 9991543..0000000
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
+++ /dev/null
@@ -1,26 +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.servicecomb.samples.porter.common.api;
-
-import java.io.File;
-import java.util.List;
-
-public interface LogService {
-  List<String> getLogFileList();
-  File getLogFileContent(String fileName);
-}
diff --git a/authentication/api/edge-service/endpoint/pom.xml b/authentication/api/edge-service/endpoint/pom.xml
new file mode 100644
index 0000000..66c4a87
--- /dev/null
+++ b/authentication/api/edge-service/endpoint/pom.xml
@@ -0,0 +1,38 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-server-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-edge-api-endpoint</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-edge-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java b/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
rename to authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
index 021b337..68fe5d7 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
+++ b/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.authentication.api.AuthenticationService;
 import org.apache.servicecomb.authentication.api.Token;
diff --git a/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml b/authentication/api/edge-service/pom.xml
similarity index 59%
rename from authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
rename to authentication/api/edge-service/pom.xml
index b5816c3..24d393b 100644
--- a/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
+++ b/authentication/api/edge-service/pom.xml
@@ -16,12 +16,21 @@
   ~ limitations under the License.
   -->
 
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns:context="http://www.springframework.org/schema/context"
-  xsi:schemaLocation="
-		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
-  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init"/>
-</beans>
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-edge-api</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/authentication/api/edge-service/service/pom.xml b/authentication/api/edge-service/service/pom.xml
new file mode 100644
index 0000000..8d86c00
--- /dev/null
+++ b/authentication/api/edge-service/service/pom.xml
@@ -0,0 +1,42 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-edge-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-edge-api-service</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
index d6b879a..2c8d63c 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.authentication.util.Constants;
 import org.apache.servicecomb.core.Handler;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
index bc270b8..46ba288 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.authentication.util.Constants;
 import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
similarity index 99%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
index 8d7472f..d1c6ef4 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/InternalAccessHandler.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/InternalAccessHandler.java
index e05f867..d01620f 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/InternalAccessHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
similarity index 92%
copy from authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
copy to authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
index 662c971..75e40b9 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
+++ b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
+org.apache.servicecomb.authentication.edge.AuthenticationFilter
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
similarity index 92%
rename from authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
rename to authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index 662c971..53481f1 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
+++ b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
+org.apache.servicecomb.authentication.edge.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/config/cse.handler.xml b/authentication/api/edge-service/service/src/main/resources/config/cse.handler.xml
similarity index 85%
rename from authentication/Gateway/src/main/resources/config/cse.handler.xml
rename to authentication/api/edge-service/service/src/main/resources/config/cse.handler.xml
index b39da71..43a5258 100644
--- a/authentication/Gateway/src/main/resources/config/cse.handler.xml
+++ b/authentication/api/edge-service/service/src/main/resources/config/cse.handler.xml
@@ -17,7 +17,7 @@
 
 <config>
   <handler id="auth"
-    class="org.apache.servicecomb.authentication.gateway.AuthHandler" />
+    class="org.apache.servicecomb.authentication.edge.AuthHandler" />
   <handler id="internalAccess"
-    class="org.apache.servicecomb.authentication.gateway.InternalAccessHandler" />
+    class="org.apache.servicecomb.authentication.edge.InternalAccessHandler" />
 </config>
diff --git a/authentication/api/pom.xml b/authentication/api/pom.xml
index cdc3926..92c7f27 100644
--- a/authentication/api/pom.xml
+++ b/authentication/api/pom.xml
@@ -31,7 +31,9 @@
 
   <modules>
     <module>common</module>
-    <module>AuthenticationServer</module>
+    <module>authentication-server</module>
+    <module>resource-server</module>
+    <module>edge-service</module>
   </modules>
 
   <dependencyManagement>
diff --git a/authentication/api/AuthenticationServer/endpoint/pom.xml b/authentication/api/resource-server/endpoint/pom.xml
similarity index 88%
rename from authentication/api/AuthenticationServer/endpoint/pom.xml
rename to authentication/api/resource-server/endpoint/pom.xml
index 5eebece..dc5d549 100644
--- a/authentication/api/AuthenticationServer/endpoint/pom.xml
+++ b/authentication/api/resource-server/endpoint/pom.xml
@@ -21,17 +21,17 @@
 
   <parent>
     <groupId>org.apache.servicecomb.authentication</groupId>
-    <artifactId>authentication-server-api</artifactId>
+    <artifactId>authentication-resource-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>authentication-server-api-endpoint</artifactId>
+  <artifactId>authentication-resource-api-endpoint</artifactId>
   <packaging>jar</packaging>
 
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
-      <artifactId>authentication-server-api-service</artifactId>
+      <artifactId>authentication-resource-api-service</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
   </dependencies>
diff --git a/authentication/api/AuthenticationServer/pom.xml b/authentication/api/resource-server/pom.xml
similarity index 95%
rename from authentication/api/AuthenticationServer/pom.xml
rename to authentication/api/resource-server/pom.xml
index 946a2fb..7c3f228 100644
--- a/authentication/api/AuthenticationServer/pom.xml
+++ b/authentication/api/resource-server/pom.xml
@@ -26,7 +26,7 @@
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>authentication-server-api</artifactId>
+  <artifactId>authentication-resource-api</artifactId>
   <packaging>pom</packaging>
 
   <modules>
diff --git a/authentication/api/resource-server/service/pom.xml b/authentication/api/resource-server/service/pom.xml
new file mode 100644
index 0000000..cf045ce
--- /dev/null
+++ b/authentication/api/resource-server/service/pom.xml
@@ -0,0 +1,42 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-resource-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-resource-api-service</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter b/authentication/api/resource-server/service/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
rename to authentication/api/resource-server/service/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
diff --git a/authentication/ResourceServer/src/main/resources/config/cse.handler.xml b/authentication/api/resource-server/service/src/main/resources/config/cse.handler.xml
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/config/cse.handler.xml
rename to authentication/api/resource-server/service/src/main/resources/config/cse.handler.xml
diff --git a/authentication/AuthenticationServer/pom.xml b/authentication/samples/AuthenticationServer/pom.xml
similarity index 96%
rename from authentication/AuthenticationServer/pom.xml
rename to authentication/samples/AuthenticationServer/pom.xml
index baaac03..488d06d 100644
--- a/authentication/AuthenticationServer/pom.xml
+++ b/authentication/samples/AuthenticationServer/pom.xml
@@ -15,9 +15,13 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.servicecomb.authentication</groupId>
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
   <artifactId>authentication-server</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
   <properties>
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
similarity index 100%
rename from authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
rename to authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
similarity index 100%
rename from authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
rename to authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
similarity index 100%
rename from authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
rename to authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
diff --git a/authentication/ResourceServer/src/main/resources/log4j2.xml b/authentication/samples/AuthenticationServer/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/log4j2.xml
rename to authentication/samples/AuthenticationServer/src/main/resources/log4j2.xml
diff --git a/authentication/AuthenticationServer/src/main/resources/microservice.yaml b/authentication/samples/AuthenticationServer/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/AuthenticationServer/src/main/resources/microservice.yaml
rename to authentication/samples/AuthenticationServer/src/main/resources/microservice.yaml
diff --git a/authentication/Client/pom.xml b/authentication/samples/Client/pom.xml
similarity index 96%
rename from authentication/Client/pom.xml
rename to authentication/samples/Client/pom.xml
index c94ff12..d879756 100644
--- a/authentication/Client/pom.xml
+++ b/authentication/samples/Client/pom.xml
@@ -15,9 +15,14 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.servicecomb.authentication</groupId>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
   <artifactId>client</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
   <properties>
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
diff --git a/authentication/Client/src/main/resources/log4j2.xml b/authentication/samples/Client/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/Client/src/main/resources/log4j2.xml
rename to authentication/samples/Client/src/main/resources/log4j2.xml
diff --git a/authentication/Client/src/main/resources/microservice.yaml b/authentication/samples/Client/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/Client/src/main/resources/microservice.yaml
rename to authentication/samples/Client/src/main/resources/microservice.yaml
diff --git a/authentication/Gateway/pom.xml b/authentication/samples/EdgeService/pom.xml
similarity index 90%
rename from authentication/Gateway/pom.xml
rename to authentication/samples/EdgeService/pom.xml
index 932669e..cb50f95 100644
--- a/authentication/Gateway/pom.xml
+++ b/authentication/samples/EdgeService/pom.xml
@@ -14,9 +14,14 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.servicecomb.authentication</groupId>
-  <artifactId>gateway</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>edge-service</artifactId>
   <packaging>jar</packaging>
 
   <properties>
@@ -34,7 +39,7 @@
       </dependency>
       <dependency>
         <groupId>org.apache.servicecomb.authentication</groupId>
-        <artifactId>authentication-common-api-endpoint</artifactId>
+        <artifactId>authentication-edge-api-endpoint</artifactId>
         <version>0.0.1-SNAPSHOT</version>
       </dependency>
       <dependency>
@@ -48,7 +53,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
-      <artifactId>authentication-common-api-endpoint</artifactId>
+      <artifactId>authentication-edge-api-endpoint</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEdgeMain.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEdgeMain.java
index be15a24..b040342 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java
+++ b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEdgeMain.java
@@ -19,7 +19,7 @@ package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
-public class AuthenticationGatewayMain {
+public class AuthenticationEdgeMain {
     public static void main(String[] args) throws Exception {
         BeanUtils.init();
     }
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/samples/EdgeService/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
similarity index 92%
rename from authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
rename to authentication/samples/EdgeService/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index cb82ded..cf4f35b 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/authentication/samples/EdgeService/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -16,5 +16,4 @@
 #
 
 org.apache.servicecomb.authentication.gateway.ApiDispatcher
-org.apache.servicecomb.authentication.gateway.StaticWebpageDispatcher
-org.apache.servicecomb.authentication.gateway.CustomVertxRestDispatcher
\ No newline at end of file
+org.apache.servicecomb.authentication.gateway.StaticWebpageDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/log4j2.xml b/authentication/samples/EdgeService/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/Gateway/src/main/resources/log4j2.xml
rename to authentication/samples/EdgeService/src/main/resources/log4j2.xml
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/samples/EdgeService/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/Gateway/src/main/resources/microservice.yaml
rename to authentication/samples/EdgeService/src/main/resources/microservice.yaml
diff --git a/authentication/Gateway/src/main/resources/ui/css/style.css b/authentication/samples/EdgeService/src/main/resources/ui/css/style.css
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/css/style.css
rename to authentication/samples/EdgeService/src/main/resources/ui/css/style.css
diff --git a/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js b/authentication/samples/EdgeService/src/main/resources/ui/js/jquery-1.11.1.min.js
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js
rename to authentication/samples/EdgeService/src/main/resources/ui/js/jquery-1.11.1.min.js
diff --git a/authentication/Gateway/src/main/resources/ui/js/login.js b/authentication/samples/EdgeService/src/main/resources/ui/js/login.js
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/js/login.js
rename to authentication/samples/EdgeService/src/main/resources/ui/js/login.js
diff --git a/authentication/Gateway/src/main/resources/ui/js/upload.js b/authentication/samples/EdgeService/src/main/resources/ui/js/upload.js
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/js/upload.js
rename to authentication/samples/EdgeService/src/main/resources/ui/js/upload.js
diff --git a/authentication/Gateway/src/main/resources/ui/login.html b/authentication/samples/EdgeService/src/main/resources/ui/login.html
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/login.html
rename to authentication/samples/EdgeService/src/main/resources/ui/login.html
diff --git a/authentication/Gateway/src/main/resources/ui/upload.html b/authentication/samples/EdgeService/src/main/resources/ui/upload.html
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/upload.html
rename to authentication/samples/EdgeService/src/main/resources/ui/upload.html
diff --git a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java b/authentication/samples/EdgeService/test/org/apache/servicecomb/authentication/test/PatternTest.java
similarity index 100%
rename from authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
rename to authentication/samples/EdgeService/test/org/apache/servicecomb/authentication/test/PatternTest.java
diff --git a/authentication/ResourceServer/pom.xml b/authentication/samples/ResourceServer/pom.xml
similarity index 88%
rename from authentication/ResourceServer/pom.xml
rename to authentication/samples/ResourceServer/pom.xml
index baeb56a..df24f7a 100644
--- a/authentication/ResourceServer/pom.xml
+++ b/authentication/samples/ResourceServer/pom.xml
@@ -15,9 +15,14 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.servicecomb.authentication</groupId>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
   <artifactId>resource-server</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
   <properties>
@@ -28,12 +33,7 @@
     <dependencies>
       <dependency>
         <groupId>org.apache.servicecomb.authentication</groupId>
-        <artifactId>authentication-common-api-endpoint</artifactId>
-        <version>0.0.1-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.servicecomb.authentication</groupId>
-        <artifactId>authentication-server-api-service</artifactId>
+        <artifactId>authentication-resource-api-endpoint</artifactId>
         <version>0.0.1-SNAPSHOT</version>
       </dependency>
       <dependency>
@@ -64,11 +64,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
-      <artifactId>authentication-common-api-endpoint</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb.authentication</groupId>
-      <artifactId>authentication-server-api-service</artifactId>
+      <artifactId>authentication-resource-api-endpoint</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceServerMain.java
similarity index 94%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceServerMain.java
index 5aae72f..1964390 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java
+++ b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceServerMain.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication;
+package org.apache.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
diff --git a/authentication/AuthenticationServer/src/main/resources/log4j2.xml b/authentication/samples/ResourceServer/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/AuthenticationServer/src/main/resources/log4j2.xml
rename to authentication/samples/ResourceServer/src/main/resources/log4j2.xml
diff --git a/authentication/ResourceServer/src/main/resources/microservice.yaml b/authentication/samples/ResourceServer/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/microservice.yaml
rename to authentication/samples/ResourceServer/src/main/resources/microservice.yaml
diff --git a/authentication/api/pom.xml b/authentication/samples/pom.xml
similarity index 94%
copy from authentication/api/pom.xml
copy to authentication/samples/pom.xml
index cdc3926..9bf4cac 100644
--- a/authentication/api/pom.xml
+++ b/authentication/samples/pom.xml
@@ -21,7 +21,7 @@
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.servicecomb.authentication</groupId>
-  <artifactId>authentication-api</artifactId>
+  <artifactId>authentication-samples</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>pom</packaging>
 
@@ -30,8 +30,10 @@
   </properties>
 
   <modules>
-    <module>common</module>
     <module>AuthenticationServer</module>
+    <module>ResourceServer</module>
+    <module>EdgeService</module>
+    <module>Client</module>
   </modules>
 
   <dependencyManagement>


[servicecomb-samples] 28/32: change misspell in Readme.md

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit a868bac1079dc7e4c2bfa9a1975e058a3a53c581
Author: alec.zheng <al...@gmail.com>
AuthorDate: Tue Jul 30 16:53:43 2019 +0800

    change misspell in Readme.md
---
 houserush/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/houserush/README.md b/houserush/README.md
index 9e514ba..2ccff7f 100644
--- a/houserush/README.md
+++ b/houserush/README.md
@@ -9,7 +9,7 @@ Real estate developers use this system to make a deal with their customer online
 1. Setup the requirements
    - setup git, see [git install overview](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)
    - setup JDK 1.8, see [JDK install overview](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html)
-   - setup Maven 3.x, 详情可参考[Maven install guide](https://maven.apache.org/install.html)
+   - setup Maven 3.x, see [Maven install guide](https://maven.apache.org/install.html)
 2. Setup and run the service center
    - setup Docker, see [Docker setup guide](https://www.docker.com/get-started)。
    - input in the terminal <code>$ docker run -d -p 30100:30100 servicecomb/service-center:latest</code>run service-center at port 30100


[servicecomb-samples] 01/32: add a readme file

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 744217edf03b9d590975bf1084388d7389d75c0b
Author: liubao <ba...@huawei.com>
AuthorDate: Wed Mar 6 09:41:17 2019 +0800

    add a readme file
---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3cf272a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# servicecomb samples
+


[servicecomb-samples] 18/32: add readme translation

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 2e8aa8a06c32868f93c7d0122a180a1636948735
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 10 11:06:17 2019 +0800

    add readme translation
---
 authentication/README.md | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/authentication/README.md b/authentication/README.md
index 3cd4217..2274bb4 100644
--- a/authentication/README.md
+++ b/authentication/README.md
@@ -1,3 +1,46 @@
+This project demonstrates authentications and authorizations based on JWT/OAuth2. Projct names follow OAuth2 architecture. 
+
+## Implementations
+
+This project uses spring security API and mainly designed for ServiceComb architecture.
+
+* User Management
+
+  1. UserDetailsService: load users information
+  2. UserDetails: User information
+  3. GrantedAuthority: authorities
+  4. PasswordEncoder: encode or verify user password
+
+## Project
+
+* AuthenticationServer
+
+Authentication server implementation. Provides APIs to login, and query roles, etc. 
+
+
+* Gateway
+
+Check if users are authenticated and dispatch HTTP request.
+
+* Client
+
+Demonstrates how client uses this project. Integration tests are provided. 
+
+
+* Api
+Reusable part. 
+
+* For testing
+
+Run AuthenticationServer、Gateway、Client、ResourceServer and call
+
+```
+http://localhost:9093/v1/test/start
+```
+
+see AuthenticationTestCase for details.
+
+
 本项目提供认证鉴权服务的实现,主要提供了基于角色的权限管理,和基于JWT的微服务授权模式。微服务的命名参考了OAuth2协议里面的命名方式。可以参考[OAuth2.0原理和验证流程分析](https://www.jianshu.com/p/d74ce6ca0c33)对于OAuth2认证过程的介绍,本项目的认证过程非常类似OAuth2的密码模式。
 
 项目的目标是提供一个商业可用的鉴权实现,对于项目代码实现的问题可以提交issue,本项目也接纳PR,共同完善。


[servicecomb-samples] 06/32: spell

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 06b60a5640e67cb49491a87d8003213ba9bd62e0
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Mar 8 16:07:03 2019 +0800

    spell
---
 .../org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
index c80f42a..3057c1f 100644
--- a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
@@ -47,10 +47,10 @@ public class ApiDispatcher extends AbstractEdgeDispatcher {
     String path = "/" + pathParams.get("param1");
 
     EdgeInvocation invoker = new EdgeInvocation() {
-      // 认证鉴权:构造Invocation的时候,设置会话信息。如果是认证请求,则添加Cookie。
+      // Authentication
       protected void createInvocation() {
         super.createInvocation();
-        // 既从cookie里面读取会话ID,也从header里面读取,方便各种独立的测试工具联调
+        // get session id from header and cookie for debug reasons
         String sessionId = context.request().getHeader("session-id");
         if (sessionId != null) {
           this.invocation.addContext("session-id", sessionId);


[servicecomb-samples] 30/32: first commit for house-order microservice

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 0fddf7db2ceb438e6abb45d49b528dad5959b8fb
Author: alec.zheng <al...@gmail.com>
AuthorDate: Fri Aug 2 11:18:53 2019 +0800

    first commit for house-order microservice
---
 houserush/house-order/README.md                    |  95 ++++++++++++++
 .../houserush/sale/HouseOrderApplication.java      |  43 +++++++
 .../practise/houserush/sale/HouseOrderConfig.java  |  26 ++++
 .../houserush/sale/aggregate/HouseOrder.java       |  59 +++++++++
 .../practise/houserush/sale/aggregate/Sale.java    |  71 +++++++++++
 .../practise/houserush/sale/api/HouseOrderApi.java |  39 ++++++
 .../houserush/sale/api/HouseOrderApiRestImpl.java  |  75 +++++++++++
 .../practise/houserush/sale/dao/HouseOrderDao.java |  38 ++++++
 .../practise/houserush/sale/dao/SaleDao.java       |  24 ++++
 .../houserush/sale/rpc/CustomerManageApi.java      |  26 ++++
 .../practise/houserush/sale/rpc/RealestateApi.java |  29 +++++
 .../practise/houserush/sale/rpc/po/Customer.java   |  31 +++++
 .../practise/houserush/sale/rpc/po/House.java      |  27 ++++
 .../houserush/sale/rpc/po/Qualification.java       |  27 ++++
 .../practise/houserush/sale/rpc/po/Realestate.java |  27 ++++
 .../houserush/sale/service/HouseOrderService.java  |  39 ++++++
 .../sale/service/HouseOrderServiceImpl.java        | 142 +++++++++++++++++++++
 .../src/main/resources/microservice.yaml           |  48 +++++++
 18 files changed, 866 insertions(+)

diff --git a/houserush/house-order/README.md b/houserush/house-order/README.md
new file mode 100644
index 0000000..1ed80b0
--- /dev/null
+++ b/houserush/house-order/README.md
@@ -0,0 +1,95 @@
+## 微服务 House-Order
+
+### 主要职责
+该微服务主要有4个职责
+1. 管理员用作开售活动的管理。
+2. 普通用户"**抢购**"房产。
+3. 管理员获取抢购活动的结果。
+4. 普通用户查询自己的抢购结果。
+
+### 主要设计考量
+1. 简单,抢购的核心接口只有1,2个,因为这部分后续需要优化性能,所以越简单,后续优化越容易。
+2. 第一版利用同步调用的方式,尽量不引入冗余数据,减少数据一致性的考量。
+
+### 后续改进的关注点 TODO list:
+1. 需要减少对其他微服务的同步调用,考虑引入异步的事务消息更新机制。提高抢购的性能。
+2. 可能会引入缓存系统,初步定为redis。
+3. 需要跨微服务事务机制,保证数据库的一致性。
+
+### 数据表设计
+
+主要有2张表:
+1. house_orders表,这张表既表示了待抢房源,也表示了抢购订单(抢购结果),差别在与customer_id列是否为null和state列的值。
+在开始抢购之前,customer_id为空,state为new, 记录这次开售活动有哪些房源参与销售。开售中和开售后记录抢购结果。
+即谁抢购到了该房产。
+2. sales表,表示开售活动,主要记录了开售活动的起止时间。sale has_many house_orders。表示这次开售
+活动有哪些房产可售。
+
+sales表:
+
+| column name     | type         |  brief     | description       |
+| --------------  | ------------  | -------   | --------------    |
+| id              | int           | 主键      |  |
+| state           | varchar(20)   | 订单状态   | new->published-> ongoing -> finished |
+| begin_at        | timestamp     | 开售活动开始时间   |  |
+| end_at          | timestamp     | 开售活动结束时间   |  |
+| realestate_id   | int           | 楼盘id    | 一次开售活动只能针对同属一个楼盘的部分房源 |
+| deleted_at      | timestamp     | 开售活动删除时间 | 一次开售活动只有在未发布前可以进行删除或编辑,软删除方案 |
+
+
+house_orders表:
+
+| column name     | type         | 简介     | 更多说明        |
+| --------------  | ------------  | -------  | -------------- |
+| id              | int           | 主键      |  |
+| sale_id         | int           | 外键:开售活动id |  |
+| customer_id     | int           | 客户id  | 记录了谁抢到了该房源,开售前为空 |
+| state           | varchar(20)   | 订单状态 | new 是待抢,confirmed是已抢 |
+| ordered_at      | timestamp     | 抢购时间  | state变为confirmed的时间 |
+
+### 接口设计
+
+
+##### 管理开售活动相关
+```java
+  @PostMapping("sales")
+  Sale createSale(@RequestBody Sale sale);
+
+  @GetMapping("sales/{saleId}")
+  Sale findSale(@PathVariable int saleId);
+  //获取开售活动详情。
+  
+  @PutMapping("sales/{saleId}")
+  Sale Sale updateSale(@PathVariable int saleId, @RequestBody Sale sale);
+  //开售活动发布是通过该接口,一旦发布,不能再修改了,也不能删除。
+
+  @DeleteMapping("sales/{saleId}")
+  void removeSale(@PathVariable int saleId);
+  
+  @GetMapping("sales")
+  List<Sale> indexSales();
+  //对客户列出客户有抢购资格的还未开始的开售活动,已开始时间排序;对管理员,列出所有的开售活动。
+
+  @PostMapping("sales/{saleId}/house_orders")
+  createHouseOrders(@PathVariable int saleId, @RequestBody List<Integer> houseIds);
+  //为开售活动创建房源,创建时需要检查这些房源是否已被其他开售活动锁定或售出。
+  //需要先对这些房源加锁后再添加到当前开售活动中,要注意事务的应用。
+  
+```
+
+##### 执行抢购相关
+```java
+  @PutMapping("house_orders/{houseOrderId}")
+  HouseOrder placeHouseOrder(@RequestHeader int customerId, @PathVariable int houseOrderId)
+  //修改house_orders的customer_id列,抢购前需要检查该房源是否已被占用,
+  // select for update加锁,注意事务应用。
+  //
+```
+
+### 依赖其他微服务。
+1. find 和 index Sale的时候,需要调用realestate微服务的相关接口获取
+Sale关联楼盘的详细信息。
+2. createHouseOrders接口需要依赖realestate微服务查询房源状态和加锁,见接口说明。
+3. 依赖CustomerManage微服务,查询当前抢购的客户是否还有抢购的资格。
+
+
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderApplication.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderApplication.java
new file mode 100644
index 0000000..63a6875
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderApplication.java
@@ -0,0 +1,43 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale;
+
+import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
+import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+@SpringBootApplication
+@EnableServiceComb
+@EnableJpaAuditing
+public class HouseOrderApplication {
+  public static void main(String[] args) {
+    configBeforeBoot();
+    SpringApplication.run(HouseOrderApplication.class, args);
+  }
+
+  private static void configBeforeBoot() {
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+    RestObjectMapperFactory.getRestObjectMapper().setDateFormat(simpleDateFormat);
+  }
+}
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderConfig.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderConfig.java
new file mode 100644
index 0000000..f681976
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/HouseOrderConfig.java
@@ -0,0 +1,26 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+
+@Configuration
+@EnableJpaRepositories(basePackages = "org.apache.servicecomb.samples.practise.houserush")
+public class HouseOrderConfig {
+}
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/HouseOrder.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/HouseOrder.java
new file mode 100644
index 0000000..3b8b863
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/HouseOrder.java
@@ -0,0 +1,59 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.aggregate;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Data;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@Data
+@Entity
+@Table(name = "house_orders")
+@EntityListeners(AuditingEntityListener.class)
+public class HouseOrder {
+  @Id
+  @GeneratedValue(strategy = GenerationType.AUTO)
+  private Integer id;
+
+  @JsonIgnore
+  @ManyToOne
+  @JoinColumn(name = "sale_id")
+  private Sale sale;
+
+  private Integer customerId;
+
+  private String state = "new";
+
+  private Integer houseId;
+
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date orderedAt;
+
+  @CreatedDate
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date CreatedAt;
+
+  @LastModifiedDate
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date UpdatedAt;
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/Sale.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/Sale.java
new file mode 100644
index 0000000..a0ea966
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/aggregate/Sale.java
@@ -0,0 +1,71 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.aggregate;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Data;
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Data
+@Entity
+@Table(name = "sales")
+@SQLDelete(sql = "update sales set deleted_at = now() where id = ?")
+@Where(clause = "deleted_at is null")
+@EntityListeners(AuditingEntityListener.class)
+public class Sale {
+  @Id
+  @GeneratedValue(strategy = GenerationType.AUTO)
+  private Integer id;
+
+  private String state = "new";
+
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date beginAt;
+
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date endAt;
+
+  @JsonIgnore
+  @OneToMany(mappedBy = "sale")
+  private List<HouseOrder> houseOrders = new ArrayList<>();
+
+  private Integer realestateId;
+
+  @Transient
+  private String realestateName;
+
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date deletedAt;
+
+  @CreatedDate
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date createdAt;
+
+  @LastModifiedDate
+  @Temporal(TemporalType.TIMESTAMP)
+  private Date updatedAt;
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApi.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApi.java
new file mode 100644
index 0000000..13207d9
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApi.java
@@ -0,0 +1,39 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.api;
+
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.HouseOrder;
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.Sale;
+
+import java.util.List;
+
+public interface HouseOrderApi {
+  List<HouseOrder> createHouseOrders(int saleId, List<Integer> houseIds);
+
+  HouseOrder placeHouseOrder(int customerId, int houseOrderId);
+
+  Sale createSale(Sale sale);
+
+  Sale findSale(int saleId);
+
+  Sale updateSale(int saleId, Sale sale);
+
+  void removeSale(int saleId);
+
+  List<Sale> indexSales();
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApiRestImpl.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApiRestImpl.java
new file mode 100644
index 0000000..2a74fc5
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/api/HouseOrderApiRestImpl.java
@@ -0,0 +1,75 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.api;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.HouseOrder;
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.Sale;
+import org.apache.servicecomb.samples.practise.houserush.sale.service.HouseOrderService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestSchema(schemaId = "houseOrderApiRest")
+@RequestMapping("/")
+public class HouseOrderApiRestImpl implements HouseOrderApi {
+  @Autowired
+  HouseOrderService houseOrderService;
+
+  @PostMapping("sales/{saleId}/house_orders")
+  public List<HouseOrder> createHouseOrders(@PathVariable int saleId, @RequestBody List<Integer> houseIds) {
+    return houseOrderService.createHouseOrders(saleId, houseIds);
+  }
+
+  @PutMapping("house_orders/{houseOrderId}")
+  public HouseOrder placeHouseOrder(@RequestHeader int customerId, @PathVariable int houseOrderId) {
+    return houseOrderService.placeHouseOrder(customerId, houseOrderId);
+  }
+
+  @Override
+  @PostMapping("sales")
+  public Sale createSale(@RequestBody Sale sale) {
+    return houseOrderService.createSale(sale);
+  }
+
+  @Override
+  @GetMapping("sales/{saleId}")
+  public Sale findSale(@PathVariable int saleId) {
+    return houseOrderService.findSale(saleId);
+  }
+
+  @Override
+  @PutMapping("sales/{saleId}")
+  public Sale updateSale(@PathVariable int saleId, @RequestBody Sale sale) {
+    sale.setId(saleId);
+    return houseOrderService.updateSale(sale);
+  }
+
+  @Override
+  @DeleteMapping("sales/{saleId}")
+  public void removeSale(@PathVariable int saleId) {
+    houseOrderService.removeSale(saleId);
+  }
+
+  @Override
+  @GetMapping("sales")
+  public List<Sale> indexSales() {
+    return houseOrderService.indexSales();
+  }
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/HouseOrderDao.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/HouseOrderDao.java
new file mode 100644
index 0000000..3e4bc2f
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/HouseOrderDao.java
@@ -0,0 +1,38 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.dao;
+
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.HouseOrder;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+public interface HouseOrderDao extends JpaRepository<HouseOrder, Integer> {
+  @Lock(LockModeType.PESSIMISTIC_WRITE)
+  @Query("SELECT ho FROM HouseOrder ho WHERE ho.sale.id = ?1 and ho.houseId in (?2)")
+  List<HouseOrder> findAllBySaleIdAndHouseIdInForUpdate(int saleId, List<Integer> ids);
+
+  @Lock(LockModeType.PESSIMISTIC_WRITE)
+  @Query("SELECT ho FROM HouseOrder ho WHERE ho.id = ?1")
+  HouseOrder findOneForUpdate(int id);
+
+  int countByCustomerIdAndSaleId(int customerId, int saleId);
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/SaleDao.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/SaleDao.java
new file mode 100644
index 0000000..99795ec
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/dao/SaleDao.java
@@ -0,0 +1,24 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.dao;
+
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.Sale;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface SaleDao extends JpaRepository<Sale, Integer> {
+}
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/CustomerManageApi.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/CustomerManageApi.java
new file mode 100644
index 0000000..0b30523
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/CustomerManageApi.java
@@ -0,0 +1,26 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.rpc;
+
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.po.Customer;
+
+public interface CustomerManageApi {
+  Customer findCustomer(int customerId);
+
+  int getQualificationsCount(int customerId, int saleId);
+}
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/RealestateApi.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/RealestateApi.java
new file mode 100644
index 0000000..0ca5393
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/RealestateApi.java
@@ -0,0 +1,29 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.rpc;
+
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.po.House;
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.po.Realestate;
+
+import java.util.List;
+
+public interface RealestateApi {
+  Realestate findRealestate(int id);
+
+  List<House> lockHousesForSale(List<Integer> ids);
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Customer.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Customer.java
new file mode 100644
index 0000000..d458315
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Customer.java
@@ -0,0 +1,31 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.rpc.po;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class Customer {
+  private int id;
+
+  private String phone;
+
+  private List<Qualification> qualifications;
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/House.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/House.java
new file mode 100644
index 0000000..c122ef4
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/House.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.rpc.po;
+
+import lombok.Data;
+
+@Data
+public class House {
+  private Integer id;
+
+  private String name;
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Qualification.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Qualification.java
new file mode 100644
index 0000000..027ca72
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Qualification.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.rpc.po;
+
+import lombok.Data;
+
+@Data
+public class Qualification {
+  private int id;
+
+  private Integer saleId;
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Realestate.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Realestate.java
new file mode 100644
index 0000000..d7d3324
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/rpc/po/Realestate.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.rpc.po;
+
+import lombok.Data;
+
+@Data
+public class Realestate {
+  private int id;
+
+  private String name;
+}
\ No newline at end of file
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderService.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderService.java
new file mode 100644
index 0000000..3333de3
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderService.java
@@ -0,0 +1,39 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.service;
+
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.HouseOrder;
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.Sale;
+
+import java.util.List;
+
+public interface HouseOrderService {
+  List<HouseOrder> createHouseOrders(int saleId, List<Integer> houseIds);
+
+  HouseOrder placeHouseOrder(int customerId, int houseOrderId);
+
+  Sale createSale(Sale sale);
+
+  Sale findSale(int saleId);
+
+  Sale updateSale(Sale sale);
+
+  void removeSale(int saleId);
+
+  List<Sale> indexSales();
+}
diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java
new file mode 100644
index 0000000..eeed043
--- /dev/null
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java
@@ -0,0 +1,142 @@
+/*
+ * 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.servicecomb.samples.practise.houserush.sale.service;
+
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.HouseOrder;
+import org.apache.servicecomb.samples.practise.houserush.sale.aggregate.Sale;
+import org.apache.servicecomb.samples.practise.houserush.sale.dao.HouseOrderDao;
+import org.apache.servicecomb.samples.practise.houserush.sale.dao.SaleDao;
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.CustomerManageApi;
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.RealestateApi;
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.po.Customer;
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.po.House;
+import org.apache.servicecomb.samples.practise.houserush.sale.rpc.po.Realestate;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class HouseOrderServiceImpl implements HouseOrderService {
+  @Autowired
+  HouseOrderDao houseOrderDao;
+
+  @Autowired
+  SaleDao saleDao;
+
+  @RpcReference(microserviceName = "realestate", schemaId = "realestateApiRest")
+  private RealestateApi realestateApi;
+
+  @RpcReference(microserviceName = "customer-manage", schemaId = "customerManageApiRest")
+  private CustomerManageApi customerManageApi;
+
+  @Override
+  @Transactional
+  public List<HouseOrder> createHouseOrders(int saleId, List<Integer> houseIds) {
+    Sale sale = saleDao.findOne(saleId);
+    if (null == sale) {
+      throw new DataRetrievalFailureException("cannot create house for the non-existed sale.");
+    }
+
+    List<HouseOrder> houseOrders = houseOrderDao.findAllBySaleIdAndHouseIdInForUpdate(saleId, houseIds);
+    if (!houseOrders.isEmpty()) {
+      throw new InvocationException(400, "", "some house is already in this sale.");
+    }
+
+    List<House> houses = realestateApi.lockHousesForSale(houseIds);
+    List<HouseOrder> resHouseOrders = new ArrayList<>();
+    houses.forEach(house -> {
+      HouseOrder houseOrder = new HouseOrder();
+      houseOrder.setHouseId(house.getId());
+      houseOrder.setSale(sale);
+      houseOrderDao.save(houseOrder);
+      resHouseOrders.add(houseOrder);
+
+    });
+    return resHouseOrders;
+  }
+
+  @Override
+  @Transactional
+  public HouseOrder placeHouseOrder(int customerId, int houseOrderId) {
+    HouseOrder houseOrder = houseOrderDao.findOneForUpdate(houseOrderId);
+    Sale sale = houseOrder.getSale();
+
+    if (null != houseOrder) {
+      if (null == houseOrder.getCustomerId()) {
+        Customer customer = customerManageApi.findCustomer(customerId);
+        int qualificationsCount = customerManageApi.getQualificationsCount(customerId, sale.getId());
+
+        int ordersCount = houseOrderDao.countByCustomerIdAndSaleId(customerId, sale.getId());
+
+        if (qualificationsCount <= ordersCount) {
+          throw new InvocationException(400, "", "do not have the enough qualification to buy houses in this sale, " +
+              "the qualifications count is " + qualificationsCount + " , the order count is " + ordersCount);
+        }
+
+        houseOrder.setCustomerId(customerId);
+        houseOrder.setState("confirmed");
+        houseOrderDao.save(houseOrder);
+        return houseOrder;
+      } else {
+        throw new InvocationException(400, "", "该住宅已被其他人选购,请选择其他房产。");
+      }
+    } else {
+      throw new InvocationException(400, "", "选择的房产不在此次抢购活动中");
+    }
+  }
+
+  @Override
+  public Sale createSale(Sale sale) {
+    return saleDao.save(sale);
+  }
+
+  @Override
+  public Sale findSale(int saleId) {
+    Sale sale = saleDao.findOne(saleId);
+    Realestate realestate = realestateApi.findRealestate(sale.getRealestateId());
+    sale.setRealestateName(realestate.getName());
+    return sale;
+  }
+
+  @Override
+  @Transactional
+  public Sale updateSale(Sale sale) {
+    int id = sale.getId();
+    if (saleDao.exists(id)) {
+      return saleDao.save(sale);
+    } else {
+      throw new DataRetrievalFailureException("cannot update the none-existed sale");
+    }
+  }
+
+  @Override
+  public void removeSale(int saleId) {
+    saleDao.delete(saleId);
+  }
+
+  @Override
+  public List<Sale> indexSales() {
+    return saleDao.findAll();
+  }
+}
diff --git a/houserush/house-order/src/main/resources/microservice.yaml b/houserush/house-order/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..5aa426a
--- /dev/null
+++ b/houserush/house-order/src/main/resources/microservice.yaml
@@ -0,0 +1,48 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# all interconnected microservices must belong to an application wth the same ID
+APPLICATION_ID: houserush
+service_description:
+  # name of the declaring microservice
+  name: house-order
+  version: 0.0.6
+servicecomb:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+      instance:
+        watch: true
+        healthCheck:
+          interval: 5
+
+  rest:
+    address: 0.0.0.0:6788
+  handler:
+    chain:
+      Provider:
+        default: bizkeeper-provider
+spring:
+  datasource:
+    url: jdbc:mysql://127.0.0.1:3306/house_order?characterEncoding=utf8&useSSL=false
+    username: root
+    password: root
+  jpa:
+    properties:
+      hibernate:
+        enable_lazy_load_no_trans: true
\ No newline at end of file


[servicecomb-samples] 11/32: fix review comments and add internal access demo

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit f46f134e4e2d353fc2405eb7a34e757fd97c66e1
Author: liubao <ba...@huawei.com>
AuthorDate: Tue Apr 16 14:12:37 2019 +0800

    fix review comments and add internal access demo
---
 porter_lightweight/README.md                       |  4 +--
 .../porter/file/api/InternalAccessEndpoint.java    | 38 ++++++++++++++++++++++
 .../porter/file/api/InternalAccessService.java     |  5 +++
 .../file/service/InternalAccessServiceImpl.java    | 28 ++++++++++++++++
 .../porter/gateway/InternalAccessHandler.java      | 37 +++++++++++++++++++++
 .../src/main/resources/config/cse.handler.xml      |  6 ++--
 .../src/main/resources/microservice.yaml           |  2 +-
 7 files changed, 115 insertions(+), 5 deletions(-)

diff --git a/porter_lightweight/README.md b/porter_lightweight/README.md
index 93d7bd5..297dbb6 100644
--- a/porter_lightweight/README.md
+++ b/porter_lightweight/README.md
@@ -80,7 +80,7 @@ java $JAVA_OPT -Dgateway.webroot=webapp -jar porter-gateway-service-0.0.1-SNAPSH
 3. 删除文件:输入上一步的文件ID,点击删除。 如果是admin用户,上传成功;如果是guest用户,上传失败。
 
 # 接口使用说明
-ServiceComb推荐先定义接口,再定义实现的开发模式。将接口定义为一个独立项目,可以由设计者统一管控,对于接口的修改,需要设计者进行审核。先定义接口还可以让开发者培养良好的开发习惯,避免将对外接口采用内部实现数据结构(比如JsonObject)、运行平台有关的数据结构(比如HttpServletResponse)来定义,使得以后将项目改在为其他技术框架变得复杂。采用这种方式组织的项目,用户很容易在不同的开发框架上进行迁移,比如gRPC、Spring Cloud等。这里的接口定义代码,对于这些运行框架都是通用的,并且具备跨平台特性。
+ServiceComb推荐先定义接口,再定义实现的开发模式。将接口定义为一个独立项目,可以由设计者统一管控,对于接口的修改,需要设计者进行审核。先定义接口还可以让开发者培养良好的开发习惯,避免将对外接口采用内部实现数据结构(比如JsonObject)、运行平台有关的数据结构(比如HttpServletResponse、HttpServletRequest)来定义,使得以后将项目改造为其他技术框架变得复杂。采用这种方式组织的项目,用户很容易在不同的开发框架上进行迁移,比如gRPC、Spring Cloud等。这里的接口定义代码,对于这些运行框架都是通用的,并且具备跨平台特性。
 
 ## 对于接口实现者(provider)
   * 依赖api对应的jar包
@@ -112,7 +112,7 @@ public class UserServiceImpl implements UserService
   </dependencies>
 ```
 
-  * 采用RCP方式调用
+  * 采用RPC方式调用
 ```
   @RpcReference(microserviceName = "user-service", schemaId = "user")
   private static UserService sserService
diff --git a/porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessEndpoint.java b/porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessEndpoint.java
new file mode 100644
index 0000000..1a7d94d
--- /dev/null
+++ b/porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessEndpoint.java
@@ -0,0 +1,38 @@
+/*
+ * 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.servicecomb.samples.porter.file.api;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import io.swagger.annotations.Api;
+
+@RestSchema(schemaId = "InternalAccessEndpoint")
+@RequestMapping(path = "/")
+@Api(tags = {"INTERNAL"})
+public class InternalAccessEndpoint {
+  @Autowired
+  private InternalAccessService internalAccessService;
+  
+  @GetMapping(path = "localAccess")
+  public String localAccess(String name) {
+    return internalAccessService.localAccess(name);
+  }
+}
diff --git a/porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessService.java b/porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessService.java
new file mode 100644
index 0000000..7e627fb
--- /dev/null
+++ b/porter_lightweight/api/file-service/service/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessService.java
@@ -0,0 +1,5 @@
+package org.apache.servicecomb.samples.porter.file.api;
+
+public interface InternalAccessService {
+  public String localAccess(String name);
+}
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/InternalAccessServiceImpl.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/InternalAccessServiceImpl.java
new file mode 100644
index 0000000..d723945
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/InternalAccessServiceImpl.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.servicecomb.samples.porter.file.service;
+
+import org.apache.servicecomb.samples.porter.file.api.InternalAccessService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class InternalAccessServiceImpl implements InternalAccessService {
+  public String localAccess(String name) {
+    return "Hello, " + name;
+  }
+}
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
new file mode 100644
index 0000000..0b181d8
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
@@ -0,0 +1,37 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+
+public class InternalAccessHandler implements Handler {
+
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncReponse) throws Exception {
+    if (invocation.getOperationMeta().getSwaggerOperation().getTags() != null
+        && invocation.getOperationMeta().getSwaggerOperation().getTags().contains("INTERNAL")) {
+      asyncReponse.consumerFail(new InvocationException(403, "", "not allowed"));
+      return;
+    }
+    invocation.next(asyncReponse);
+  }
+
+}
diff --git a/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml b/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml
index 00295f8..e9dd306 100644
--- a/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml
+++ b/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml
@@ -16,6 +16,8 @@
   -->
 
 <config>
-	<handler id="auth"
-			 class="org.apache.servicecomb.samples.porter.gateway.AuthHandler" />
+  <handler id="auth"
+    class="org.apache.servicecomb.samples.porter.gateway.AuthHandler" />
+  <handler id="internalAccess"
+    class="org.apache.servicecomb.samples.porter.gateway.InternalAccessHandler" />
 </config>
diff --git a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
index 3bb50fa..2462c7f 100644
--- a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
@@ -37,7 +37,7 @@ servicecomb:
   handler:
     chain:
       Consumer:
-        default: auth,qps-flowcontrol-consumer,loadbalance
+        default: internalAccess,auth,qps-flowcontrol-consumer,loadbalance
 
   uploads:
     directory: tmp_for_upload_gateway


[servicecomb-samples] 22/32: provide default authentication service implementation

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit ab23af153a31eca1daa4406797caa80d89250c26
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 17 11:35:41 2019 +0800

    provide default authentication service implementation
---
 .../api/authentication-server/endpoint/pom.xml     |  5 ++
 .../authentication/api/AuthenticationEndpoint.java | 46 +++++++++++--
 .../service/AuthenticationServiceImpl.java         | 75 ----------------------
 3 files changed, 47 insertions(+), 79 deletions(-)

diff --git a/authentication/api/authentication-server/endpoint/pom.xml b/authentication/api/authentication-server/endpoint/pom.xml
index 5eebece..a653462 100644
--- a/authentication/api/authentication-server/endpoint/pom.xml
+++ b/authentication/api/authentication-server/endpoint/pom.xml
@@ -34,5 +34,10 @@
       <artifactId>authentication-server-api-service</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
   </dependencies>
 </project>
diff --git a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
index 5177aeb..c777bc5 100644
--- a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
@@ -17,26 +17,64 @@
 
 package org.apache.servicecomb.authentication.api;
 
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+import org.springframework.security.jwt.crypto.sign.Signer;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
 @RestSchema(schemaId = "AuthenticationEndpoint")
 @RequestMapping(path = "/v1/auth")
-public class AuthenticationEndpoint {
+public class AuthenticationEndpoint implements AuthenticationService {
   @Autowired
-  private AuthenticationService authenticationService;
+  @Qualifier("authUserDetailsService")
+  private UserDetailsService userDetailsService;
 
+  @Autowired
+  @Qualifier("authPasswordEncoder")
+  private PasswordEncoder passwordEncoder;
+
+  @Autowired
+  @Qualifier("authSigner")
+  private Signer signer;
+
+  @Override
   @PostMapping(path = "login")
   public Token login(@RequestParam(name = "userName") String userName,
       @RequestParam(name = "password") String password) {
-    return authenticationService.login(userName, password);
+    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
+    if (passwordEncoder.matches(password, userDetails.getPassword())) {
+      JWTClaims claims = new JWTClaims();
+      if (userDetails.getAuthorities() != null) {
+        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
+      }
+      String content = JsonParser.unparse(claims);
+      Jwt accessToken = JwtHelper.encode(content, signer);
+
+      Token token = new Token();
+      token.setScope(claims.getScope());
+      token.setExpires_in(10 * 60);
+      token.setToken_type("bearer");
+      token.setAccess_token(accessToken.getEncoded());
+      return token;
+    } else {
+      return null;
+    }
   }
 
+  @Override
   @PostMapping(path = "refresh")
   public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
-    return authenticationService.refresh(refreshToken);
+    return null;
   }
+
 }
diff --git a/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
deleted file mode 100644
index cfbe22b..0000000
--- a/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
+++ /dev/null
@@ -1,75 +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.servicecomb.authentication.service;
-
-import org.apache.servicecomb.authentication.api.AuthenticationService;
-import org.apache.servicecomb.authentication.api.Token;
-import org.apache.servicecomb.authentication.jwt.JWTClaims;
-import org.apache.servicecomb.authentication.jwt.JsonParser;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.jwt.Jwt;
-import org.springframework.security.jwt.JwtHelper;
-import org.springframework.security.jwt.crypto.sign.Signer;
-import org.springframework.stereotype.Service;
-
-@Service
-public class AuthenticationServiceImpl implements AuthenticationService {
-  @Autowired
-  @Qualifier("authUserDetailsService")
-  private UserDetailsService userDetailsService;
-
-  @Autowired
-  @Qualifier("authPasswordEncoder")
-  private PasswordEncoder passwordEncoder;
-
-  @Autowired
-  @Qualifier("authSigner")
-  private Signer signer;
-
-  @Override
-  public Token login(String userName, String password) {
-    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
-    if (passwordEncoder.matches(password, userDetails.getPassword())) {
-      JWTClaims claims = new JWTClaims();
-      if (userDetails.getAuthorities() != null) {
-        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
-      }
-      String content = JsonParser.unparse(claims);
-      Jwt accessToken = JwtHelper.encode(content, signer);
-
-      Token token = new Token();
-      token.setScope(claims.getScope());
-      token.setExpires_in(10 * 60);
-      token.setToken_type("bearer");
-      token.setAccess_token(accessToken.getEncoded());
-      return token;
-    } else {
-      return null;
-    }
-  }
-
-  @Override
-  public Token refresh(String refreshToken) {
-    return null;
-  }
-
-}


[servicecomb-samples] 29/32: format little change for README.md

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 872cc38fb35a6e25a1390040b3cb85e27c942239
Author: alec.zheng <al...@gmail.com>
AuthorDate: Fri Aug 2 10:47:57 2019 +0800

    format little change for README.md
---
 houserush/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/houserush/README.md b/houserush/README.md
index 2ccff7f..a167254 100644
--- a/houserush/README.md
+++ b/houserush/README.md
@@ -17,4 +17,4 @@ Real estate developers use this system to make a deal with their customer online
 
 4. check & change the src/main/resources/microservice.yaml and src/main/resources/application.yaml configuration file.
 
-5. run each microservice process <code>by mvn spring-boot:run. </code>
\ No newline at end of file
+5. run each microservice process by <code>mvn spring-boot:run. </code>
\ No newline at end of file


[servicecomb-samples] 02/32: add porter demo

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 4bfdb295453193dc5bc82bb11365614a1a10b8df
Author: liubao <ba...@huawei.com>
AuthorDate: Wed Mar 6 22:47:42 2019 +0800

    add porter demo
---
 .gitignore                                         |  85 +++++++++++
 README.md                                          |   2 +
 porter_lightweight/README.md                       |  82 ++++++++++
 porter_lightweight/common/pom.xml                  |  31 ++++
 .../java/samples/porter/file/api/FileEndpoint.java |  51 +++++++
 .../java/samples/porter/file/api/FileService.java  |  26 ++++
 .../java/samples/porter/user/api/SessionInfo.java  |  50 +++++++
 .../java/samples/porter/user/api/UserEndpoint.java |  49 ++++++
 .../java/samples/porter/user/api/UserService.java  |  27 ++++
 .../common/src/main/resources/microservice.yaml    |  30 ++++
 porter_lightweight/file-service/pom.xml            |  49 ++++++
 .../servicecomb/samples/porter/file/FileMain.java  |  28 ++++
 .../porter/file/service/FileServiceImpl.java       |  53 +++++++
 .../porter/file/service/FileStoreService.java      |  31 ++++
 .../porter/file/service/LocalFileStoreService.java |  64 ++++++++
 .../samples/porter/file/service/SessionInfo.java   |  81 ++++++++++
 .../main/resources/META-INF/spring/file.bean.xml   |  29 ++++
 .../src/main/resources/microservice.yaml           |  30 ++++
 porter_lightweight/gateway-service/pom.xml         |  58 ++++++++
 .../samples/porter/gateway/ApiDispatcher.java      |  68 +++++++++
 .../samples/porter/gateway/AuthHandler.java        | 105 +++++++++++++
 .../samples/porter/gateway/EdgeSSLCustom.java      |  38 +++++
 .../samples/porter/gateway/GatewayMain.java        |  28 ++++
 .../porter/gateway/StaticWebpageDispatcher.java    |  52 +++++++
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  19 +++
 .../src/main/resources/config/cse.handler.xml      |  21 +++
 .../src/main/resources/microservice.yaml           |  45 ++++++
 .../src/main/resources/ui/css/style.css            |  49 ++++++
 .../src/main/resources/ui/js/jquery-1.11.1.min.js  |   4 +
 .../src/main/resources/ui/js/login.js              |  52 +++++++
 .../src/main/resources/ui/js/upload.js             |  63 ++++++++
 .../src/main/resources/ui/login.html               |  45 ++++++
 .../src/main/resources/ui/upload.html              |  61 ++++++++
 porter_lightweight/pom.xml                         | 165 +++++++++++++++++++++
 porter_lightweight/user-service/.gitignore         |   1 +
 porter_lightweight/user-service/pom.xml            |  85 +++++++++++
 .../servicecomb/samples/porter/user/UserMain.java  |  28 ++++
 .../samples/porter/user/dao/SessionInfoModel.java  |  90 +++++++++++
 .../samples/porter/user/dao/SessionMapper.java     |  28 ++++
 .../samples/porter/user/dao/UserInfo.java          |  61 ++++++++
 .../samples/porter/user/dao/UserMapper.java        |  24 +++
 .../porter/user/service/UserServiceImpl.java       | 114 ++++++++++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  57 +++++++
 .../src/main/resources/config/SessionMapper.xml    |  57 +++++++
 .../src/main/resources/config/UserMapper.xml       |  46 ++++++
 .../src/main/resources/config/create_db_user.sql   |  46 ++++++
 .../src/main/resources/config/mybatis-config.xml   |  27 ++++
 .../src/main/resources/microservice.yaml           |  27 ++++
 48 files changed, 2362 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..67e5a7d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,85 @@
+# Output Directory
+target/
+
+# C pre-compile
+*.gch
+*.pch
+
+# C compile
+*.a
+*.o
+*.ko
+*.la
+*.lo
+*.obj
+*.elf
+*.so
+*.so.*
+*.dylib
+*.exe
+*.lib
+*.dll
+*.out
+*.app
+*.hex
+
+# Debug files
+*.dSYM/
+
+# Java
+*.class
+
+# Java Package Files
+*.jar
+*.war
+*.ear
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+# Zip Files
+*.rar
+*.zip
+*.7z
+*.tar
+*.gz
+
+# Ant
+build/
+
+# Compiled Python
+__pycache__/
+*.py[cod]
+*py.class
+
+# Eclipse
+.settings/
+.classpath
+.project
+
+# IntelliJ, based on http://devnet.jetbrains.net/docs/DOC-1186
+.idea/
+*.iml
+*.ipr
+*.iws
+
+# logs and trace
+*.log
+*.trace
+*.dat
+
+# vi swap
+*.swp
+
+# Backup Files
+*.bak
+*.old
+
+# SVN metadata
+.svn/
+
+# Mac
+.DS_Store
+
+# gradle
+.gradle
diff --git a/README.md b/README.md
index 3cf272a..ac5abc5 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,4 @@
 # servicecomb samples
 
+## porter_lightweight
+A sample shows an application with basic login, download file, delete file functions. 
diff --git a/porter_lightweight/README.md b/porter_lightweight/README.md
new file mode 100644
index 0000000..ef8c671
--- /dev/null
+++ b/porter_lightweight/README.md
@@ -0,0 +1,82 @@
+This project shows how to using java-chassis and service-center to create a simple microservice application. It shows basic authentication and authorization, uploading files and delte files operations.
+
+## build and run
+
+* compile
+
+```
+mvn clean install
+```
+
+* run
+  * create a database using mysql with user name and password(e.g. root/root)
+  * execute create_db_user.sql
+
+* run user-service:
+
+```
+java $JAVA_OPT -Ddb.url="jdbc:mysql://localhost/porter_user_db?useSSL=false" -Ddb.username=root -Ddb.password=root -jar porter-user-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
+```
+
+* run file-service:
+
+```
+java $JAVA_OPT -jar porter-file-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
+```
+
+* run gateway-serivce:
+
+gateway-service contains static webpages in resources/ui. First copy to web root folder,e.g webapp, which is relative to working directory. 
+
+```
+java $JAVA_OPT -Dgateway.webroot=webapp -jar porter-gateway-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
+```
+
+## Try it
+
+1. Using browser: http://localhost:9090/ui/login.html with user admin or guest to login, password is test.
+2. Choose a file to upload. Uploaded file is stored in file-service workding directory. And name is random number generated. 
+3. Delete file. Input the random number generated in step 2. 
+
+
+这个项目帮助开发者学习如何使用ServiceComb开发完整的微服务。 这个项目实现的功能非常简单,用户登录后,上传一个文件和删除一个文件,验证了没有权限的用户无法删除文件。
+
+# 编译和运行
+
+* 编译
+
+```
+mvn clean install
+```
+
+* 运行
+  * 安装mysql数据库,设置用户名密码(假设为root/root)
+  * 执行脚本create_db_user.sql
+
+
+* 启动user-service:
+
+```
+java $JAVA_OPT -Ddb.url="jdbc:mysql://localhost/porter_user_db?useSSL=false" -Ddb.username=root -Ddb.password=root -jar porter-user-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
+```
+
+* 启动file-service:
+
+```
+java $JAVA_OPT -jar porter-file-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
+```
+
+* 启动gateway-serivce:
+
+gateway-service包含了静态页面文件,在resources/ui目录。首先需要将页面文件拷贝到WEB主目录(相对路径,当前运行目录),比如: webapp,然后将ui目录整体拷贝到webapp/ui目录。启动:
+```
+java $JAVA_OPT -Dgateway.webroot=webapp -jar porter-gateway-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
+```
+
+# 使用
+
+1. 输入: http://localhost:9090/ui/login.html 使用admin或者guest登陆,密码为test。
+2. 选择一个文件上传,上传成功,上传成功后的文件会保存在file-service的当前目录, 文件名称是一个随机的数字,这个数字就是文件ID。
+3. 删除文件:输入上一步的文件ID,点击删除。 如果是admin用户,上传成功;如果是guest用户,上传失败。
+
+
diff --git a/porter_lightweight/common/pom.xml b/porter_lightweight/common/pom.xml
new file mode 100644
index 0000000..772ec4e
--- /dev/null
+++ b/porter_lightweight/common/pom.xml
@@ -0,0 +1,31 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.samples.porter</groupId>
+    <artifactId>porter-application</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>porter-common</artifactId>
+  <packaging>jar</packaging>
+
+</project>
diff --git a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java b/porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java
new file mode 100644
index 0000000..e7c1f0c
--- /dev/null
+++ b/porter_lightweight/common/src/main/java/samples/porter/file/api/FileEndpoint.java
@@ -0,0 +1,51 @@
+/*
+ * 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 samples.porter.file.api;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+@RestSchema(schemaId = "file")
+@RequestMapping(path = "/")
+public class FileEndpoint {
+  @Autowired
+  private FileService fileService;
+  
+  /**
+   * upload and return file id
+   */
+  @PostMapping(path = "/upload", produces = MediaType.TEXT_PLAIN_VALUE)
+  public String uploadFile(@RequestPart(name = "fileName") MultipartFile file) {
+      return fileService.uploadFile(file);
+  }
+
+  /**
+   * delete file by id
+   */
+  @DeleteMapping(path = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
+  public boolean deleteFile(@RequestParam(name = "id") String id) {
+      return fileService.deleteFile(id);
+  }
+}
diff --git a/porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java b/porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java
new file mode 100644
index 0000000..606e727
--- /dev/null
+++ b/porter_lightweight/common/src/main/java/samples/porter/file/api/FileService.java
@@ -0,0 +1,26 @@
+/*
+ * 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 samples.porter.file.api;
+
+import org.springframework.web.multipart.MultipartFile;
+
+public interface FileService {
+  public String uploadFile(MultipartFile file);
+
+  public boolean deleteFile(String id);
+}
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java b/porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.java
new file mode 100644
index 0000000..2aca62b
--- /dev/null
+++ b/porter_lightweight/common/src/main/java/samples/porter/user/api/SessionInfo.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 samples.porter.user.api;
+
+public class SessionInfo {
+  private String sessiondId;
+
+  private String userName;
+
+  private String roleName;
+
+  public String getSessiondId() {
+    return sessiondId;
+  }
+
+  public void setSessiondId(String sessiondId) {
+    this.sessiondId = sessiondId;
+  }
+
+  public String getUserName() {
+    return userName;
+  }
+
+  public void setUserName(String userName) {
+    this.userName = userName;
+  }
+
+  public String getRoleName() {
+    return roleName;
+  }
+
+  public void setRoleName(String roleName) {
+    this.roleName = roleName;
+  }
+}
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java b/porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java
new file mode 100644
index 0000000..8a248d3
--- /dev/null
+++ b/porter_lightweight/common/src/main/java/samples/porter/user/api/UserEndpoint.java
@@ -0,0 +1,49 @@
+/*
+ * 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 samples.porter.user.api;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "user")
+@RequestMapping(path = "/")
+public class UserEndpoint {
+  @Autowired
+  private UserService userService;
+
+  @PostMapping(path = "/v1/user/login", produces = MediaType.APPLICATION_JSON_VALUE)
+  public SessionInfo login(@RequestParam(name = "userName") String userName,
+      @RequestParam(name = "password") String password) {
+    return userService.login(userName, password);
+  }
+
+  @GetMapping(path = "/v1/user/session", produces = MediaType.APPLICATION_JSON_VALUE)
+  public SessionInfo getSession(@RequestParam(name = "sessionId") String sessionId) {
+    return userService.getSession(sessionId);
+  }
+
+  @GetMapping(path = "/v1/user/ping", produces = MediaType.APPLICATION_JSON_VALUE)
+  public String ping(@RequestParam(name = "message") String message) {
+    return userService.ping(message);
+  }
+}
diff --git a/porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java b/porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java
new file mode 100644
index 0000000..a37ffa3
--- /dev/null
+++ b/porter_lightweight/common/src/main/java/samples/porter/user/api/UserService.java
@@ -0,0 +1,27 @@
+/*
+ * 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 samples.porter.user.api;
+
+public interface UserService {
+  public SessionInfo login(String userName,
+      String password);
+
+  public SessionInfo getSession(String sessionId);
+
+  public String ping(String message);
+}
diff --git a/porter_lightweight/common/src/main/resources/microservice.yaml b/porter_lightweight/common/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..9e3de6e
--- /dev/null
+++ b/porter_lightweight/common/src/main/resources/microservice.yaml
@@ -0,0 +1,30 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+servicecomb-config-order: 10
+
+APPLICATION_ID: porter-application
+service_description:
+  version: 0.0.1
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
\ No newline at end of file
diff --git a/porter_lightweight/file-service/pom.xml b/porter_lightweight/file-service/pom.xml
new file mode 100644
index 0000000..d42ed5c
--- /dev/null
+++ b/porter_lightweight/file-service/pom.xml
@@ -0,0 +1,49 @@
+<!--
+  ~ 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.samples.porter</groupId>
+    <artifactId>porter-application</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>porter-file-service</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>porter-common</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
+  <properties>
+    <main.class>org.apache.servicecomb.samples.porter.file.FileMain</main.class>
+  </properties>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java
new file mode 100644
index 0000000..9b13142
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.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.servicecomb.samples.porter.file;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
+
+public class FileMain {
+    public static void main(String[] args) throws Exception {
+        Log4jUtils.init();
+        BeanUtils.init();
+    }
+}
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.java
new file mode 100644
index 0000000..78aea60
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileServiceImpl.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.servicecomb.samples.porter.file.service;
+
+import org.apache.servicecomb.foundation.common.utils.JsonUtils;
+import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+@Service
+public class FileServiceImpl implements samples.porter.file.api.FileService {
+    @Autowired
+    private FileStoreService fileService;
+
+    public String uploadFile(MultipartFile file) {
+        return fileService.uploadFile(file);
+    }
+
+    public boolean deleteFile(String id) {
+        String session = ContextUtils.getInvocationContext().getContext("session-info");
+        if (session == null) {
+            throw new InvocationException(403, "", "not allowed");
+        } else {
+            SessionInfo sessionInfo = null;
+            try {
+                sessionInfo = JsonUtils.readValue(session.getBytes("UTF-8"), SessionInfo.class);
+            } catch (Exception e) {
+                throw new InvocationException(403, "", "session not allowed");
+            }
+            if (sessionInfo == null || !sessionInfo.getRoleName().equals("admin")) {
+                throw new InvocationException(403, "", "not allowed");
+            }
+        }
+        return fileService.deleteFile(id);
+    }
+}
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileStoreService.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileStoreService.java
new file mode 100644
index 0000000..f9ff5c9
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/FileStoreService.java
@@ -0,0 +1,31 @@
+/*
+ * 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.servicecomb.samples.porter.file.service;
+
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * file storage service, can implement using file system, OBS, etc.
+ */
+public interface FileStoreService {
+
+    public String uploadFile(MultipartFile file);
+
+    public boolean deleteFile(String id);
+
+}
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/LocalFileStoreService.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/LocalFileStoreService.java
new file mode 100644
index 0000000..adb8b19
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/LocalFileStoreService.java
@@ -0,0 +1,64 @@
+/*
+ * 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.servicecomb.samples.porter.file.service;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.UUID;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ *  Simple file storage implementation.
+ *  Caution: file check and other security constraints not implemented. 
+ */
+@Component
+public class LocalFileStoreService implements FileStoreService {
+    // maxmum BUFFER_SIZE * BUFFER_NUM
+    private static final int BUFFER_SIZE = 10240;
+
+    private static final File BASE_FILE = new File(".");
+
+    @Override
+    public String uploadFile(MultipartFile file) {
+        byte[] buffer = new byte[BUFFER_SIZE];
+        String fileId = UUID.randomUUID().toString();
+
+        File outFile = new File(BASE_FILE, fileId);
+        int len;
+        try (InputStream is = file.getInputStream(); OutputStream os = new FileOutputStream(outFile)) {
+            while ((len = is.read(buffer)) != -1) {
+                os.write(buffer, 0, len);
+            }
+        } catch (IOException e) {
+            return null;
+        }
+        return fileId;
+    }
+
+    @Override
+    public boolean deleteFile(String id) {
+        File outFile = new File(BASE_FILE, id);
+        return outFile.delete();
+    }
+
+}
diff --git a/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/SessionInfo.java b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/SessionInfo.java
new file mode 100644
index 0000000..eeff226
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/SessionInfo.java
@@ -0,0 +1,81 @@
+/*
+ * 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.servicecomb.samples.porter.file.service;
+
+public class SessionInfo {
+    private int id;
+
+    private String sessiondId;
+
+    private String userName;
+
+    private String roleName;
+
+    private java.sql.Timestamp creationTime;
+
+    private java.sql.Timestamp activeTime;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getSessiondId() {
+        return sessiondId;
+    }
+
+    public void setSessiondId(String sessiondId) {
+        this.sessiondId = sessiondId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getRoleName() {
+        return roleName;
+    }
+
+    public void setRoleName(String roleName) {
+        this.roleName = roleName;
+    }
+
+    public java.sql.Timestamp getCreationTime() {
+        return creationTime;
+    }
+
+    public void setCreationTime(java.sql.Timestamp creationTime) {
+        this.creationTime = creationTime;
+    }
+
+    public java.sql.Timestamp getActiveTime() {
+        return activeTime;
+    }
+
+    public void setActiveTime(java.sql.Timestamp activeTime) {
+        this.activeTime = activeTime;
+    }
+
+}
diff --git a/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
new file mode 100644
index 0000000..4a3846c
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml
@@ -0,0 +1,29 @@
+<?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:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xsi:schemaLocation="
+        http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+    <!-- Only scan file components. Other beans in common module like org.apache.servicecomb.samples.porter.user.api.UserEndpoint ignored. -->
+    <context:component-scan base-package="samples.porter.file" />
+</beans>
\ No newline at end of file
diff --git a/porter_lightweight/file-service/src/main/resources/microservice.yaml b/porter_lightweight/file-service/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..bb71959
--- /dev/null
+++ b/porter_lightweight/file-service/src/main/resources/microservice.yaml
@@ -0,0 +1,30 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 10
+
+service_description:
+  name: file-service
+
+servicecomb:
+  rest:
+    address: 0.0.0.0:9091
+
+  uploads:
+    directory: tmp_for_upload_file
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/pom.xml b/porter_lightweight/gateway-service/pom.xml
new file mode 100644
index 0000000..427c75e
--- /dev/null
+++ b/porter_lightweight/gateway-service/pom.xml
@@ -0,0 +1,58 @@
+<!--
+  ~ 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.samples.porter</groupId>
+    <artifactId>porter-application</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>porter-gateway-service</artifactId>
+  <packaging>jar</packaging>
+
+  <properties>
+    <main.class>org.apache.servicecomb.samples.porter.gateway.GatewayMain</main.class>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>porter-common</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>edge-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>metrics-core</artifactId>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
new file mode 100644
index 0000000..c80f42a
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.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.servicecomb.samples.porter.gateway;
+
+import java.util.Map;
+
+import org.apache.servicecomb.edge.core.AbstractEdgeDispatcher;
+import org.apache.servicecomb.edge.core.EdgeInvocation;
+
+import io.vertx.ext.web.Cookie;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.CookieHandler;
+
+public class ApiDispatcher extends AbstractEdgeDispatcher {
+  @Override
+  public int getOrder() {
+    return 10002;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "/api/([^\\/]+)/(.*)";
+    router.routeWithRegex(regex).handler(CookieHandler.create());
+    router.routeWithRegex(regex).handler(createBodyHandler());
+    router.routeWithRegex(regex).failureHandler(this::onFailure).handler(this::onRequest);
+  }
+
+  protected void onRequest(RoutingContext context) {
+    Map<String, String> pathParams = context.pathParams();
+    String microserviceName = pathParams.get("param0");
+    String path = "/" + pathParams.get("param1");
+
+    EdgeInvocation invoker = new EdgeInvocation() {
+      // 认证鉴权:构造Invocation的时候,设置会话信息。如果是认证请求,则添加Cookie。
+      protected void createInvocation() {
+        super.createInvocation();
+        // 既从cookie里面读取会话ID,也从header里面读取,方便各种独立的测试工具联调
+        String sessionId = context.request().getHeader("session-id");
+        if (sessionId != null) {
+          this.invocation.addContext("session-id", sessionId);
+        } else {
+          Cookie sessionCookie = context.getCookie("session-id");
+          if (sessionCookie != null) {
+            this.invocation.addContext("session-id", sessionCookie.getValue());
+          }
+        }
+      }
+    };
+    invoker.init(microserviceName, context, path, httpServerFilters);
+    invoker.edgeInvoke();
+  }
+}
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
new file mode 100644
index 0000000..73cc06d
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
@@ -0,0 +1,105 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.JsonUtils;
+import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.concurrent.ListenableFuture;
+import org.springframework.util.concurrent.ListenableFutureCallback;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
+import samples.porter.user.api.SessionInfo;
+
+
+public class AuthHandler implements Handler {
+  private CseAsyncRestTemplate restTemplate = new CseAsyncRestTemplate();
+
+  //服务端会话过期是10分钟,客户端缓存1分钟会话。
+  private Cache<String, String> sessionCache = CacheBuilder.newBuilder()
+      .expireAfterAccess(30, TimeUnit.SECONDS)
+      .build();
+
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception {
+    if (invocation.getMicroserviceName().equals("user-service")
+        && (invocation.getOperationName().equals("login")
+            || (invocation.getOperationName().equals("getSession")))) {
+      // login: 直接返回认证结果。  开发者需要在JS里面设置cookie。 
+      invocation.next(asyncResponse);
+    } else {
+      // check session
+      String sessionId = invocation.getContext("session-id");
+      if (sessionId == null) {
+        throw new InvocationException(403, "", "session is not valid.");
+      }
+
+      String sessionInfo = sessionCache.getIfPresent(sessionId);
+      if (sessionInfo != null) {
+        try {
+          // 将会话信息传递给后面的微服务。后面的微服务可以从context获取到会话信息,从而可以进行鉴权等。 
+          invocation.addContext("session-id", sessionId);
+          invocation.addContext("session-info", sessionInfo);
+          invocation.next(asyncResponse);
+        } catch (Exception e) {
+          asyncResponse.complete(Response.failResp(new InvocationException(500, "", e.getMessage())));
+        }
+        return;
+      }
+
+      // 在网关执行的Hanlder逻辑,是reactive模式的,不能使用阻塞调用。
+      ListenableFuture<ResponseEntity<SessionInfo>> sessionInfoFuture =
+          restTemplate.getForEntity("cse://user-service/v1/user/session?sessionId=" + sessionId, SessionInfo.class);
+      sessionInfoFuture.addCallback(
+          new ListenableFutureCallback<ResponseEntity<SessionInfo>>() {
+            @Override
+            public void onFailure(Throwable ex) {
+              asyncResponse.complete(Response.failResp(new InvocationException(403, "", "session is not valid.")));
+            }
+
+            @Override
+            public void onSuccess(ResponseEntity<SessionInfo> result) {
+              SessionInfo sessionInfo = result.getBody();
+              if (sessionInfo == null) {
+                asyncResponse.complete(Response.failResp(new InvocationException(403, "", "session is not valid.")));
+                return;
+              }
+              try {
+                // 将会话信息传递给后面的微服务。后面的微服务可以从context获取到会话信息,从而可以进行鉴权等。 
+                invocation.addContext("session-id", sessionId);
+                String sessionInfoStr = JsonUtils.writeValueAsString(sessionInfo);
+                invocation.addContext("session-info", sessionInfoStr);
+                invocation.next(asyncResponse);
+                sessionCache.put(sessionId, sessionInfoStr);
+              } catch (Exception e) {
+                asyncResponse.complete(Response.failResp(new InvocationException(500, "", e.getMessage())));
+              }
+            }
+          });
+    }
+  }
+}
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
new file mode 100644
index 0000000..159c10d
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
@@ -0,0 +1,38 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import java.io.File;
+
+import org.apache.servicecomb.foundation.ssl.SSLCustom;
+
+public class EdgeSSLCustom extends SSLCustom {
+
+    @Override
+    public char[] decode(char[] plain) {
+        return plain;
+    }
+
+    @Override
+    public String getFullPath(String name) {
+        String fullName = System.getProperty("user.dir") + File.separator + name;
+        System.out.println(fullName);
+        return (new File(fullName)).getAbsolutePath();
+    }
+
+}
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
new file mode 100644
index 0000000..48c1824
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.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.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
+
+public class GatewayMain {
+    public static void main(String[] args) throws Exception {
+        Log4jUtils.init();
+        BeanUtils.init();
+    }
+}
diff --git a/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
new file mode 100644
index 0000000..791c512
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
@@ -0,0 +1,52 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.handler.StaticHandler;
+
+public class StaticWebpageDispatcher implements VertxHttpDispatcher {
+  private static final Logger LOGGER = LoggerFactory.getLogger(StaticWebpageDispatcher.class);
+
+  private static final String WEB_ROOT = DynamicPropertyFactory.getInstance()
+      .getStringProperty("gateway.webroot", "/var/static")
+      .get();
+
+  @Override
+  public int getOrder() {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "/ui/(.*)";
+    StaticHandler webpageHandler = StaticHandler.create();
+    webpageHandler.setWebRoot(WEB_ROOT);
+    LOGGER.info("server static web page for WEB_ROOT={}", WEB_ROOT);
+    router.routeWithRegex(regex).failureHandler((context) -> {
+      LOGGER.error("", context.failure());
+    }).handler(webpageHandler);
+  }
+
+}
diff --git a/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
new file mode 100644
index 0000000..71009db
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
+org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml b/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml
new file mode 100644
index 0000000..00295f8
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/config/cse.handler.xml
@@ -0,0 +1,21 @@
+<!--
+  ~ 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.
+  -->
+
+<config>
+	<handler id="auth"
+			 class="org.apache.servicecomb.samples.porter.gateway.AuthHandler" />
+</config>
diff --git a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..5623c60
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
@@ -0,0 +1,45 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+service_description:
+  name: gateway-service
+
+servicecomb:
+  rest:
+    address: 0.0.0.0:9090?sslEnabled=false
+
+  handler:
+    chain:
+      Consumer:
+        default: auth,qps-flowcontrol-consumer,loadbalance
+
+  uploads:
+    directory: tmp_for_upload_gateway
+
+  accesslog:
+    enabled: true
+  metrics:
+    window_time: 30000
+    publisher.defaultLog.enabled: true
+
+servicecomb.http.dispatcher.edge.default.enabled: false
+servicecomb.http.dispatcher.rest.enabled: false
+gateway.webroot: /code/servicecomb-samples/porter_lightweight/gateway-service/src/main/resources
diff --git a/porter_lightweight/gateway-service/src/main/resources/ui/css/style.css b/porter_lightweight/gateway-service/src/main/resources/ui/css/style.css
new file mode 100644
index 0000000..5731863
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/ui/css/style.css
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+.error {
+    font-family:verdana;
+    color:red;
+}
+
+.header {
+    background-color:black;
+    color:white;
+    text-align:center;
+    padding:5px;
+}
+
+.nav {
+    line-height:30px;
+    background-color:#eeeeee;
+    height:300px;
+    width:100px;
+    float:left;
+    padding:5px; 
+}
+
+.section {
+    text-align:center;
+    padding:5px;
+}
+
+.footer {
+    color:red;
+    clear:both;
+    text-align:center;
+    padding:25px; 
+}
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/src/main/resources/ui/js/jquery-1.11.1.min.js b/porter_lightweight/gateway-service/src/main/resources/ui/js/jquery-1.11.1.min.js
new file mode 100644
index 0000000..ab28a24
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/ui/js/jquery-1.11.1.min.js
@@ -0,0 +1,4 @@
+/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
+!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b [...]
+if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&& [...]
+},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.prop [...]
diff --git a/porter_lightweight/gateway-service/src/main/resources/ui/js/login.js b/porter_lightweight/gateway-service/src/main/resources/ui/js/login.js
new file mode 100644
index 0000000..c7e7c8e
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/ui/js/login.js
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+function loginAction() {
+     var username = document.getElementById("username").value;
+     var password = document.getElementById("paasword").value;
+     var formData = {};
+     formData.userName = username;
+     formData.password = password;
+
+     $.ajax({
+        type: 'POST',
+        url: "/api/user-service/v1/user/login",
+        data: formData,
+        success: function (data) {
+            console.log(data);
+            setCookie("session-id", data.sessiondId, 1);
+            window.location = "/ui/upload.html";
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Login failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
+
+function setCookie(name,value,days) {
+    var expires = "";
+    if (days) {
+        var date = new Date();
+        date.setTime(date.getTime() + (days*24*60*60*1000));
+        expires = "; expires=" + date.toUTCString();
+    }
+    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
+}
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/src/main/resources/ui/js/upload.js b/porter_lightweight/gateway-service/src/main/resources/ui/js/upload.js
new file mode 100644
index 0000000..7d66555
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/ui/js/upload.js
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+function uploadAction() {
+     var formData = new FormData(document.getElementById("upload_form"));
+
+     $.ajax({
+        type: 'POST',
+        url: "/api/file-service/upload",
+        data: formData,
+        processData:false,
+        contentType:false,
+        success: function (data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Upload Successfully";
+            error.hidden=false;
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Upload failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
+
+function deleteAction() {
+     var fileID = document.getElementById("fileID").value;
+     $.ajax({
+        type: 'DELETE',
+        url: "/api/file-service/delete?" + $.param({ id: fileID }),
+        data: {},
+        success: function (data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Delete successfully";
+            error.hidden=false;
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Delete failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/src/main/resources/ui/login.html b/porter_lightweight/gateway-service/src/main/resources/ui/login.html
new file mode 100644
index 0000000..c8b45fb
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/ui/login.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+
+<!--
+  ~ 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.
+  -->
+
+<html>
+
+    <head>
+        <title>PORTER</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
+        <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
+        <script type="text/javascript" src="js/login.js"></script>
+    </head>
+
+    <body>
+    <div class="header">
+        <h2>Login</h2>
+    </div>
+    <div class="section">
+        <form method="POST" enctype="multipart/form-data">
+            <input id="username" type="text" placeholder="Username" required="true"/>
+            <input id="paasword" type="password" placeholder="Password" required="true"/>
+            <input type="button" value="Login" onclick="loginAction()">
+        </form>
+    </div>
+    <div class="footer">
+        <p id="error" hidden="true" class="error"/>
+    </div>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/porter_lightweight/gateway-service/src/main/resources/ui/upload.html b/porter_lightweight/gateway-service/src/main/resources/ui/upload.html
new file mode 100644
index 0000000..bd5eeff
--- /dev/null
+++ b/porter_lightweight/gateway-service/src/main/resources/ui/upload.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<!--
+  ~ 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.
+  -->
+
+<html>
+
+    <head>
+        <title>PORTER</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
+        <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
+        <script type="text/javascript" src="js/upload.js"></script>
+    </head>
+
+    <body>
+    <div class="header">
+        <h2>Upload</h2>
+    </div>
+    <div class="section">
+        <form id="upload_form" method="POST">
+            <p>
+                File Name: <input type="file" name="fileName"/>
+            </p>
+            <p>
+                <input type="button" value="Upload" onclick="uploadAction()">
+            </p>
+        </form>
+    </div>
+
+    <div class="header">
+        <h2>Delete file</h2>
+    </div>
+    <div class="section">
+        <form id="delete_form" method="DELETE">
+            <p>
+                File ID: <input id="fileID" type="text"/>
+            </p>
+            <p>
+                <input type="button" value="Delete" onclick="deleteAction()">
+            </p>
+        </form>
+    </div>
+    <div class="footer">
+        <p id="error" hidden="true" class="error"/>
+    </div>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/porter_lightweight/pom.xml b/porter_lightweight/pom.xml
new file mode 100644
index 0000000..5a7e539
--- /dev/null
+++ b/porter_lightweight/pom.xml
@@ -0,0 +1,165 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.samples.porter</groupId>
+  <artifactId>porter-application</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis</artifactId>
+        <version>3.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis-spring</artifactId>
+        <version>1.3.0</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.46</version>
+      </dependency>
+      <!-- need to compile lastest java-chassis code -->
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+  </dependencies>
+
+  <modules>
+    <module>common</module>
+    <module>file-service</module>
+    <module>user-service</module>
+    <module>gateway-service</module>
+  </modules>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-deploy-plugin</artifactId>
+          <version>2.8.2</version>
+          <configuration>
+            <skip>true</skip>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-install-plugin</artifactId>
+          <version>2.5.2</version>
+          <configuration>
+            <skip>false</skip>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-jar-plugin</artifactId>
+          <version>2.6</version>
+          <configuration>
+            <outputDirectory>${project.build.directory}</outputDirectory>
+            <archive>
+              <manifestEntries>
+                <Class-Path>.</Class-Path>
+              </manifestEntries>
+            </archive>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-war-plugin</artifactId>
+          <version>2.6</version>
+          <configuration>
+            <outputDirectory>${project.build.directory}</outputDirectory>
+            <archive>
+              <manifest>
+                <addClasspath>true</addClasspath>
+                <classpathPrefix>./lib/</classpathPrefix>
+              </manifest>
+              <manifestEntries>
+                <Class-Path>.</Class-Path>
+              </manifestEntries>
+            </archive>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-dependency-plugin</artifactId>
+          <version>2.10</version>
+          <executions>
+            <execution>
+              <id>copy-dependencies</id>
+              <phase>package</phase>
+              <goals>
+                <goal>copy-dependencies</goal>
+              </goals>
+              <configuration>
+                <outputDirectory>${project.build.directory}/lib</outputDirectory>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/user-service/.gitignore b/porter_lightweight/user-service/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/porter_lightweight/user-service/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/porter_lightweight/user-service/pom.xml b/porter_lightweight/user-service/pom.xml
new file mode 100644
index 0000000..04c50ae
--- /dev/null
+++ b/porter_lightweight/user-service/pom.xml
@@ -0,0 +1,85 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.samples.porter</groupId>
+    <artifactId>porter-application</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>porter-user-service</artifactId>
+  <packaging>jar</packaging>
+
+  <properties>
+    <main.class>org.apache.servicecomb.samples.porter.user.UserMain</main.class>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples.porter</groupId>
+      <artifactId>porter-common</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java
new file mode 100644
index 0000000..390b040
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.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.servicecomb.samples.porter.user;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
+
+public class UserMain {
+  public static void main(String[] args) throws Exception {
+    Log4jUtils.init();
+    BeanUtils.init();
+  }
+}
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
new file mode 100644
index 0000000..f363af5
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionInfoModel.java
@@ -0,0 +1,90 @@
+/*
+ * 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.servicecomb.samples.porter.user.dao;
+
+import samples.porter.user.api.SessionInfo;
+
+public class SessionInfoModel {
+  private int id;
+
+  private String sessiondId;
+
+  private String userName;
+
+  private String roleName;
+
+  private java.sql.Timestamp creationTime;
+
+  private java.sql.Timestamp activeTime;
+
+  public int getId() {
+    return id;
+  }
+
+  public void setId(int id) {
+    this.id = id;
+  }
+
+  public String getSessiondId() {
+    return sessiondId;
+  }
+
+  public void setSessiondId(String sessiondId) {
+    this.sessiondId = sessiondId;
+  }
+
+  public String getUserName() {
+    return userName;
+  }
+
+  public void setUserName(String userName) {
+    this.userName = userName;
+  }
+
+  public String getRoleName() {
+    return roleName;
+  }
+
+  public void setRoleName(String roleName) {
+    this.roleName = roleName;
+  }
+
+  public java.sql.Timestamp getCreationTime() {
+    return creationTime;
+  }
+
+  public void setCreationTime(java.sql.Timestamp creationTime) {
+    this.creationTime = creationTime;
+  }
+
+  public java.sql.Timestamp getActiveTime() {
+    return activeTime;
+  }
+
+  public void setActiveTime(java.sql.Timestamp activeTime) {
+    this.activeTime = activeTime;
+  }
+
+  public static SessionInfo toSessionInfo(SessionInfoModel entity) {
+    SessionInfo info = new SessionInfo();
+    info.setSessiondId(entity.getSessiondId());
+    info.setUserName(entity.getUserName());
+    info.setRoleName(entity.getRoleName());
+    return info;
+  }
+}
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.java
new file mode 100644
index 0000000..fb3306b
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/SessionMapper.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.servicecomb.samples.porter.user.dao;
+
+import samples.porter.user.api.SessionInfo;
+
+public interface SessionMapper {
+    void createSession(SessionInfo sessionInfo);
+
+    SessionInfoModel getSessioinInfo(String sessionId);
+    
+    void updateSessionInfo(String sessionId);
+}
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/UserInfo.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/UserInfo.java
new file mode 100644
index 0000000..b0e2003
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/UserInfo.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.servicecomb.samples.porter.user.dao;
+
+public class UserInfo {
+    private int id;
+
+    private String userName;
+
+    private String password;
+
+    private String roleName;
+
+    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;
+    }
+
+    public String getRoleName() {
+        return roleName;
+    }
+
+    public void setRoleName(String roleName) {
+        this.roleName = roleName;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+}
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/UserMapper.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/UserMapper.java
new file mode 100644
index 0000000..5c2d331
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/UserMapper.java
@@ -0,0 +1,24 @@
+/*
+ * 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.servicecomb.samples.porter.user.dao;
+
+public interface UserMapper {
+    void createUser(UserInfo userInfo);
+
+    UserInfo getUserInfo(String userName);
+}
diff --git a/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
new file mode 100644
index 0000000..2633d57
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/service/UserServiceImpl.java
@@ -0,0 +1,114 @@
+/*
+ * 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.servicecomb.samples.porter.user.service;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel;
+import org.apache.servicecomb.samples.porter.user.dao.SessionMapper;
+import org.apache.servicecomb.samples.porter.user.dao.UserInfo;
+import org.apache.servicecomb.samples.porter.user.dao.UserMapper;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import samples.porter.user.api.SessionInfo;
+import samples.porter.user.api.UserService;
+
+@Service
+public class UserServiceImpl implements UserService {
+  private static Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);
+
+  @Autowired
+  private UserMapper userMapper;
+
+  @Autowired
+  private SessionMapper sessionMapper;
+
+
+  public SessionInfo login(String userName,
+      String password) {
+    UserInfo userInfo = userMapper.getUserInfo(userName);
+    if (userInfo != null) {
+      if (validatePassword(password, userInfo.getPassword())) {
+        SessionInfo sessionInfo = new SessionInfo();
+        sessionInfo.setSessiondId(UUID.randomUUID().toString());
+        sessionInfo.setUserName(userInfo.getUserName());
+        sessionInfo.setRoleName(userInfo.getRoleName());
+        sessionMapper.createSession(sessionInfo);
+        return sessionInfo;
+      }
+    }
+    return null;
+  }
+
+  public SessionInfo getSession(String sessionId) {
+    if (sessionId == null) {
+      throw new InvocationException(405, "", "invalid session.");
+    }
+    SessionInfoModel sessionInfo = sessionMapper.getSessioinInfo(sessionId);
+    if (sessionInfo != null) {
+      if (System.currentTimeMillis() - sessionInfo.getActiveTime().getTime() > 10 * 60 * 1000) {
+        LOGGER.info("user session expired.");
+        return null;
+      } else {
+        sessionMapper.updateSessionInfo(sessionInfo.getSessiondId());
+        return SessionInfoModel.toSessionInfo(sessionInfo);
+      }
+    }
+    return null;
+  }
+
+  private boolean validatePassword(String plain, String encrypt) {
+    // 简单加密校验,开发者可以结合业务场景自行修改
+    try {
+      MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
+      messageDigest.update(plain.getBytes("UTF-8"));
+      byte byteBuffer[] = messageDigest.digest();
+      String encryptedText = Base64.encodeBase64String(byteBuffer);
+      return encryptedText.equals(encrypt);
+    } catch (NoSuchAlgorithmException e) {
+      LOGGER.error("", e);
+    } catch (UnsupportedEncodingException e) {
+      LOGGER.error("", e);
+    }
+    return false;
+  }
+
+
+  public String ping(String message) {
+    long delay = DynamicPropertyFactory.getInstance().getLongProperty("user.ping.delay", 0).get();
+    if (delay > 0) {
+      try {
+        TimeUnit.SECONDS.sleep(delay);
+      } catch (InterruptedException e) {
+        LOGGER.error("", e);
+      }
+    }
+    return message;
+  }
+}
diff --git a/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
new file mode 100644
index 0000000..e1cdd94
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/resources/META-INF/spring/user.bean.xml
@@ -0,0 +1,57 @@
+<?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:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+    <context:component-scan base-package="samples.porter.user" >
+    </context:component-scan>
+
+    <bean id="dataSource"
+        class="org.apache.commons.dbcp2.BasicDataSource"
+        destroy-method="close">
+        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
+        <property name="url"
+            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
+        <property name="username" value="${db.username:root}" />
+        <property name="password" value="${db.password:}" />
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
+    </bean>
+
+    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/porter_lightweight/user-service/src/main/resources/config/SessionMapper.xml b/porter_lightweight/user-service/src/main/resources/config/SessionMapper.xml
new file mode 100644
index 0000000..989e786
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/resources/config/SessionMapper.xml
@@ -0,0 +1,57 @@
+<?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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
+    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
+        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
+    </sql>
+
+    <sql id="all_column_auto">
+        SESSION_ID, USER_NAME, ROLE_NAME
+    </sql>
+
+    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        insert into T_SESSION (
+        <include refid="all_column_auto" />
+        )
+        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
+        #{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getSessioinInfo" parameterType="java.lang.String"
+        resultMap="sessionInfo">
+        select
+        <include refid="all_column" />
+        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
+    </select>
+    
+    <update id="updateSessionInfo" parameterType="java.lang.String">
+        update T_SESSION
+        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
+    </update>
+</mapper>
\ No newline at end of file
diff --git a/porter_lightweight/user-service/src/main/resources/config/UserMapper.xml b/porter_lightweight/user-service/src/main/resources/config/UserMapper.xml
new file mode 100644
index 0000000..c02e60d
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/resources/config/UserMapper.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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
+    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, USER_NAME, PASSWORD, ROLE_NAME
+    </sql>
+
+    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        insert into T_USER (
+        <include refid="all_column" />
+        )
+        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
+        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getUserInfo" parameterType="java.lang.String"
+        resultMap="userInfo">
+        select
+        <include refid="all_column" />
+        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql b/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql
new file mode 100644
index 0000000..3505f3d
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/resources/config/create_db_user.sql
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+CREATE DATABASE IF NOT EXISTS porter_user_db;
+
+USE porter_user_db;
+
+DROP TABLE IF EXISTS T_USER;
+
+CREATE TABLE `T_USER` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT '用户名称',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT '用户密码',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT '角色名称',
+  PRIMARY KEY (`ID`)
+);
+
+#### password is encrypted for test
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
+
+DROP TABLE IF EXISTS T_SESSION;
+
+CREATE TABLE `T_SESSION` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT '唯一标识',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT '临时会话ID',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT '用户名称',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT '角色名称',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近活跃时间',
+  PRIMARY KEY (`ID`)
+);
diff --git a/porter_lightweight/user-service/src/main/resources/config/mybatis-config.xml b/porter_lightweight/user-service/src/main/resources/config/mybatis-config.xml
new file mode 100644
index 0000000..894caac
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/resources/config/mybatis-config.xml
@@ -0,0 +1,27 @@
+<?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.
+  -->
+
+<!DOCTYPE configuration
+  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <mappers>
+        <mapper resource="config/UserMapper.xml"/>
+        <mapper resource="config/SessionMapper.xml"/>
+    </mappers>
+</configuration>
\ No newline at end of file
diff --git a/porter_lightweight/user-service/src/main/resources/microservice.yaml b/porter_lightweight/user-service/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..81ef89e
--- /dev/null
+++ b/porter_lightweight/user-service/src/main/resources/microservice.yaml
@@ -0,0 +1,27 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 10
+
+service_description:
+  name: user-service
+
+servicecomb:
+  rest:
+    address: 0.0.0.0:9093
\ No newline at end of file


[servicecomb-samples] 17/32: add test cases and modify license info

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 5b965a65c5c132c1a564f13a504235805f1822a5
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 10 10:10:00 2019 +0800

    add test cases and modify license info
---
 .../AuthenticationConfiguration.java               |  17 ++++
 .../servicecomb/authentication/user/Role.java      |   5 -
 .../servicecomb/authentication/user/User.java      |  11 --
 .../servicecomb/authentication/user/UserStore.java |   5 -
 authentication/Client/pom.xml                      |  18 ++++
 .../authentication/AuthenticationTestCase.java     |  78 +++++++++++++++
 .../authentication/BootEventListener.java          |  41 ++++++++
 .../authentication/GateRestTemplate.java           | 111 +++++++++++++++++++++
 .../authentication/ITUriTemplateHandler.java}      |  36 +++----
 .../servicecomb/authentication/TestCase.java}      |  32 +-----
 .../servicecomb/authentication/TestEndpoint.java   |  48 +++++++++
 .../apache/servicecomb/authentication/TestMgr.java | 105 +++++++++++++++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 -----------
 .../src/main/resources/config/SessionMapper.xml    |  57 -----------
 .../src/main/resources/config/UserMapper.xml       |  46 ---------
 .../src/main/resources/config/create_db_user.sql   |  46 ---------
 .../src/main/resources/config/mybatis-config.xml   |  27 -----
 .../Client/src/main/resources/microservice.yaml    |   7 +-
 .../gateway/AuthenticationConfiguration.java       |  17 ++++
 .../gateway/AuthenticationFilter.java              |  17 ++++
 ...servicecomb.common.rest.filter.HttpServerFilter |  17 ++++
 .../Gateway/src/main/resources/microservice.yaml   |   1 +
 .../authentication/test/PatternTest.java           |  17 ++++
 authentication/README.md                           |  35 +++++--
 .../resource/AccessConfiguration.java              |  17 ++++
 .../resource/AccessConfigurationManager.java       |  17 ++++
 .../resource/AuthenticationConfiguration.java      |  17 ++++
 .../resource/HandlerAuthEndpoint.java              |  17 ++++
 .../resource/PreMethodAuthEndpoint.java            |  17 ++++
 .../resource/ResourceAuthHandler.java              |  17 ++++
 .../servicecomb/authentication/jwt/JWTClaims.java  |  17 ++++
 .../authentication/jwt/JWTClaimsCommon.java        |  17 ++++
 .../servicecomb/authentication/jwt/JWTHeader.java  |  17 ++++
 .../servicecomb/authentication/jwt/JsonParser.java |  17 ++++
 .../servicecomb/authentication/util/Constants.java |  17 ++++
 35 files changed, 725 insertions(+), 312 deletions(-)

diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
index 5840fc3..7d9d076 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication;
 
 import java.util.Arrays;
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
deleted file mode 100644
index 393cd3e..0000000
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.servicecomb.authentication.user;
-
-public interface Role {
-  String getRoleName();
-}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
deleted file mode 100644
index b0ba017..0000000
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.servicecomb.authentication.user;
-
-import java.util.Collection;
-
-public interface User {
-  Collection<Role> getRoles();
-
-  String getPassword();
-
-  String getUsername();
-}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
deleted file mode 100644
index 5bd8459..0000000
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.servicecomb.authentication.user;
-
-public interface UserStore {
-  User loadUserByUsername(String userName);
-}
diff --git a/authentication/Client/pom.xml b/authentication/Client/pom.xml
index 60978df..c94ff12 100644
--- a/authentication/Client/pom.xml
+++ b/authentication/Client/pom.xml
@@ -27,6 +27,16 @@
   <dependencyManagement>
     <dependencies>
       <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-service</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>org.mybatis</groupId>
         <artifactId>mybatis</artifactId>
         <version>3.4.5</version>
@@ -53,6 +63,14 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
new file mode 100644
index 0000000..1bae5c3
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
@@ -0,0 +1,78 @@
+/*
+ * 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.servicecomb.authentication;
+
+import org.apache.servicecomb.authentication.api.Token;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.HttpClientErrorException;
+
+@Component
+public class AuthenticationTestCase implements TestCase {
+  @Override
+  public void run() {
+    // get token
+    MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
+    map.add("userName", "admin");
+    map.add("password", "changeMyPassword");
+    HttpHeaders headers = new HttpHeaders();
+    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
+
+    Token token =
+        BootEventListener.gateEndpoint.postForObject("/v1/auth/login",
+            new HttpEntity<>(map, headers),
+            Token.class);
+    TestMgr.check("bearer", token.getToken_type());
+    TestMgr.check(true, token.getAccess_token().length() > 10);
+
+    // get resources
+    headers = new HttpHeaders();
+    headers.add("Authorization", "Bearer " + token.getAccess_token());
+    headers.setContentType(MediaType.APPLICATION_JSON);
+    String name;
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/everyoneSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/adminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/guestOrAdminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = null;
+    try {
+      name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/guestSayHello?name=Hi",
+          new HttpEntity<>(headers),
+          String.class);
+    } catch (HttpClientErrorException e) {
+      TestMgr.check(403, e.getStatusCode().value());
+    }
+    TestMgr.check(null, name);
+  }
+
+}
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
new file mode 100644
index 0000000..2af0a55
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.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.servicecomb.authentication;
+
+import org.apache.servicecomb.core.BootListener;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BootEventListener implements BootListener {
+  public static GateRestTemplate authenticationServerAuthenticationEndpoint;
+  public static GateRestTemplate gateEndpoint;
+  public static GateRestTemplate resouceServerHandlerAuthEndpoint;
+  @Override
+  public void onBootEvent(BootEvent event) {
+    if (EventType.AFTER_REGISTRY.equals(event.getEventType())) {
+      authenticationServerAuthenticationEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("gateway", "authentication-server", "AuthenticationEndpoint").init();
+      gateEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("gateway", null, null).init();
+      resouceServerHandlerAuthEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "HandlerAuthEndpoint").init();
+    }
+
+  }
+
+}
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
new file mode 100644
index 0000000..7a6709f
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
@@ -0,0 +1,111 @@
+/*
+ * 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.servicecomb.authentication;
+
+import java.util.Arrays;
+
+import org.apache.servicecomb.core.definition.MicroserviceVersionMeta;
+import org.apache.servicecomb.core.definition.SchemaMeta;
+import org.apache.servicecomb.foundation.common.net.URIEndpointObject;
+import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
+import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersionRule;
+import org.apache.servicecomb.serviceregistry.definition.DefinitionConst;
+import org.springframework.http.converter.FormHttpMessageConverter;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+
+public class GateRestTemplate extends RestTemplate {
+  private final String gateName;
+
+  private final String schemaId;
+
+  private final String producerName;
+
+  private String urlPrefix;
+
+  public static GateRestTemplate createEdgeRestTemplate(String gateName, String producerName, String schemaId) {
+    return new GateRestTemplate(gateName, producerName, schemaId);
+  }
+
+
+  public GateRestTemplate(String gateName, String producerName, String schemaId) {
+    this.gateName = gateName;
+    this.producerName = producerName;
+    this.schemaId = schemaId;
+  }
+
+  public GateRestTemplate init() {
+    urlPrefix = getUrlPrefix(gateName, producerName, schemaId);
+
+    setUriTemplateHandler(new ITUriTemplateHandler(urlPrefix));
+
+    setMessageConverters(Arrays.asList(
+        new MappingJackson2HttpMessageConverter(),
+        new StringHttpMessageConverter(),
+        new FormHttpMessageConverter()));
+
+    return this;
+  }
+
+  public String getUrlPrefix() {
+    return urlPrefix;
+  }
+
+  private String getUrlPrefix(String gateName, String producerName, String schemaId) {
+    MicroserviceVersionRule microserviceVersionRule = RegistryUtils.getServiceRegistry()
+        .getAppManager()
+        .getOrCreateMicroserviceVersionRule(RegistryUtils.getAppId(),
+            gateName,
+            DefinitionConst.VERSION_RULE_ALL);
+    MicroserviceInstance microserviceInstance = microserviceVersionRule.getInstances()
+        .values()
+        .stream()
+        .findFirst()
+        .get();
+    URIEndpointObject edgeAddress = new URIEndpointObject(microserviceInstance.getEndpoints().get(0));
+
+    String urlSchema = "http";
+    if (edgeAddress.isSslEnabled()) {
+      urlSchema = "https";
+    }
+
+    if(producerName == null) {
+      return String
+          .format("%s://%s:%d",
+              urlSchema,
+              edgeAddress.getHostOrIp(),
+              edgeAddress.getPort());
+    }
+    
+    microserviceVersionRule = RegistryUtils.getServiceRegistry()
+        .getAppManager()
+        .getOrCreateMicroserviceVersionRule(RegistryUtils.getAppId(),
+            producerName,
+            DefinitionConst.VERSION_RULE_ALL);
+    MicroserviceVersionMeta microserviceVersionMeta = microserviceVersionRule.getLatestMicroserviceVersion();
+    SchemaMeta schemaMeta = microserviceVersionMeta.getMicroserviceMeta().ensureFindSchemaMeta(schemaId);
+    return String
+        .format("%s://%s:%d/api/%s%s",
+            urlSchema,
+            edgeAddress.getHostOrIp(),
+            edgeAddress.getPort(),
+            producerName,
+            schemaMeta.getSwagger().getBasePath());
+  }
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
similarity index 52%
copy from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
copy to authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
index 54c2175..8308599 100644
--- a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
@@ -14,35 +14,31 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.servicecomb.authentication;
 
-package org.apache.servicecomb.authentication.api;
+import java.net.URI;
+import java.util.Map;
 
-/**
- * 
- * After successfully login, tokens are created. </br>
- * <B>Access Token:</B> used to access resources.</br>
- * <B>Refresh Token:</B> used to acquire new tokens.</br>
- *
- */
-public class Tokens {
-  private String accessToken;
+import org.springframework.web.util.DefaultUriTemplateHandler;
 
-  private String refreshToken;
+public class ITUriTemplateHandler extends DefaultUriTemplateHandler {
+  private String urlPrefix;
 
-  public String getAccessToken() {
-    return accessToken;
+  public ITUriTemplateHandler(String urlPrefix) {
+    this.urlPrefix = urlPrefix;
   }
 
-  public void setAccessToken(String accessToken) {
-    this.accessToken = accessToken;
+  @Override
+  protected URI expandInternal(String uriTemplate, Object... uriVariables) {
+    return super.expandInternal(changeUrl(uriTemplate), uriVariables);
   }
 
-  public String getRefreshToken() {
-    return refreshToken;
+  @Override
+  protected URI expandInternal(String uriTemplate, Map<String, ?> uriVariables) {
+    return super.expandInternal(changeUrl(uriTemplate), uriVariables);
   }
 
-  public void setRefreshToken(String refreshToken) {
-    this.refreshToken = refreshToken;
+  private String changeUrl(String uriTemplate) {
+    return urlPrefix + uriTemplate;
   }
-
 }
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
similarity index 55%
rename from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
rename to authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
index 54c2175..1c511d2 100644
--- a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
@@ -15,34 +15,8 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
-
-/**
- * 
- * After successfully login, tokens are created. </br>
- * <B>Access Token:</B> used to access resources.</br>
- * <B>Refresh Token:</B> used to acquire new tokens.</br>
- *
- */
-public class Tokens {
-  private String accessToken;
-
-  private String refreshToken;
-
-  public String getAccessToken() {
-    return accessToken;
-  }
-
-  public void setAccessToken(String accessToken) {
-    this.accessToken = accessToken;
-  }
-
-  public String getRefreshToken() {
-    return refreshToken;
-  }
-
-  public void setRefreshToken(String refreshToken) {
-    this.refreshToken = refreshToken;
-  }
+package org.apache.servicecomb.authentication;
 
+public interface TestCase {
+  void run();
 }
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
new file mode 100644
index 0000000..04c3927
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
@@ -0,0 +1,48 @@
+/*
+ * 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.servicecomb.authentication;
+
+import java.util.List;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestSchema(schemaId = "TestEndpoint")
+@RequestMapping(path = "/v1/test")
+public class TestEndpoint {
+  @Autowired
+  private List<TestCase> tests;
+  
+  @GetMapping(path = "/start")
+  public String start() {
+    tests.forEach(test -> test.run());
+    
+    List<Throwable> errors = TestMgr.errors();
+    if (errors.isEmpty()) {
+      return "success";
+    } else {
+      StringBuilder sb = new StringBuilder();
+      sb.append("Failed count : " + errors.size());
+      sb.append("\n");
+      errors.forEach(t -> sb.append(t.getMessage() + "\n"));
+      return sb.toString();
+    }
+  }
+}
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
new file mode 100644
index 0000000..6b53045
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
@@ -0,0 +1,105 @@
+/*
+ * 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.servicecomb.authentication;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
+
+public class TestMgr {
+  private static final Logger LOGGER = LoggerFactory.getLogger(TestMgr.class);
+
+  private static final List<Throwable> errorList = new ArrayList<>();
+
+  private static String msg = "";
+
+  public static void setMsg(String msg) {
+    TestMgr.msg = msg;
+  }
+
+  public static void setMsg(String microserviceName, String transport) {
+    TestMgr.msg = String.format("microservice=%s, transport=%s", microserviceName, transport);
+  }
+
+  public static void check(Object expect, Object real) {
+    check(expect, real, null);
+  }
+
+  public static void check(Object expect, Object real, Throwable error) {
+    if (expect == real) {
+      return;
+    }
+
+    String strExpect = String.valueOf(expect);
+    String strReal = String.valueOf(real);
+
+    if (!strExpect.equals(strReal)) {
+      Error newError = new Error(msg + " | Expect " + strExpect + ", but " + strReal);
+      if (error != null) {
+        newError.setStackTrace(error.getStackTrace());
+      }
+      errorList.add(newError);
+    }
+  }
+
+  public static void checkNotEmpty(String real) {
+    if (StringUtils.isEmpty(real)) {
+      errorList.add(new Error(msg + " | unexpected null result, method is " + getCaller()));
+    }
+  }
+
+  public static void failed(String desc, Throwable e) {
+    Error error = new Error(msg + " | " + desc + ", method is " + getCaller());
+    if (e != null) {
+      error.setStackTrace(error.getStackTrace());
+    }
+    errorList.add(error);
+  }
+
+  public static boolean isSuccess() {
+    return errorList.isEmpty();
+  }
+
+  public static void summary() {
+    if (errorList.isEmpty()) {
+      LOGGER.info("............. test finished ............");
+      return;
+    }
+
+    LOGGER.info("............. test not finished ............");
+    for (Throwable e : errorList) {
+      LOGGER.info("", e);
+    }
+  }
+
+  public static List<Throwable> errors() {
+    return errorList;
+  }
+
+  private static String getCaller() {
+    StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+    if (stackTrace.length < 3) {
+      return null;
+    }
+    StackTraceElement stackTraceElement = stackTrace[3];
+    return stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName();
+  }
+}
diff --git a/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml b/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
deleted file mode 100644
index 661608f..0000000
--- a/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
+++ /dev/null
@@ -1,56 +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:p="http://www.springframework.org/schema/p"
-    xmlns:util="http://www.springframework.org/schema/util"
-    xmlns:context="http://www.springframework.org/schema/context"
-    xmlns:tx="http://www.springframework.org/schema/tx"
-    xsi:schemaLocation="
-		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
-        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
-		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init"/>
-    
-    <bean id="dataSource"
-        class="org.apache.commons.dbcp2.BasicDataSource"
-        destroy-method="close">
-        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
-        <property name="url"
-            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
-        <property name="username" value="${db.username:root}" />
-        <property name="password" value="${db.password:}" />
-    </bean>
-
-    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
-    </bean>
-
-    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-</beans>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/SessionMapper.xml b/authentication/Client/src/main/resources/config/SessionMapper.xml
deleted file mode 100644
index 989e786..0000000
--- a/authentication/Client/src/main/resources/config/SessionMapper.xml
+++ /dev/null
@@ -1,57 +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.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
-    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
-        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
-    </sql>
-
-    <sql id="all_column_auto">
-        SESSION_ID, USER_NAME, ROLE_NAME
-    </sql>
-
-    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        insert into T_SESSION (
-        <include refid="all_column_auto" />
-        )
-        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
-        #{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getSessioinInfo" parameterType="java.lang.String"
-        resultMap="sessionInfo">
-        select
-        <include refid="all_column" />
-        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
-    </select>
-    
-    <update id="updateSessionInfo" parameterType="java.lang.String">
-        update T_SESSION
-        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
-    </update>
-</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/UserMapper.xml b/authentication/Client/src/main/resources/config/UserMapper.xml
deleted file mode 100644
index c02e60d..0000000
--- a/authentication/Client/src/main/resources/config/UserMapper.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.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
-    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, USER_NAME, PASSWORD, ROLE_NAME
-    </sql>
-
-    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        insert into T_USER (
-        <include refid="all_column" />
-        )
-        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
-        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getUserInfo" parameterType="java.lang.String"
-        resultMap="userInfo">
-        select
-        <include refid="all_column" />
-        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
-    </select>
-</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/create_db_user.sql b/authentication/Client/src/main/resources/config/create_db_user.sql
deleted file mode 100644
index a07c5d9..0000000
--- a/authentication/Client/src/main/resources/config/create_db_user.sql
+++ /dev/null
@@ -1,46 +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.
- */
-
-CREATE DATABASE IF NOT EXISTS porter_user_db;
-
-USE porter_user_db;
-
-DROP TABLE IF EXISTS T_USER;
-
-CREATE TABLE `T_USER` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  PRIMARY KEY (`ID`)
-);
-
-#### password is encrypted for test
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
-
-DROP TABLE IF EXISTS T_SESSION;
-
-CREATE TABLE `T_SESSION` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
-  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
-  PRIMARY KEY (`ID`)
-);
diff --git a/authentication/Client/src/main/resources/config/mybatis-config.xml b/authentication/Client/src/main/resources/config/mybatis-config.xml
deleted file mode 100644
index 894caac..0000000
--- a/authentication/Client/src/main/resources/config/mybatis-config.xml
+++ /dev/null
@@ -1,27 +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.
-  -->
-
-<!DOCTYPE configuration
-  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
-  "http://mybatis.org/dtd/mybatis-3-config.dtd">
-<configuration>
-    <mappers>
-        <mapper resource="config/UserMapper.xml"/>
-        <mapper resource="config/SessionMapper.xml"/>
-    </mappers>
-</configuration>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/microservice.yaml b/authentication/Client/src/main/resources/microservice.yaml
index 411b4c6..f19ca7b 100644
--- a/authentication/Client/src/main/resources/microservice.yaml
+++ b/authentication/Client/src/main/resources/microservice.yaml
@@ -22,8 +22,9 @@ servicecomb-config-order: 100
 APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
-  name: authentication-server
-
+  name: authentication-client
+  environment: development
+  
 servicecomb:
   service:
     registry:
@@ -32,4 +33,4 @@ servicecomb:
         watch: false
 
   rest:
-    address: 0.0.0.0:9092
+    address: 0.0.0.0:9093
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
index b188402..87837eb 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.gateway;
 
 import org.springframework.context.annotation.Bean;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
index a6817bf..bc270b8 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.authentication.util.Constants;
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
index 57adadd..662c971 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
@@ -1 +1,18 @@
+#
+# 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.
+#
+
 org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/Gateway/src/main/resources/microservice.yaml
index 8d926ee..2eda242 100644
--- a/authentication/Gateway/src/main/resources/microservice.yaml
+++ b/authentication/Gateway/src/main/resources/microservice.yaml
@@ -41,6 +41,7 @@ servicecomb:
         default: internalAccess,auth,qps-flowcontrol-consumer,loadbalance
         service:
           authentication-server: internalAccess,qps-flowcontrol-consumer,loadbalance
+          authentication-client: internalAccess,qps-flowcontrol-consumer,loadbalance
 
   uploads:
     directory: tmp_for_upload_gateway
diff --git a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
index bb737ba..e4b2151 100644
--- a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
+++ b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.test;
 
 import java.util.regex.Pattern;
diff --git a/authentication/README.md b/authentication/README.md
index 48798cd..3cd4217 100644
--- a/authentication/README.md
+++ b/authentication/README.md
@@ -2,6 +2,20 @@
 
 项目的目标是提供一个商业可用的鉴权实现,对于项目代码实现的问题可以提交issue,本项目也接纳PR,共同完善。
 
+
+
+## 实现说明
+
+* 用户管理
+用户管理采用了org.springframework.security.core.userdetails的模型,包括:
+  1. UserDetailsService:加载用户信息。
+  2. UserDetails:用户信息。
+  3. GrantedAuthority:角色信息。
+  4. PasswordEncoder:用户密码加密和匹配。
+  
+  
+## 项目结构介绍
+
 * AuthenticationServer
 
 认证鉴权服务。提供用户管理、角色管理。并提供登录认证、权限查询等接口。鉴权服务及相关API是核心交付件,也是能够被重用的部分。开发者可以基于这个项目开发认证鉴权服务。
@@ -15,12 +29,19 @@ Client模拟的是使用使用者。一方面演示客户端如何获取Token,
 * ResourceServer
 ResourceServer模拟的是业务服务。一方面演示业务服务如何进行权限配置,本项目也是自动化测试的组成部分。
 
+* Api
+认证鉴权提取的公共功能,作为复用单元。目前项目处于初始阶段,很多复用代码分散在其他项目中。
+
+
+* 测试介绍
+
+本项目实现了微服务架构的自动化测试。启动AuthenticationServer、Gateway、Client、ResourceServer后,可以提供
+
+```
+http://localhost:9093/v1/test/start
+```
+触发测试用例的执行。 所有的测试用例放到Client微服务里面, 这个微服务实现了简单的测试框架帮助书写测试用例,对测试结果进行检查等功能。 
+
+测试项目同时展示了这个项目的功能,比如: AuthenticationTestCase 的测试逻辑展示了基本的认证功能,从登陆,到接口的权限检查。 
 
-## 实现说明
 
-* 用户管理
-用户管理采用了org.springframework.security.core.userdetails的模型,包括:
-  1. UserDetailsService:加载用户信息。
-  2. UserDetails:用户信息。
-  3. GrantedAuthority:角色信息。
-  4. PasswordEncoder:用户密码加密和匹配。
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
index 136a11a..8167612 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.config.inject.InjectProperties;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
index c4cbd1e..c6ea891 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.resource;
 
 import java.util.Map;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
index 847550f..0e58c30 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.resource;
 
 import org.springframework.context.annotation.Bean;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
index 32256ad..347db46 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
index eea0968..e07745b 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
index fdfb3ad..800e52d 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.resource;
 
 import java.util.Set;
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
index a5db2c2..c62affc 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.jwt;
 
 import java.util.HashMap;
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
index 3b71a5c..54e26a5 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.jwt;
 
 public class JWTClaimsCommon {
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
index b4b1ae7..2cc797c 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.jwt;
 
 public class JWTHeader {
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
index 37e54d7..2a4bcd1 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.jwt;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
index a7427fa..96333aa 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
@@ -1,3 +1,20 @@
+/*
+ * 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.servicecomb.authentication.util;
 
 public final class Constants {


[servicecomb-samples] 26/32: reformat code with google java code style and add the Readme content

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit f0fbf8873bd223276d630e62554d193cce877e74
Author: alec.zheng <al...@gmail.com>
AuthorDate: Tue Jul 30 11:21:56 2019 +0800

    reformat code with google java code style and add the Readme content
---
 houserush/README.md               |  22 +++-
 houserush/customer-manage/pom.xml |  13 +-
 houserush/doc/pom.xml             |  20 +--
 houserush/gateway/pom.xml         | 106 ++++++++--------
 houserush/house-order/pom.xml     |  94 +++++++-------
 houserush/login/pom.xml           | 106 ++++++++--------
 houserush/pom.xml                 | 257 +++++++++++++++++++-------------------
 houserush/realestate/pom.xml      |  94 +++++++-------
 houserush/user-center/pom.xml     |  78 ++++++------
 9 files changed, 396 insertions(+), 394 deletions(-)

diff --git a/houserush/README.md b/houserush/README.md
index 105187f..57b81ee 100644
--- a/houserush/README.md
+++ b/houserush/README.md
@@ -1,2 +1,20 @@
-TODO
-# houserush todo
+### The business background of my planing project:
+Traditionally, a real estate developer in china will show their nearing completion buildings to the customers for a couple of days, then determine an open sale time for all customers to make real deal offline. Those customers have to get to sale place long before the open sale time and queue up,because only in this way they get the chances to pick the apartment which they like mostly. 
+So recently, more and more real estate developers begin to build an online apartments/houses open sale system. The e-commerce system help their customer to pick the houses more easily and more fairly. This is the system which I plan to build with ServiceComb.
+
+### Why I choose this project as a guiding sample of ServiceComb?
+Real estate developers use this system to make a deal with their customer online. So, yes! This is a real e-commerce system with real commercial value. But this is also a real simple e-commerce system which has no payment and shipping module. So Its simplicity is good for the guiding purpose. Meanwhile, because these trading subjects of this system are very expensive,and there will be high QPS when the open sale time just arrives. So There are high requirements for the system’s scalabili [...]
+
+### Requirements & Basic Setup
+1. Setup the requirements
+   - setup git, see [git install overview](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)
+   - setup JDK 1.8, see [JDK install overview](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html)
+   - setup Maven 3.x, 详情可参考[Maven install guide](https://maven.apache.org/install.html)
+2. Setup and run the service center
+   - setup Docker, see [Docker setup guide](https://www.docker.com/get-started)。
+   - input in the terminal <code>$ docker run -d -p 30100:30100 servicecomb/service-center:latest</code>run service-center at port 30100
+3. Setup the database
+
+4. check & change the src/main/resources/microservice.yaml and src/main/resources/application.yaml configuration file.
+
+5. run each microservice process by mvn spring-boot:run. 
\ No newline at end of file
diff --git a/houserush/customer-manage/pom.xml b/houserush/customer-manage/pom.xml
index 120d9f1..bab8767 100644
--- a/houserush/customer-manage/pom.xml
+++ b/houserush/customer-manage/pom.xml
@@ -23,35 +23,29 @@
     <groupId>org.apache.servicecomb.samples.practice</groupId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
+
   <modelVersion>4.0.0</modelVersion>
 
   <artifactId>houserush-customer-manage</artifactId>
   <name>Java Chassis::Samples::Practice::HouseRush-Customer-Manage</name>
 
-
-
   <dependencies>
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
     </dependency>
-
-
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-data-jpa</artifactId>
     </dependency>
-
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
     </dependency>
-
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>spring-boot-starter-provider</artifactId>
     </dependency>
-
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>handler-flowcontrol-qps</artifactId>
@@ -64,14 +58,10 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>handler-tracing-zipkin</artifactId>
     </dependency>
-
     <dependency>
       <groupId>mysql</groupId>
       <artifactId>mysql-connector-java</artifactId>
     </dependency>
-
-
-
   </dependencies>
 
   <build>
@@ -82,5 +72,4 @@
       </plugin>
     </plugins>
   </build>
-
 </project>
diff --git a/houserush/doc/pom.xml b/houserush/doc/pom.xml
index d153734..c3b6486 100644
--- a/houserush/doc/pom.xml
+++ b/houserush/doc/pom.xml
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <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/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>houserush</artifactId>
-        <groupId>org.apache.servicecomb.samples.practice</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>houserush-doc</artifactId>
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>houserush</artifactId>
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
 
+  <modelVersion>4.0.0</modelVersion>
 
+  <artifactId>houserush-doc</artifactId>
+  <name>Java Chassis::Samples::Practice::HouseRush-Doc</name>
 </project>
\ No newline at end of file
diff --git a/houserush/gateway/pom.xml b/houserush/gateway/pom.xml
index 4d45787..a0c2a7c 100644
--- a/houserush/gateway/pom.xml
+++ b/houserush/gateway/pom.xml
@@ -17,60 +17,60 @@
   -->
 
 <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/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>houserush</artifactId>
-        <groupId>org.apache.servicecomb.samples.practice</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>houserush</artifactId>
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>houserush-webapp</artifactId>
-    <name>Java Chassis::Samples::Practice::HouseRush-webapp</name>
+  <artifactId>houserush-webapp</artifactId>
+  <name>Java Chassis::Samples::Practice::HouseRush-webapp</name>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>transport-rest-vertx</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-boot-starter-servicecomb</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-boot-starter-discovery</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-cloud-zuul</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-cloud-zuul-zipkin</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.auth0</groupId>
-            <artifactId>java-jwt</artifactId>
-            <version>3.8.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-            <version>20180813</version>
-        </dependency>
-    </dependencies>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>transport-rest-vertx</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-servicecomb</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-discovery</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-cloud-zuul</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-cloud-zuul-zipkin</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.auth0</groupId>
+      <artifactId>java-jwt</artifactId>
+      <version>3.8.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.json</groupId>
+      <artifactId>json</artifactId>
+      <version>20180813</version>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/houserush/house-order/pom.xml b/houserush/house-order/pom.xml
index 46890ab..0864e00 100644
--- a/houserush/house-order/pom.xml
+++ b/houserush/house-order/pom.xml
@@ -17,54 +17,54 @@
   -->
 
 <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/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>houserush</artifactId>
-        <groupId>org.apache.servicecomb.samples.practice</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>houserush</artifactId>
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>houserush-house-order</artifactId>
-    <name>Java Chassis::Samples::Practice::HouseRush-House-Order</name>
+  <artifactId>houserush-house-order</artifactId>
+  <name>Java Chassis::Samples::Practice::HouseRush-House-Order</name>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-jpa</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-boot-starter-provider</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-flowcontrol-qps</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-bizkeeper</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-tracing-zipkin</artifactId>
-        </dependency>
-    </dependencies>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-data-jpa</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-provider</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-tracing-zipkin</artifactId>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/houserush/login/pom.xml b/houserush/login/pom.xml
index 4162f80..917993d 100644
--- a/houserush/login/pom.xml
+++ b/houserush/login/pom.xml
@@ -17,62 +17,58 @@
   -->
 
 <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/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>houserush</artifactId>
-        <groupId>org.apache.servicecomb.samples.practice</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>houserush</artifactId>
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>houserush-login</artifactId>
-    <name>Java Chassis::Samples::Practice::HouseRush-Login</name>
+  <artifactId>houserush-login</artifactId>
+  <name>Java Chassis::Samples::Practice::HouseRush-Login</name>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-jpa</artifactId>
-        </dependency>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-data-jpa</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-provider</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-tracing-zipkin</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+  </dependencies>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-boot-starter-provider</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-flowcontrol-qps</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-bizkeeper</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-tracing-zipkin</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/houserush/pom.xml b/houserush/pom.xml
index c6e1e1f..eeb3987 100644
--- a/houserush/pom.xml
+++ b/houserush/pom.xml
@@ -16,142 +16,141 @@
   -->
 
 <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/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
-    <groupId>org.apache.servicecomb.samples.practice</groupId>
-    <artifactId>houserush</artifactId>
-    <name>Java Chassis::Samples::practice::HouseRush</name>
-    <version>0.0.1-SNAPSHOT</version>
-    <packaging>pom</packaging>
+  <groupId>org.apache.servicecomb.samples.practice</groupId>
+  <artifactId>houserush</artifactId>
+  <name>Java Chassis::Samples::practice::HouseRush</name>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
 
-    <modules>
-        <module>customer-manage</module>
-        <module>login</module>
-        <module>realestate</module>
-        <module>house-order</module>
-        <module>user-center</module>
-        <module>gateway</module>
-        <module>doc</module>
-    </modules>
+  <modules>
+    <module>customer-manage</module>
+    <module>login</module>
+    <module>realestate</module>
+    <module>house-order</module>
+    <module>user-center</module>
+    <module>gateway</module>
+    <module>doc</module>
+  </modules>
 
-    <description>Quick Start Demo for Using ServiceComb Java Chassis</description>
+  <description>Quick Start Demo for Using ServiceComb Java Chassis</description>
 
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <java.version>1.8</java.version>
-        <java-chassis.version>1.2.1</java-chassis.version>
-        <spring-boot-1.version>1.5.14.RELEASE</spring-boot-1.version>
-    </properties>
-
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>org.apache.servicecomb</groupId>
-                <artifactId>java-chassis-dependencies</artifactId>
-                <version>${java-chassis.version}</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-dependencies</artifactId>
-                <version>${spring-boot-1.version}</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-starter</artifactId>
-                <version>${spring-boot-1.version}</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <!-- 用于连接mysql的相关依赖 -->
-            <dependency>
-                <groupId>mysql</groupId>
-                <artifactId>mysql-connector-java</artifactId>
-                <version>5.1.47</version>
-            </dependency>
-            <dependency>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-starter-data-rest</artifactId>
-                <version>${spring-boot-1.version}</version>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    <java.version>1.8</java.version>
+    <java-chassis.version>1.2.1</java-chassis.version>
+    <spring-boot-1.version>1.5.14.RELEASE</spring-boot-1.version>
+  </properties>
 
+  <dependencyManagement>
     <dependencies>
-        <dependency>
-            <groupId>org.hibernate.validator</groupId>
-            <artifactId>hibernate-validator</artifactId>
-            <version>6.1.0.Alpha5</version>
-        </dependency>
-        <dependency>
-            <groupId>javax.validation</groupId>
-            <artifactId>validation-api</artifactId>
-            <version>2.0.1.Final</version>
-        </dependency>
-        <dependency>
-            <groupId>org.projectlombok</groupId>
-            <artifactId>lombok</artifactId>
-            <version>1.16.10</version>
-        </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>${java-chassis.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-dependencies</artifactId>
+        <version>${spring-boot-1.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter</artifactId>
+        <version>${spring-boot-1.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.47</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-data-rest</artifactId>
+        <version>${spring-boot-1.version}</version>
+      </dependency>
     </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.hibernate.validator</groupId>
+      <artifactId>hibernate-validator</artifactId>
+      <version>6.1.0.Alpha5</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.validation</groupId>
+      <artifactId>validation-api</artifactId>
+      <version>2.0.1.Final</version>
+    </dependency>
+    <dependency>
+      <groupId>org.projectlombok</groupId>
+      <artifactId>lombok</artifactId>
+      <version>1.16.10</version>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-maven-plugin</artifactId>
-                    <version>2.0.1.RELEASE</version>
-                </plugin>
-            </plugins>
-        </pluginManagement>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.0.1.RELEASE</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
 
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.1</version>
-                <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.rat</groupId>
-                <artifactId>apache-rat-plugin</artifactId>
-                <version>0.13</version>
-                <configuration>
-                    <excludes>
-                        <exclude>.travis.yml</exclude>
-                        <exclude>**/*.md</exclude>
-                        <exclude>**/target/*</exclude>
-                        <!-- Skip the ssl configuration files -->
-                        <exculde>**/resources/ssl/**</exculde>
-                        <!-- Skip the protobuf files -->
-                        <exclude>**/*.proto</exclude>
-                        <!-- Skip the idl files -->
-                        <exclude>**/*.idl</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-    <repositories>
-        <repository>
-            <id>maven-apache-snapshot</id>
-            <name>Maven Apache Snapshot</name>
-            <url>https://repository.apache.org/content/groups/snapshots</url>
-            <releases>
-                <enabled>false</enabled>
-            </releases>
-            <snapshots>
-                <enabled>true</enabled>
-            </snapshots>
-        </repository>
-    </repositories>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <version>0.13</version>
+        <configuration>
+          <excludes>
+            <exclude>.travis.yml</exclude>
+            <exclude>**/*.md</exclude>
+            <exclude>**/target/*</exclude>
+            <!-- Skip the ssl configuration files -->
+            <exculde>**/resources/ssl/**</exculde>
+            <!-- Skip the protobuf files -->
+            <exclude>**/*.proto</exclude>
+            <!-- Skip the idl files -->
+            <exclude>**/*.idl</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <repositories>
+    <repository>
+      <id>maven-apache-snapshot</id>
+      <name>Maven Apache Snapshot</name>
+      <url>https://repository.apache.org/content/groups/snapshots</url>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
 </project>
diff --git a/houserush/realestate/pom.xml b/houserush/realestate/pom.xml
index e425b6a..c4f659d 100644
--- a/houserush/realestate/pom.xml
+++ b/houserush/realestate/pom.xml
@@ -17,55 +17,55 @@
   -->
 
 <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/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>houserush</artifactId>
-        <groupId>org.apache.servicecomb.samples.practice</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>houserush</artifactId>
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>houserush-realestate</artifactId>
-    <name>Java Chassis::Samples::Practice::HouseRush-Realestate</name>
+  <artifactId>houserush-realestate</artifactId>
+  <name>Java Chassis::Samples::Practice::HouseRush-Realestate</name>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-jpa</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-boot-starter-provider</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-flowcontrol-qps</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-bizkeeper</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-tracing-zipkin</artifactId>
-        </dependency>
-    </dependencies>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-data-jpa</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-provider</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-tracing-zipkin</artifactId>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>
diff --git a/houserush/user-center/pom.xml b/houserush/user-center/pom.xml
index 84718ac..52dc4f6 100644
--- a/houserush/user-center/pom.xml
+++ b/houserush/user-center/pom.xml
@@ -17,47 +17,47 @@
   -->
 
 <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/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>houserush</artifactId>
-        <groupId>org.apache.servicecomb.samples.practice</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>houserush</artifactId>
+    <groupId>org.apache.servicecomb.samples.practice</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>houserush-user-center</artifactId>
-    <name>Java Chassis::Samples::Practice::HouseRush-User-Center</name>
+  <artifactId>houserush-user-center</artifactId>
+  <name>Java Chassis::Samples::Practice::HouseRush-User-Center</name>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>spring-boot-starter-provider</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-flowcontrol-qps</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-bizkeeper</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.servicecomb</groupId>
-            <artifactId>handler-tracing-zipkin</artifactId>
-        </dependency>
-    </dependencies>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>spring-boot-starter-provider</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-tracing-zipkin</artifactId>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>


[servicecomb-samples] 27/32: change mysql to postgresql & add License && upgrade the spring-boot-maven-plugin version

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit db13c0f4febc97a59f58194f148d42bd7c08dfcc
Author: alec.zheng <al...@gmail.com>
AuthorDate: Tue Jul 30 16:50:11 2019 +0800

    change mysql to postgresql & add License && upgrade the spring-boot-maven-plugin version
---
 houserush/README.md               |  2 +-
 houserush/customer-manage/pom.xml |  4 ++--
 houserush/doc/pom.xml             | 22 +++++++++++++++++++---
 houserush/house-order/pom.xml     |  4 ++--
 houserush/login/pom.xml           |  4 ++--
 houserush/pom.xml                 |  8 ++++----
 houserush/realestate/pom.xml      |  4 ++--
 7 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/houserush/README.md b/houserush/README.md
index 57b81ee..9e514ba 100644
--- a/houserush/README.md
+++ b/houserush/README.md
@@ -17,4 +17,4 @@ Real estate developers use this system to make a deal with their customer online
 
 4. check & change the src/main/resources/microservice.yaml and src/main/resources/application.yaml configuration file.
 
-5. run each microservice process by mvn spring-boot:run. 
\ No newline at end of file
+5. run each microservice process <code>by mvn spring-boot:run. </code>
\ No newline at end of file
diff --git a/houserush/customer-manage/pom.xml b/houserush/customer-manage/pom.xml
index bab8767..fae8da0 100644
--- a/houserush/customer-manage/pom.xml
+++ b/houserush/customer-manage/pom.xml
@@ -59,8 +59,8 @@
       <artifactId>handler-tracing-zipkin</artifactId>
     </dependency>
     <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
     </dependency>
   </dependencies>
 
diff --git a/houserush/doc/pom.xml b/houserush/doc/pom.xml
index c3b6486..45ede77 100644
--- a/houserush/doc/pom.xml
+++ b/houserush/doc/pom.xml
@@ -1,6 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<!--
+  ~ 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/xsd/maven-4.0.0.xsd">
   <parent>
     <artifactId>houserush</artifactId>
@@ -12,4 +28,4 @@
 
   <artifactId>houserush-doc</artifactId>
   <name>Java Chassis::Samples::Practice::HouseRush-Doc</name>
-</project>
\ No newline at end of file
+</project>
diff --git a/houserush/house-order/pom.xml b/houserush/house-order/pom.xml
index 0864e00..9da545d 100644
--- a/houserush/house-order/pom.xml
+++ b/houserush/house-order/pom.xml
@@ -38,8 +38,8 @@
       <artifactId>spring-boot-starter-data-jpa</artifactId>
     </dependency>
     <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
diff --git a/houserush/login/pom.xml b/houserush/login/pom.xml
index 917993d..a1965ab 100644
--- a/houserush/login/pom.xml
+++ b/houserush/login/pom.xml
@@ -58,8 +58,8 @@
       <artifactId>handler-tracing-zipkin</artifactId>
     </dependency>
     <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
     </dependency>
   </dependencies>
 
diff --git a/houserush/pom.xml b/houserush/pom.xml
index eeb3987..e9462ee 100644
--- a/houserush/pom.xml
+++ b/houserush/pom.xml
@@ -69,9 +69,9 @@
         <scope>import</scope>
       </dependency>
       <dependency>
-        <groupId>mysql</groupId>
-        <artifactId>mysql-connector-java</artifactId>
-        <version>5.1.47</version>
+        <groupId>org.postgresql</groupId>
+        <artifactId>postgresql</artifactId>
+        <version>42.2.6</version>
       </dependency>
       <dependency>
         <groupId>org.springframework.boot</groupId>
@@ -105,7 +105,7 @@
         <plugin>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-maven-plugin</artifactId>
-          <version>2.0.1.RELEASE</version>
+          <version>2.1.6.RELEASE</version>
         </plugin>
       </plugins>
     </pluginManagement>
diff --git a/houserush/realestate/pom.xml b/houserush/realestate/pom.xml
index c4f659d..df586d8 100644
--- a/houserush/realestate/pom.xml
+++ b/houserush/realestate/pom.xml
@@ -38,8 +38,8 @@
       <artifactId>spring-boot-starter-data-jpa</artifactId>
     </dependency>
     <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>


[servicecomb-samples] 05/32: fix config error

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 635f740ca47559b53a882b49a4990bd057b69607
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Mar 8 15:59:54 2019 +0800

    fix config error
---
 .../file-service/src/main/resources/microservice.yaml               | 2 +-
 porter_lightweight/gateway-service/pom.xml                          | 4 ----
 .../gateway-service/src/main/resources/microservice.yaml            | 6 ------
 .../user-service/src/main/resources/microservice.yaml               | 2 +-
 4 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/porter_lightweight/file-service/src/main/resources/microservice.yaml b/porter_lightweight/file-service/src/main/resources/microservice.yaml
index 44654c4..dc4a845 100644
--- a/porter_lightweight/file-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/file-service/src/main/resources/microservice.yaml
@@ -28,7 +28,7 @@ service_description:
 servicecomb:
   service:
     registry:
-      address: http://localhost:30120
+      address: http://localhost:30100
       instance:
         watch: false
 
diff --git a/porter_lightweight/gateway-service/pom.xml b/porter_lightweight/gateway-service/pom.xml
index c0188fa..252935e 100644
--- a/porter_lightweight/gateway-service/pom.xml
+++ b/porter_lightweight/gateway-service/pom.xml
@@ -42,10 +42,6 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>edge-core</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>metrics-core</artifactId>
-    </dependency>
   </dependencies>
   <build>
     <plugins>
diff --git a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
index a3edac1..3bb50fa 100644
--- a/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/gateway-service/src/main/resources/microservice.yaml
@@ -42,12 +42,6 @@ servicecomb:
   uploads:
     directory: tmp_for_upload_gateway
 
-  accesslog:
-    enabled: true
-  metrics:
-    window_time: 30000
-    publisher.defaultLog.enabled: true
-
 servicecomb.http.dispatcher.edge.default.enabled: false
 servicecomb.http.dispatcher.rest.enabled: false
 gateway.webroot: /code/servicecomb-samples/porter_lightweight/gateway-service/src/main/resources
diff --git a/porter_lightweight/user-service/src/main/resources/microservice.yaml b/porter_lightweight/user-service/src/main/resources/microservice.yaml
index 9c25055..5daaea5 100644
--- a/porter_lightweight/user-service/src/main/resources/microservice.yaml
+++ b/porter_lightweight/user-service/src/main/resources/microservice.yaml
@@ -27,7 +27,7 @@ service_description:
 servicecomb:
   service:
     registry:
-      address: http://localhost:30120
+      address: http://localhost:30100
       instance:
         watch: false
 


[servicecomb-samples] 32/32: Merge pull request #13 from alec-z/new_houserush_sample

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit e11f3f977b4f5870e3294428844c66e2402cca4c
Merge: a868bac 5aee0ac
Author: Mabin <bi...@huawei.com>
AuthorDate: Wed Aug 7 11:18:56 2019 +0800

    Merge pull request #13 from alec-z/new_houserush_sample
    
    Add the one of 6 micro-services: House-Order

 houserush/README.md                                |   2 +-
 houserush/house-order/README.md                    |  95 ++++++++++++++
 .../houserush/sale/HouseOrderApplication.java      |  43 +++++++
 .../practise/houserush/sale/HouseOrderConfig.java  |  26 ++++
 .../houserush/sale/aggregate/HouseOrder.java       |  59 +++++++++
 .../practise/houserush/sale/aggregate/Sale.java    |  71 +++++++++++
 .../practise/houserush/sale/api/HouseOrderApi.java |  39 ++++++
 .../houserush/sale/api/HouseOrderApiRestImpl.java  |  75 +++++++++++
 .../practise/houserush/sale/dao/HouseOrderDao.java |  38 ++++++
 .../practise/houserush/sale/dao/SaleDao.java       |  24 ++++
 .../houserush/sale/rpc/CustomerManageApi.java      |  26 ++++
 .../practise/houserush/sale/rpc/RealestateApi.java |  29 +++++
 .../practise/houserush/sale/rpc/po/Customer.java   |  31 +++++
 .../practise/houserush/sale/rpc/po/House.java      |  27 ++++
 .../houserush/sale/rpc/po/Qualification.java       |  27 ++++
 .../practise/houserush/sale/rpc/po/Realestate.java |  27 ++++
 .../houserush/sale/service/HouseOrderService.java  |  39 ++++++
 .../sale/service/HouseOrderServiceImpl.java        | 141 +++++++++++++++++++++
 .../src/main/resources/microservice.yaml           |  48 +++++++
 19 files changed, 866 insertions(+), 1 deletion(-)


[servicecomb-samples] 15/32: authentication: add tokens logic

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 3a458c2f13a88491b29f1f2794d495f84965a283
Author: liubao <ba...@huawei.com>
AuthorDate: Wed May 8 17:49:16 2019 +0800

    authentication: add tokens logic
---
 authentication/AuthenticationServer/pom.xml        |  9 +++
 .../AuthenticationConfiguration.java               | 28 ++++++++
 .../service/AuthenticationServiceImpl.java         | 45 ++++++++----
 .../servicecomb/authentication/user/Role.java      |  5 ++
 .../servicecomb/authentication/user/User.java      | 11 +++
 .../servicecomb/authentication/user/UserStore.java |  5 ++
 .../servicecomb/authentication/api/Token.java      | 76 +++++++++++++++++---
 .../servicecomb/authentication/jwt/JWTClaims.java  | 45 ++++++++++++
 .../authentication/jwt/JWTClaimsCommon.java        | 83 ++++++++++++++++++++++
 .../servicecomb/authentication/jwt/JWTHeader.java  | 25 +++++++
 .../servicecomb/authentication/jwt/JsonParser.java | 23 ++++++
 11 files changed, 330 insertions(+), 25 deletions(-)

diff --git a/authentication/AuthenticationServer/pom.xml b/authentication/AuthenticationServer/pom.xml
index 0c7a295..baaac03 100644
--- a/authentication/AuthenticationServer/pom.xml
+++ b/authentication/AuthenticationServer/pom.xml
@@ -47,6 +47,11 @@
         <version>0.0.1-SNAPSHOT</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.servicecomb</groupId>
         <artifactId>java-chassis-dependencies</artifactId>
         <version>1.2.0</version>
@@ -77,6 +82,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
       <artifactId>authentication-server-api-endpoint</artifactId>
     </dependency>
     <dependency>
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
new file mode 100644
index 0000000..77a6342
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
@@ -0,0 +1,28 @@
+package org.apache.servicecomb.authentication;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+@Configuration
+public class AuthenticationConfiguration {
+  @Bean(name = "authPasswordEncoder")
+  private PasswordEncoder authPasswordEncoder() {
+    return new PasswordEncoder() {
+
+      @Override
+      public String encode(CharSequence rawPassword) {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      @Override
+      public boolean matches(CharSequence rawPassword, String encodedPassword) {
+        // TODO Auto-generated method stub
+        return false;
+      }
+      
+    };
+  }
+  
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
index be46f5c..a6e856a 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
@@ -19,34 +19,49 @@ package org.apache.servicecomb.authentication.service;
 
 import org.apache.servicecomb.authentication.api.AuthenticationService;
 import org.apache.servicecomb.authentication.api.Token;
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
+import org.apache.servicecomb.authentication.user.User;
+import org.apache.servicecomb.authentication.user.UserStore;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+import org.springframework.security.jwt.crypto.sign.Signer;
 import org.springframework.stereotype.Service;
 
 @Service
 public class AuthenticationServiceImpl implements AuthenticationService {
   @Autowired
-  @Qualifier("userDetailsService")
-  private UserDetailsService userDetailsService;
-  
+  @Qualifier("authUserStore")
+  private UserStore userStore;
+
   @Autowired
-  @Qualifier("passwordEncoder")
+  @Qualifier("authPasswordEncoder")
   private PasswordEncoder passwordEncoder;
 
+  @Autowired
+  @Qualifier("authSigner")
+  private Signer signer;
+
   @Override
   public Token login(String userName, String password) {
-    UserDetails userDetails;
-    try {
-      userDetails = userDetailsService.loadUserByUsername(userName);
-    } catch (UsernameNotFoundException e) {
-      return null;
-    }
-    if(passwordEncoder.matches(password, userDetails.getPassword())) {
-      return null;
+    User user = userStore.loadUserByUsername(userName);
+    if (passwordEncoder.matches(password, user.getPassword())) {
+      JWTClaims claims = new JWTClaims();
+      if (user.getRoles() != null) {
+        user.getRoles().forEach(role -> claims.addRole(role.getRoleName()));
+      }
+      claims.setScope("read");
+      String content = JsonParser.unparse(claims);
+      Jwt accessToken = JwtHelper.encode(content, signer);
+
+      Token token = new Token();
+      token.setExpires_in(10 * 60);
+      token.setToken_type("bearer");
+      token.setAccess_token(accessToken.getEncoded());
+      return token;
     } else {
       return null;
     }
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
new file mode 100644
index 0000000..393cd3e
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
@@ -0,0 +1,5 @@
+package org.apache.servicecomb.authentication.user;
+
+public interface Role {
+  String getRoleName();
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
new file mode 100644
index 0000000..b0ba017
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
@@ -0,0 +1,11 @@
+package org.apache.servicecomb.authentication.user;
+
+import java.util.Collection;
+
+public interface User {
+  Collection<Role> getRoles();
+
+  String getPassword();
+
+  String getUsername();
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
new file mode 100644
index 0000000..5bd8459
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
@@ -0,0 +1,5 @@
+package org.apache.servicecomb.authentication.user;
+
+public interface UserStore {
+  User loadUserByUsername(String userName);
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
index 732fe22..94ce237 100644
--- a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
@@ -17,24 +17,80 @@
 
 package org.apache.servicecomb.authentication.api;
 
+import java.util.Map;
+import java.util.Set;
+
 public class Token {
-  private String accessToken;
+  // Naming conventions https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.1
+  private String token_type;
+
+  private String access_token;
+
+  private String refresh_token;
+
+  private int expires_in;
+
+  private Set<String> scope;
+
+  // JWT id
+  private String jti;
+
+  private Map<String, Object> additionalInformation;
 
-  private String refreshToken;
+  public String getToken_type() {
+    return token_type;
+  }
+
+  public void setToken_type(String token_type) {
+    this.token_type = token_type;
+  }
+
+  public String getAccess_token() {
+    return access_token;
+  }
+
+  public void setAccess_token(String access_token) {
+    this.access_token = access_token;
+  }
 
-  public String getAccessToken() {
-    return accessToken;
+  public String getRefresh_token() {
+    return refresh_token;
   }
 
-  public void setAccessToken(String accessToken) {
-    this.accessToken = accessToken;
+  public void setRefresh_token(String refresh_token) {
+    this.refresh_token = refresh_token;
   }
 
-  public String getRefreshToken() {
-    return refreshToken;
+  public int getExpires_in() {
+    return expires_in;
   }
 
-  public void setRefreshToken(String refreshToken) {
-    this.refreshToken = refreshToken;
+  public void setExpires_in(int expires_in) {
+    this.expires_in = expires_in;
   }
+
+  public Set<String> getScope() {
+    return scope;
+  }
+
+  public void setScope(Set<String> scope) {
+    this.scope = scope;
+  }
+
+  public String getJti() {
+    return jti;
+  }
+
+  public void setJti(String jti) {
+    this.jti = jti;
+  }
+
+  public Map<String, Object> getAdditionalInformation() {
+    return additionalInformation;
+  }
+
+  public void setAdditionalInformation(Map<String, Object> additionalInformation) {
+    this.additionalInformation = additionalInformation;
+  }
+
 }
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
new file mode 100644
index 0000000..569b4da
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
@@ -0,0 +1,45 @@
+package org.apache.servicecomb.authentication.jwt;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+public class JWTClaims extends JWTClaimsCommon {
+  protected Set<String> roles = Collections.emptySet();
+
+  protected Map<String, Object> additionalInformation = Collections.emptyMap();
+
+  /**
+   * The scope of the access token as described by <a
+   * href="http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.3">Section 3.3</a>
+   */
+  protected String scope;
+
+  public Set<String> getRoles() {
+    return roles;
+  }
+
+  public void setRoles(Set<String> roles) {
+    this.roles = roles;
+  }
+
+  public Map<String, Object> getAdditionalInformation() {
+    return additionalInformation;
+  }
+
+  public void setAdditionalInformation(Map<String, Object> additionalInformation) {
+    this.additionalInformation = additionalInformation;
+  }
+
+  public String getScope() {
+    return scope;
+  }
+
+  public void setScope(String scope) {
+    this.scope = scope;
+  }
+
+  public void addRole(String role) {
+    this.roles.add(role);
+  }
+}
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
new file mode 100644
index 0000000..3b71a5c
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
@@ -0,0 +1,83 @@
+package org.apache.servicecomb.authentication.jwt;
+
+public class JWTClaimsCommon {
+  // see: https://tools.ietf.org/html/rfc7519
+  // (Issuer) Claim
+  protected String iss;
+
+  // (Subject) Claim
+  protected String sub;
+
+  // (Audience) Claim
+  protected String aud;
+
+  // (Expiration Time) Claim
+  protected long exp;
+
+  // (Not Before) Claim
+  protected long nbf;
+
+  // (Issued At) Claim
+  protected long iat;
+
+  // (JWT ID) Claim
+  protected String jti;
+
+  public String getIss() {
+    return iss;
+  }
+
+  public void setIss(String iss) {
+    this.iss = iss;
+  }
+
+  public String getSub() {
+    return sub;
+  }
+
+  public void setSub(String sub) {
+    this.sub = sub;
+  }
+
+  public String getAud() {
+    return aud;
+  }
+
+  public void setAud(String aud) {
+    this.aud = aud;
+  }
+
+  public long getExp() {
+    return exp;
+  }
+
+  public void setExp(long exp) {
+    this.exp = exp;
+  }
+
+  public long getNbf() {
+    return nbf;
+  }
+
+  public void setNbf(long nbf) {
+    this.nbf = nbf;
+  }
+
+  public long getIat() {
+    return iat;
+  }
+
+  public void setIat(long iat) {
+    this.iat = iat;
+  }
+
+  public String getJti() {
+    return jti;
+  }
+
+  public void setJti(String jti) {
+    this.jti = jti;
+  }
+
+
+}
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
new file mode 100644
index 0000000..b4b1ae7
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
@@ -0,0 +1,25 @@
+package org.apache.servicecomb.authentication.jwt;
+
+public class JWTHeader {
+  private String typ;
+
+  private String alg;
+
+  public String getTyp() {
+    return typ;
+  }
+
+  public void setTyp(String typ) {
+    this.typ = typ;
+  }
+
+  public String getAlg() {
+    return alg;
+  }
+
+  public void setAlg(String alg) {
+    this.alg = alg;
+  }
+
+
+}
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
new file mode 100644
index 0000000..37e54d7
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
@@ -0,0 +1,23 @@
+package org.apache.servicecomb.authentication.jwt;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class JsonParser {
+  private static final ObjectMapper MAPPER = new ObjectMapper();
+
+  public static <T> T parse(String json, Class<T> clazz) {
+    try {
+      return MAPPER.readValue(json, clazz);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Cannot parse json", e);
+    }
+  }
+
+  public static <T> String unparse(T obj) {
+    try {
+      return MAPPER.writeValueAsString(obj);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Cannot unparse json", e);
+    }
+  }
+}


[servicecomb-samples] 04/32: spell and add license notice

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 1136c1fe13bb517b0c90888854faf50f8627f6a8
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Mar 8 15:27:47 2019 +0800

    spell and add license notice
---
 LICENSE                      | 217 +++++++++++++++++++++++++++++++++++++++++++
 NOTICE                       |   5 +
 porter_lightweight/README.md |   8 +-
 3 files changed, 226 insertions(+), 4 deletions(-)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a22797d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,217 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   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.
+
+=======================================================================
+Apache ServiceComb Java Chassis Subcomponents:
+
+The Apache ServiceComb Java Chassis project contains subcomponents with
+separate copyright notices and license terms. Your use of the source
+for these subcomponents is subject to the terms and conditions of the
+following licenses.
+
+
+================================================================
+For porter_lightweight/gateway-service/src/main/resources/ui/js/jquery-1.11.1.min.js
+================================================================
+This product bundles files from jquery which is licensed under the MIT License.
+For details, see https://github.com/jquery/jquery/blob/master/LICENSE.txt
+
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..d463439
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,5 @@
+Apache ServiceComb Samples
+Copyright 2017-2018 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/porter_lightweight/README.md b/porter_lightweight/README.md
index ef8c671..9870398 100644
--- a/porter_lightweight/README.md
+++ b/porter_lightweight/README.md
@@ -1,4 +1,4 @@
-This project shows how to using java-chassis and service-center to create a simple microservice application. It shows basic authentication and authorization, uploading files and delte files operations.
+This project shows how to using java-chassis and service-center to create a simple microservice application. It shows basic authentication and authorization, uploading files and delete files operations.
 
 ## build and run
 
@@ -24,9 +24,9 @@ java $JAVA_OPT -Ddb.url="jdbc:mysql://localhost/porter_user_db?useSSL=false" -Dd
 java $JAVA_OPT -jar porter-file-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
 ```
 
-* run gateway-serivce:
+* run gateway-service:
 
-gateway-service contains static webpages in resources/ui. First copy to web root folder,e.g webapp, which is relative to working directory. 
+gateway-service contains static web pages in resources/ui. First copy to web root folder,e.g webapp, which is relative to working directory. 
 
 ```
 java $JAVA_OPT -Dgateway.webroot=webapp -jar porter-gateway-service-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
@@ -35,7 +35,7 @@ java $JAVA_OPT -Dgateway.webroot=webapp -jar porter-gateway-service-0.0.1-SNAPSH
 ## Try it
 
 1. Using browser: http://localhost:9090/ui/login.html with user admin or guest to login, password is test.
-2. Choose a file to upload. Uploaded file is stored in file-service workding directory. And name is random number generated. 
+2. Choose a file to upload. Uploaded file is stored in file-service working directory. And name is random number generated. 
 3. Delete file. Input the random number generated in step 2. 
 
 


[servicecomb-samples] 31/32: change the exception message from chinese to english

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 5aee0aca415b271afcb9fb751cf1c0cd3b5ee791
Author: alec.zheng <al...@gmail.com>
AuthorDate: Tue Aug 6 18:40:23 2019 +0800

    change the exception message from chinese to english
---
 .../practise/houserush/sale/service/HouseOrderServiceImpl.java       | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java
index eeed043..e2dfd3c 100644
--- a/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java
+++ b/houserush/house-order/src/main/java/org/apache/servicecomb/samples/practise/houserush/sale/service/HouseOrderServiceImpl.java
@@ -84,7 +84,6 @@ public class HouseOrderServiceImpl implements HouseOrderService {
 
     if (null != houseOrder) {
       if (null == houseOrder.getCustomerId()) {
-        Customer customer = customerManageApi.findCustomer(customerId);
         int qualificationsCount = customerManageApi.getQualificationsCount(customerId, sale.getId());
 
         int ordersCount = houseOrderDao.countByCustomerIdAndSaleId(customerId, sale.getId());
@@ -99,10 +98,10 @@ public class HouseOrderServiceImpl implements HouseOrderService {
         houseOrderDao.save(houseOrder);
         return houseOrder;
       } else {
-        throw new InvocationException(400, "", "该住宅已被其他人选购,请选择其他房产。");
+        throw new InvocationException(400, "", "this house have been occupied first by other customer, please choose another house or try it later.");
       }
     } else {
-      throw new InvocationException(400, "", "选择的房产不在此次抢购活动中");
+      throw new InvocationException(400, "", "this house which you chose does not belong to the current sale.");
     }
   }
 


[servicecomb-samples] 16/32: authentication: add gateway & resource server logic

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 3a10a7b7503a3e73e5f292f0c447494bc27b3c41
Author: liubao <ba...@huawei.com>
AuthorDate: Thu May 9 19:15:26 2019 +0800

    authentication: add gateway & resource server logic
---
 .../AuthenticationConfiguration.java               | 48 ++++++++++-----
 .../service/AuthenticationServiceImpl.java         | 18 +++---
 .../main/resources/META-INF/spring/user.bean.xml   | 64 +++++---------------
 .../src/main/resources/config/SessionMapper.xml    | 57 ------------------
 .../src/main/resources/config/UserMapper.xml       | 46 --------------
 .../src/main/resources/config/create_db_user.sql   | 46 --------------
 .../src/main/resources/microservice.yaml           |  1 +
 authentication/Gateway/pom.xml                     | 50 +++++++++++-----
 .../gateway/ApiDispatcher.java                     |  2 +-
 .../gateway/AuthHandler.java                       | 21 ++++++-
 .../gateway/AuthenticationConfiguration.java       | 14 +++++
 .../gateway}/AuthenticationEndpoint.java           | 13 ++--
 .../gateway/AuthenticationFilter.java              | 30 ++++++++++
 .../gateway/CustomVertxRestDispatcher.java         |  6 +-
 .../gateway/EdgeSSLCustom.java                     |  2 +-
 .../gateway/GatewayMain.java                       |  2 +-
 .../gateway/InternalAccessHandler.java             |  2 +-
 .../gateway/StaticWebpageDispatcher.java           |  2 +-
 ...servicecomb.common.rest.filter.HttpServerFilter |  1 +
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  6 +-
 .../src/main/resources/config/cse.handler.xml      |  4 +-
 .../Gateway/src/main/resources/microservice.yaml   |  3 +
 .../authentication/test/PatternTest.java           | 19 ++++++
 authentication/ResourceServer/pom.xml              | 18 ++++++
 .../resource/AccessConfiguration.java              | 20 +++++++
 .../resource/AccessConfigurationManager.java       | 19 ++++++
 .../resource/AuthenticationConfiguration.java      | 14 +++++
 .../resource/HandlerAuthEndpoint.java              | 29 +++++++++
 .../resource/PreMethodAuthEndpoint.java            | 33 ++++++++++
 .../resource/ResourceAuthHandler.java              | 70 ++++++++++++++++++++++
 .../spring/{user.bean.xml => resource.bean.xml}    | 26 --------
 .../src/main/resources/config/SessionMapper.xml    | 57 ------------------
 .../src/main/resources/config/UserMapper.xml       | 46 --------------
 .../src/main/resources/config/create_db_user.sql   | 46 --------------
 .../src/main/resources/config/cse.handler.xml}     | 14 ++---
 .../src/main/resources/config/mybatis-config.xml   | 27 ---------
 .../src/main/resources/microservice.yaml           | 18 +++++-
 .../authentication/api/AuthenticationEndpoint.java |  5 +-
 authentication/api/common/service/pom.xml          | 25 ++++++++
 .../servicecomb/authentication/jwt/JWTClaims.java  | 42 +++++++++----
 .../servicecomb/authentication/util/Constants.java |  9 +++
 41 files changed, 493 insertions(+), 482 deletions(-)

diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
index 77a6342..5840fc3 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
@@ -1,28 +1,46 @@
 package org.apache.servicecomb.authentication;
 
+import java.util.Arrays;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
+import org.springframework.security.jwt.crypto.sign.MacSigner;
+import org.springframework.security.jwt.crypto.sign.Signer;
+import org.springframework.security.provisioning.InMemoryUserDetailsManager;
 
 @Configuration
 public class AuthenticationConfiguration {
+  @Autowired
+  @Qualifier("authPasswordEncoder")
+  private PasswordEncoder passwordEncoder;
+
   @Bean(name = "authPasswordEncoder")
-  private PasswordEncoder authPasswordEncoder() {
-    return new PasswordEncoder() {
+  public PasswordEncoder authPasswordEncoder() {
+    return new Pbkdf2PasswordEncoder();
+  }
 
-      @Override
-      public String encode(CharSequence rawPassword) {
-        // TODO Auto-generated method stub
-        return null;
-      }
+  @Bean(name = "authSigner")
+  public Signer authSigner() {
+    return new MacSigner("Please change this key.");
+  }
 
-      @Override
-      public boolean matches(CharSequence rawPassword, String encodedPassword) {
-        // TODO Auto-generated method stub
-        return false;
-      }
-      
-    };
+  @Bean(name = "authUserDetailsService")
+  public UserDetailsService authUserDetailsService() {
+    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
+    UserDetails uAdmin = new User("admin", passwordEncoder.encode("changeMyPassword"),
+        Arrays.asList(new SimpleGrantedAuthority("ADMIN")));
+    UserDetails uGuest = new User("guest", passwordEncoder.encode("changeMyPassword"),
+        Arrays.asList(new SimpleGrantedAuthority("GUEST")));
+    manager.createUser(uAdmin);
+    manager.createUser(uGuest);
+    return manager;
   }
-  
 }
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
index a6e856a..cfbe22b 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
@@ -21,10 +21,10 @@ import org.apache.servicecomb.authentication.api.AuthenticationService;
 import org.apache.servicecomb.authentication.api.Token;
 import org.apache.servicecomb.authentication.jwt.JWTClaims;
 import org.apache.servicecomb.authentication.jwt.JsonParser;
-import org.apache.servicecomb.authentication.user.User;
-import org.apache.servicecomb.authentication.user.UserStore;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.jwt.Jwt;
 import org.springframework.security.jwt.JwtHelper;
@@ -34,8 +34,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class AuthenticationServiceImpl implements AuthenticationService {
   @Autowired
-  @Qualifier("authUserStore")
-  private UserStore userStore;
+  @Qualifier("authUserDetailsService")
+  private UserDetailsService userDetailsService;
 
   @Autowired
   @Qualifier("authPasswordEncoder")
@@ -47,17 +47,17 @@ public class AuthenticationServiceImpl implements AuthenticationService {
 
   @Override
   public Token login(String userName, String password) {
-    User user = userStore.loadUserByUsername(userName);
-    if (passwordEncoder.matches(password, user.getPassword())) {
+    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
+    if (passwordEncoder.matches(password, userDetails.getPassword())) {
       JWTClaims claims = new JWTClaims();
-      if (user.getRoles() != null) {
-        user.getRoles().forEach(role -> claims.addRole(role.getRoleName()));
+      if (userDetails.getAuthorities() != null) {
+        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
       }
-      claims.setScope("read");
       String content = JsonParser.unparse(claims);
       Jwt accessToken = JwtHelper.encode(content, signer);
 
       Token token = new Token();
+      token.setScope(claims.getScope());
       token.setExpires_in(10 * 60);
       token.setToken_type("bearer");
       token.setAccess_token(accessToken.getEncoded());
diff --git a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
index 661608f..b33e5c9 100644
--- a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
+++ b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
@@ -1,56 +1,24 @@
 <?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.
-  -->
+<!-- ~ 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:p="http://www.springframework.org/schema/p"
-    xmlns:util="http://www.springframework.org/schema/util"
-    xmlns:context="http://www.springframework.org/schema/context"
-    xmlns:tx="http://www.springframework.org/schema/tx"
-    xsi:schemaLocation="
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+  xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:tx="http://www.springframework.org/schema/tx"
+  xsi:schemaLocation="
 		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
   <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init"/>
-    
-    <bean id="dataSource"
-        class="org.apache.commons.dbcp2.BasicDataSource"
-        destroy-method="close">
-        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
-        <property name="url"
-            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
-        <property name="username" value="${db.username:root}" />
-        <property name="password" value="${db.password:}" />
-    </bean>
-
-    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
-    </bean>
-
-    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
+    init-method="init" />
 </beans>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
deleted file mode 100644
index 989e786..0000000
--- a/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
+++ /dev/null
@@ -1,57 +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.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
-    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
-        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
-    </sql>
-
-    <sql id="all_column_auto">
-        SESSION_ID, USER_NAME, ROLE_NAME
-    </sql>
-
-    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        insert into T_SESSION (
-        <include refid="all_column_auto" />
-        )
-        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
-        #{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getSessioinInfo" parameterType="java.lang.String"
-        resultMap="sessionInfo">
-        select
-        <include refid="all_column" />
-        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
-    </select>
-    
-    <update id="updateSessionInfo" parameterType="java.lang.String">
-        update T_SESSION
-        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
-    </update>
-</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml
deleted file mode 100644
index c02e60d..0000000
--- a/authentication/AuthenticationServer/src/main/resources/config/UserMapper.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.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
-    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, USER_NAME, PASSWORD, ROLE_NAME
-    </sql>
-
-    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        insert into T_USER (
-        <include refid="all_column" />
-        )
-        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
-        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getUserInfo" parameterType="java.lang.String"
-        resultMap="userInfo">
-        select
-        <include refid="all_column" />
-        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
-    </select>
-</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql b/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
deleted file mode 100644
index a07c5d9..0000000
--- a/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
+++ /dev/null
@@ -1,46 +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.
- */
-
-CREATE DATABASE IF NOT EXISTS porter_user_db;
-
-USE porter_user_db;
-
-DROP TABLE IF EXISTS T_USER;
-
-CREATE TABLE `T_USER` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  PRIMARY KEY (`ID`)
-);
-
-#### password is encrypted for test
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
-
-DROP TABLE IF EXISTS T_SESSION;
-
-CREATE TABLE `T_SESSION` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
-  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
-  PRIMARY KEY (`ID`)
-);
diff --git a/authentication/AuthenticationServer/src/main/resources/microservice.yaml b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
index 1e6b0af..dfedc0f 100644
--- a/authentication/AuthenticationServer/src/main/resources/microservice.yaml
+++ b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
@@ -23,6 +23,7 @@ APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
   name: authentication-server
+  environment: development
 
 servicecomb:
   service:
diff --git a/authentication/Gateway/pom.xml b/authentication/Gateway/pom.xml
index 9223b6b..932669e 100644
--- a/authentication/Gateway/pom.xml
+++ b/authentication/Gateway/pom.xml
@@ -1,19 +1,14 @@
-<!--
-  ~ 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.
-  -->
+<!-- ~ 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/xsd/maven-4.0.0.xsd">
@@ -37,11 +32,29 @@
         <type>pom</type>
         <scope>import</scope>
       </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-service</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
@@ -53,6 +66,11 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>edge-core</artifactId>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
index e801ebd..9f45550 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import java.util.Map;
 
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
similarity index 55%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
index 7119753..d6b879a 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
@@ -15,17 +15,34 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
+import org.apache.servicecomb.authentication.util.Constants;
 import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+import org.springframework.security.jwt.crypto.sign.InvalidSignatureException;
 
 
 public class AuthHandler implements Handler {
   @Override
   public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception {
-    // TODO check session
+    String token = invocation.getContext(Constants.CONTEXT_HEADER_AUTHORIZATION);
+    if (token == null) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
+    Jwt jwt = JwtHelper.decode(token);
+    try {
+      jwt.verifySignature(BeanUtils.getBean("authSigner"));
+    } catch (InvalidSignatureException e) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
     invocation.next(asyncResponse);
   }
 }
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
new file mode 100644
index 0000000..b188402
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
@@ -0,0 +1,14 @@
+package org.apache.servicecomb.authentication.gateway;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.jwt.crypto.sign.MacSigner;
+import org.springframework.security.jwt.crypto.sign.Signer;
+
+@Configuration
+public class AuthenticationConfiguration {
+  @Bean(name = "authSigner")
+  public Signer authSigner() {
+    return new MacSigner("Please change this key.");
+  }
+}
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
similarity index 74%
copy from authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
copy to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
index dfc9c51..021b337 100644
--- a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
@@ -15,24 +15,29 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.gateway;
 
+import org.apache.servicecomb.authentication.api.AuthenticationService;
+import org.apache.servicecomb.authentication.api.Token;
+import org.apache.servicecomb.provider.pojo.RpcReference;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
 @RestSchema(schemaId = "AuthenticationEndpoint")
-@RequestMapping(path = "/v1/auth/login")
+@RequestMapping(path = "/v1/auth")
 public class AuthenticationEndpoint {
-  @Autowired
+  @RpcReference(microserviceName = "authentication-server", schemaId = "AuthenticationEndpoint")
   private AuthenticationService authenticationService;
 
+  @PostMapping(path = "login")
   public Token login(@RequestParam(name = "userName") String userName,
       @RequestParam(name = "password") String password) {
     return authenticationService.login(userName, password);
   }
 
+  @PostMapping(path = "refresh")
   public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
     return authenticationService.refresh(refreshToken);
   }
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
new file mode 100644
index 0000000..a6817bf
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
@@ -0,0 +1,30 @@
+package org.apache.servicecomb.authentication.gateway;
+
+import org.apache.servicecomb.authentication.util.Constants;
+import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.swagger.invocation.Response;
+
+public class AuthenticationFilter implements HttpServerFilter {
+
+  @Override
+  public int getOrder() {
+    return 0;
+  }
+
+  @Override
+  public Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx) {
+    String authentication = requestEx.getHeader(Constants.HTTP_HEADER_AUTHORIZATION);
+    if (authentication != null) {
+      String[] tokens = authentication.split(" ");
+      if (tokens.length == 2) {
+        if (tokens[0].equals("Bearer")) {
+          invocation.addContext(Constants.CONTEXT_HEADER_AUTHORIZATION, tokens[1]);
+        }
+      }
+    }
+    return null;
+  }
+
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
similarity index 98%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
index a2941be..8d7472f 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
@@ -44,7 +44,7 @@ import io.vertx.ext.web.Router;
 import io.vertx.ext.web.RoutingContext;
 import io.vertx.ext.web.handler.CookieHandler;
 
-// copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher
+// copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher 1.2.0
 public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
   private static final Logger LOGGER = LoggerFactory.getLogger(VertxRestDispatcher.class);
 
@@ -62,7 +62,7 @@ public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
 
   @Override
   public void init(Router router) {
-    String regex = "[/v1/log/|/inspector|/v1/auth](.*)";
+    String regex = "(/v1/log|/inspector|/v1/auth)/(.*)";
     router.routeWithRegex(regex).handler(CookieHandler.create());
     router.routeWithRegex(regex).handler(createBodyHandler());
     router.routeWithRegex(regex).failureHandler(this::failureHandler).handler(this::onRequest);
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
similarity index 95%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
index 159c10d..0fb1268 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import java.io.File;
 
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
similarity index 94%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
index a219d2d..862e6c3 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
index 0b181d8..e05f867 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
index 791c512..555ddc4 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher;
 import org.slf4j.Logger;
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
new file mode 100644
index 0000000..57adadd
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
@@ -0,0 +1 @@
+org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index bada1de..cb82ded 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -15,6 +15,6 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
-org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
-org.apache.servicecomb.samples.porter.gateway.CustomVertxRestDispatcher
\ No newline at end of file
+org.apache.servicecomb.authentication.gateway.ApiDispatcher
+org.apache.servicecomb.authentication.gateway.StaticWebpageDispatcher
+org.apache.servicecomb.authentication.gateway.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/config/cse.handler.xml b/authentication/Gateway/src/main/resources/config/cse.handler.xml
index e9dd306..b39da71 100644
--- a/authentication/Gateway/src/main/resources/config/cse.handler.xml
+++ b/authentication/Gateway/src/main/resources/config/cse.handler.xml
@@ -17,7 +17,7 @@
 
 <config>
   <handler id="auth"
-    class="org.apache.servicecomb.samples.porter.gateway.AuthHandler" />
+    class="org.apache.servicecomb.authentication.gateway.AuthHandler" />
   <handler id="internalAccess"
-    class="org.apache.servicecomb.samples.porter.gateway.InternalAccessHandler" />
+    class="org.apache.servicecomb.authentication.gateway.InternalAccessHandler" />
 </config>
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/Gateway/src/main/resources/microservice.yaml
index 5b1cd91..8d926ee 100644
--- a/authentication/Gateway/src/main/resources/microservice.yaml
+++ b/authentication/Gateway/src/main/resources/microservice.yaml
@@ -23,6 +23,7 @@ APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
   name: gateway
+  environment: development
 
 servicecomb:
   service:
@@ -38,6 +39,8 @@ servicecomb:
     chain:
       Consumer:
         default: internalAccess,auth,qps-flowcontrol-consumer,loadbalance
+        service:
+          authentication-server: internalAccess,qps-flowcontrol-consumer,loadbalance
 
   uploads:
     directory: tmp_for_upload_gateway
diff --git a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
new file mode 100644
index 0000000..bb737ba
--- /dev/null
+++ b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
@@ -0,0 +1,19 @@
+package org.apache.servicecomb.authentication.test;
+
+import java.util.regex.Pattern;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class PatternTest {
+  @Test
+  public void testPattern() {
+    String regex = "(/v1/log|/inspector|/v1/auth)/(.*)";
+    Pattern p = Pattern.compile(regex);
+    Assert.assertTrue(p.matcher("/v1/log/login").matches());
+    Assert.assertTrue(p.matcher("/inspector/login").matches());
+    Assert.assertTrue(p.matcher("/v1/auth/login").matches());
+    Assert.assertTrue(!p.matcher("/api/v1/auth/login").matches());
+  }
+}
diff --git a/authentication/ResourceServer/pom.xml b/authentication/ResourceServer/pom.xml
index 52aea79..baeb56a 100644
--- a/authentication/ResourceServer/pom.xml
+++ b/authentication/ResourceServer/pom.xml
@@ -27,6 +27,16 @@
   <dependencyManagement>
     <dependencies>
       <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-service</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>org.mybatis</groupId>
         <artifactId>mybatis</artifactId>
         <version>3.4.5</version>
@@ -53,6 +63,14 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
new file mode 100644
index 0000000..136a11a
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
@@ -0,0 +1,20 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.config.inject.InjectProperties;
+import org.apache.servicecomb.config.inject.InjectProperty;
+
+@InjectProperties(prefix = "servicecomb.authencation.access")
+public class AccessConfiguration {
+  @InjectProperty(keys = {
+      "needAuth.${schemaId}.${operationId}",
+      "needAuth.${schemaId}",
+      "needAuth"},
+      defaultValue = "true")
+  public boolean needAuth;
+
+  @InjectProperty(keys = {
+      "roles.${schemaId}.${operationId}",
+      "roles.${schemaId}",
+      "roles"})
+  public String roles;
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
new file mode 100644
index 0000000..c4cbd1e
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
@@ -0,0 +1,19 @@
+package org.apache.servicecomb.authentication.resource;
+
+import java.util.Map;
+
+import org.apache.servicecomb.config.inject.ConfigObjectFactory;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+
+public class AccessConfigurationManager {
+  private static final Map<String, AccessConfiguration> CONFIGURATIONS = new ConcurrentHashMapEx<>();
+
+  private static final ConfigObjectFactory FACTORY = new ConfigObjectFactory();
+
+  public static AccessConfiguration getAccessConfiguration(Invocation invocation) {
+    return CONFIGURATIONS.computeIfAbsent(invocation.getOperationMeta().getSchemaQualifiedName(), key -> {
+      return FACTORY.create(AccessConfiguration.class, "schemaId", invocation.getSchemaId(), "operationId", invocation.getOperationName());
+    });
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
new file mode 100644
index 0000000..847550f
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
@@ -0,0 +1,14 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.jwt.crypto.sign.MacSigner;
+import org.springframework.security.jwt.crypto.sign.Signer;
+
+@Configuration
+public class AuthenticationConfiguration {
+  @Bean(name = "authSigner")
+  public Signer authSigner() {
+    return new MacSigner("Please change this key.");
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
new file mode 100644
index 0000000..32256ad
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
@@ -0,0 +1,29 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestSchema(schemaId = "HandlerAuthEndpoint")
+@RequestMapping(path = "/v1/auth/handler")
+public class HandlerAuthEndpoint {
+  @PostMapping(path = "/adminSayHello")
+  public String adminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestSayHello")
+  public String guestSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestOrAdminSayHello")
+  public String guestOrAdminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/everyoneSayHello")
+  public String everyoneSayHello(String name) {
+    return name;
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
new file mode 100644
index 0000000..eea0968
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
@@ -0,0 +1,33 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestSchema(schemaId = "PreMethodAuthEndpoint")
+@RequestMapping(path = "/v1/auth/method")
+public class PreMethodAuthEndpoint {
+  @PostMapping(path = "/adminSayHello")
+  @PreAuthorize("hasRole('ADMIN')")
+  public String adminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestSayHello")
+  @PreAuthorize("hasRole('USER')")
+  public String guestSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestOrAdminSayHello")
+  @PreAuthorize("hasRole('USER,ADMIN')")
+  public String guestOrAdminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/everyoneSayHello")
+  public String everyoneSayHello(String name) {
+    return name;
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
new file mode 100644
index 0000000..fdfb3ad
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
@@ -0,0 +1,70 @@
+package org.apache.servicecomb.authentication.resource;
+
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
+import org.apache.servicecomb.authentication.util.Constants;
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+
+public class ResourceAuthHandler implements Handler {
+
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception {
+    AccessConfiguration config = AccessConfigurationManager.getAccessConfiguration(invocation);
+
+    // by pass authentication
+    if (!config.needAuth) {
+      invocation.next(asyncResponse);
+      return;
+    }
+
+    String token = invocation.getContext(Constants.CONTEXT_HEADER_AUTHORIZATION);
+    if (token == null) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
+    // verify tokens
+    Jwt jwt = JwtHelper.decode(token);
+    JWTClaims claims;
+    try {
+      jwt.verifySignature(BeanUtils.getBean("authSigner"));
+      claims = JsonParser.parse(jwt.getClaims(), JWTClaims.class);
+      // TODO: verify claims.
+    } catch (Exception e) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
+
+    // check roles
+    if (!StringUtils.isEmpty(config.roles)) {
+      String[] roles = config.roles.split(",");
+      if (roles.length > 0) {
+        boolean valid = false;
+        Set<String> authorities = claims.getAuthorities();
+        for (String role : roles) {
+          if (authorities.contains(role)) {
+            valid = true;
+            break;
+          }
+        }
+        if (!valid) {
+          asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+          return;
+        }
+      }
+    }
+
+    // pre method authentiation
+    invocation.addLocalContext(Constants.CONTEXT_HEADER_CLAIMS, jwt.getClaims());
+    invocation.next(asyncResponse);
+  }
+
+}
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
similarity index 58%
rename from authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
rename to authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
index 661608f..fd84e44 100644
--- a/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
+++ b/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
@@ -27,30 +27,4 @@
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
   <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
     init-method="init"/>
-    
-    <bean id="dataSource"
-        class="org.apache.commons.dbcp2.BasicDataSource"
-        destroy-method="close">
-        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
-        <property name="url"
-            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
-        <property name="username" value="${db.username:root}" />
-        <property name="password" value="${db.password:}" />
-    </bean>
-
-    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
-    </bean>
-
-    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
 </beans>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml b/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
deleted file mode 100644
index 989e786..0000000
--- a/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
+++ /dev/null
@@ -1,57 +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.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
-    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
-        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
-    </sql>
-
-    <sql id="all_column_auto">
-        SESSION_ID, USER_NAME, ROLE_NAME
-    </sql>
-
-    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        insert into T_SESSION (
-        <include refid="all_column_auto" />
-        )
-        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
-        #{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getSessioinInfo" parameterType="java.lang.String"
-        resultMap="sessionInfo">
-        select
-        <include refid="all_column" />
-        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
-    </select>
-    
-    <update id="updateSessionInfo" parameterType="java.lang.String">
-        update T_SESSION
-        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
-    </update>
-</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/UserMapper.xml b/authentication/ResourceServer/src/main/resources/config/UserMapper.xml
deleted file mode 100644
index c02e60d..0000000
--- a/authentication/ResourceServer/src/main/resources/config/UserMapper.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.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
-    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, USER_NAME, PASSWORD, ROLE_NAME
-    </sql>
-
-    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        insert into T_USER (
-        <include refid="all_column" />
-        )
-        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
-        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getUserInfo" parameterType="java.lang.String"
-        resultMap="userInfo">
-        select
-        <include refid="all_column" />
-        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
-    </select>
-</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/create_db_user.sql b/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
deleted file mode 100644
index a07c5d9..0000000
--- a/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
+++ /dev/null
@@ -1,46 +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.
- */
-
-CREATE DATABASE IF NOT EXISTS porter_user_db;
-
-USE porter_user_db;
-
-DROP TABLE IF EXISTS T_USER;
-
-CREATE TABLE `T_USER` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  PRIMARY KEY (`ID`)
-);
-
-#### password is encrypted for test
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
-
-DROP TABLE IF EXISTS T_SESSION;
-
-CREATE TABLE `T_SESSION` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
-  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
-  PRIMARY KEY (`ID`)
-);
diff --git a/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml b/authentication/ResourceServer/src/main/resources/config/cse.handler.xml
similarity index 71%
rename from authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
rename to authentication/ResourceServer/src/main/resources/config/cse.handler.xml
index 894caac..0efe6d1 100644
--- a/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
+++ b/authentication/ResourceServer/src/main/resources/config/cse.handler.xml
@@ -1,4 +1,3 @@
-<?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
@@ -16,12 +15,7 @@
   ~ limitations under the License.
   -->
 
-<!DOCTYPE configuration
-  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
-  "http://mybatis.org/dtd/mybatis-3-config.dtd">
-<configuration>
-    <mappers>
-        <mapper resource="config/UserMapper.xml"/>
-        <mapper resource="config/SessionMapper.xml"/>
-    </mappers>
-</configuration>
\ No newline at end of file
+<config>
+  <handler id="resource-auth-provider"
+    class="org.apache.servicecomb.authentication.resource.ResourceAuthHandler" />
+</config>
diff --git a/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml b/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
deleted file mode 100644
index 894caac..0000000
--- a/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
+++ /dev/null
@@ -1,27 +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.
-  -->
-
-<!DOCTYPE configuration
-  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
-  "http://mybatis.org/dtd/mybatis-3-config.dtd">
-<configuration>
-    <mappers>
-        <mapper resource="config/UserMapper.xml"/>
-        <mapper resource="config/SessionMapper.xml"/>
-    </mappers>
-</configuration>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/microservice.yaml b/authentication/ResourceServer/src/main/resources/microservice.yaml
index 47b05c1..69b0ffc 100644
--- a/authentication/ResourceServer/src/main/resources/microservice.yaml
+++ b/authentication/ResourceServer/src/main/resources/microservice.yaml
@@ -23,7 +23,8 @@ APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
   name: resource-server
-
+  environment: development
+  
 servicecomb:
   service:
     registry:
@@ -33,3 +34,18 @@ servicecomb:
 
   rest:
     address: 0.0.0.0:9092
+
+  authencation:
+    access:
+      needAuth: true
+      roles:
+        HandlerAuthEndpoint:
+          adminSayHello: ADMIN
+          guestSayHello: GUEST
+          guestOrAdminSayHello: ADMIN,GUEST
+          # everyoneSayHello: all can
+
+  handler:
+    chain:
+      Provider:
+        default: qps-flowcontrol-provider,resource-auth-provider
\ No newline at end of file
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
index dfc9c51..5177aeb 100644
--- a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
@@ -19,20 +19,23 @@ package org.apache.servicecomb.authentication.api;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
 @RestSchema(schemaId = "AuthenticationEndpoint")
-@RequestMapping(path = "/v1/auth/login")
+@RequestMapping(path = "/v1/auth")
 public class AuthenticationEndpoint {
   @Autowired
   private AuthenticationService authenticationService;
 
+  @PostMapping(path = "login")
   public Token login(@RequestParam(name = "userName") String userName,
       @RequestParam(name = "password") String password) {
     return authenticationService.login(userName, password);
   }
 
+  @PostMapping(path = "refresh")
   public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
     return authenticationService.refresh(refreshToken);
   }
diff --git a/authentication/api/common/service/pom.xml b/authentication/api/common/service/pom.xml
index 538be70..66c5f90 100644
--- a/authentication/api/common/service/pom.xml
+++ b/authentication/api/common/service/pom.xml
@@ -28,4 +28,29 @@
   <artifactId>authentication-common-api-service</artifactId>
   <packaging>jar</packaging>
 
+ <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.springframework.security.oauth</groupId>
+        <artifactId>spring-security-oauth2</artifactId>
+        <version>2.3.2.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.security</groupId>
+        <artifactId>spring-security-jwt</artifactId>
+        <version>1.0.7.RELEASE</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.security.oauth</groupId>
+      <artifactId>spring-security-oauth2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.security</groupId>
+      <artifactId>spring-security-jwt</artifactId>
+    </dependency>
+  </dependencies>
 </project>
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
index 569b4da..a5db2c2 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
@@ -1,26 +1,27 @@
 package org.apache.servicecomb.authentication.jwt;
 
-import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 public class JWTClaims extends JWTClaimsCommon {
-  protected Set<String> roles = Collections.emptySet();
+  protected Set<String> authorities;
 
-  protected Map<String, Object> additionalInformation = Collections.emptyMap();
+  protected Map<String, Object> additionalInformation;
 
   /**
    * The scope of the access token as described by <a
    * href="http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.3">Section 3.3</a>
    */
-  protected String scope;
+  protected Set<String> scope;
 
-  public Set<String> getRoles() {
-    return roles;
+  public Set<String> getAuthorities() {
+    return authorities;
   }
 
-  public void setRoles(Set<String> roles) {
-    this.roles = roles;
+  public void setAuthorities(Set<String> authorities) {
+    this.authorities = authorities;
   }
 
   public Map<String, Object> getAdditionalInformation() {
@@ -31,15 +32,32 @@ public class JWTClaims extends JWTClaimsCommon {
     this.additionalInformation = additionalInformation;
   }
 
-  public String getScope() {
+  public Set<String> getScope() {
     return scope;
   }
 
-  public void setScope(String scope) {
+  public void setScope(Set<String> scope) {
     this.scope = scope;
   }
 
-  public void addRole(String role) {
-    this.roles.add(role);
+  public void addAdditionalInformation(String key, Object value) {
+    if (this.additionalInformation == null) {
+      this.additionalInformation = new HashMap<>();
+    }
+    this.additionalInformation.put(key, value);
+  }
+
+  public void addScope(String operation) {
+    if (this.scope == null) {
+      this.scope = new HashSet<>();
+    }
+    this.scope.add(operation);
+  }
+
+  public void addAuthority(String authority) {
+    if (this.authorities == null) {
+      this.authorities = new HashSet<>();
+    }
+    this.authorities.add(authority);
   }
 }
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
new file mode 100644
index 0000000..a7427fa
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
@@ -0,0 +1,9 @@
+package org.apache.servicecomb.authentication.util;
+
+public final class Constants {
+  public static final String HTTP_HEADER_AUTHORIZATION = "Authorization";
+
+  public static final String CONTEXT_HEADER_AUTHORIZATION = "Authorization";
+  
+  public static final String CONTEXT_HEADER_CLAIMS = "Claims";
+}


[servicecomb-samples] 19/32: add method security support

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 79409fb0d66c20c93645fa5e48d392d4a6b4078d
Author: liubao <ba...@huawei.com>
AuthorDate: Mon May 13 15:47:46 2019 +0800

    add method security support
---
 ...onServer.java => AuthenticationServerMain.java} |  2 +-
 .../{Client.java => AuthenticationClientMain.java} |  2 +-
 .../authentication/AuthenticationTestCase.java     | 52 +++++++++++++++
 .../authentication/BootEventListener.java          |  4 ++
 .../servicecomb/authentication/TestEndpoint.java   | 12 ++--
 .../apache/servicecomb/authentication/TestMgr.java | 13 ++++
 ...wayMain.java => AuthenticationGatewayMain.java} |  2 +-
 ...ResourceServer.java => ResourceServerMain.java} |  2 +-
 ...eptionExceptionToProducerResponseConverter.java | 39 +++++++++++
 .../resource/MethodSecurityConfiguration.java      | 36 ++++++++++
 .../resource/PreMethodAuthEndpoint.java            |  2 +-
 .../resource/ResourceAuthHandler.java              | 16 ++++-
 .../resource/SimpleAuthentication.java             | 77 ++++++++++++++++++++++
 ....exception.ExceptionToProducerResponseConverter | 18 +++++
 14 files changed, 267 insertions(+), 10 deletions(-)

diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
similarity index 96%
rename from authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java
rename to authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
index f38125a..35b239d 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
@@ -19,7 +19,7 @@ package org.apache.servicecomb.authentication;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
-public class AuthenticationServer {
+public class AuthenticationServerMain {
   public static void main(String[] args) {
     try {
       BeanUtils.init();
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
similarity index 96%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java
rename to authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
index 4ba1070..ce9c356 100644
--- a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
@@ -19,7 +19,7 @@ package org.apache.servicecomb.authentication;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
-public class Client {
+public class AuthenticationClientMain {
   public static void main(String[] args) {
     try {
       BeanUtils.init();
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
index 1bae5c3..61ba97f 100644
--- a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
@@ -30,6 +30,12 @@ import org.springframework.web.client.HttpClientErrorException;
 public class AuthenticationTestCase implements TestCase {
   @Override
   public void run() {
+    testHanlderAuth();
+    testMethodAuth();
+  }
+
+
+  private void testHanlderAuth() {
     // get token
     MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
     map.add("userName", "admin");
@@ -75,4 +81,50 @@ public class AuthenticationTestCase implements TestCase {
     TestMgr.check(null, name);
   }
 
+
+  private void testMethodAuth() {
+    // get token
+    MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
+    map.add("userName", "admin");
+    map.add("password", "changeMyPassword");
+    HttpHeaders headers = new HttpHeaders();
+    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
+
+    Token token =
+        BootEventListener.gateEndpoint.postForObject("/v1/auth/login",
+            new HttpEntity<>(map, headers),
+            Token.class);
+    TestMgr.check("bearer", token.getToken_type());
+    TestMgr.check(true, token.getAccess_token().length() > 10);
+
+    // get resources
+    headers = new HttpHeaders();
+    headers.add("Authorization", "Bearer " + token.getAccess_token());
+    headers.setContentType(MediaType.APPLICATION_JSON);
+    String name;
+    name = BootEventListener.resouceServerMethodAuthEndpoint.postForObject("/everyoneSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerMethodAuthEndpoint.postForObject("/adminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerMethodAuthEndpoint.postForObject("/guestOrAdminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = null;
+    try {
+      name = BootEventListener.resouceServerMethodAuthEndpoint.postForObject("/guestSayHello?name=Hi",
+          new HttpEntity<>(headers),
+          String.class);
+    } catch (HttpClientErrorException e) {
+      TestMgr.check(403, e.getStatusCode().value());
+    }
+    TestMgr.check(null, name);
+  }
 }
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
index 2af0a55..5512f8c 100644
--- a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
@@ -25,6 +25,8 @@ public class BootEventListener implements BootListener {
   public static GateRestTemplate authenticationServerAuthenticationEndpoint;
   public static GateRestTemplate gateEndpoint;
   public static GateRestTemplate resouceServerHandlerAuthEndpoint;
+  public static GateRestTemplate resouceServerMethodAuthEndpoint;
+  
   @Override
   public void onBootEvent(BootEvent event) {
     if (EventType.AFTER_REGISTRY.equals(event.getEventType())) {
@@ -34,6 +36,8 @@ public class BootEventListener implements BootListener {
           GateRestTemplate.createEdgeRestTemplate("gateway", null, null).init();
       resouceServerHandlerAuthEndpoint =
           GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "HandlerAuthEndpoint").init();
+      resouceServerMethodAuthEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "PreMethodAuthEndpoint").init();
     }
 
   }
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
index 04c3927..19b0af1 100644
--- a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
@@ -29,19 +29,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
 public class TestEndpoint {
   @Autowired
   private List<TestCase> tests;
-  
+
   @GetMapping(path = "/start")
   public String start() {
     tests.forEach(test -> test.run());
-    
+
     List<Throwable> errors = TestMgr.errors();
-    if (errors.isEmpty()) {
-      return "success";
+    if (TestMgr.isSuccess()) {
+      return TestMgr.successMessage();
     } else {
+      TestMgr.summary();
+
       StringBuilder sb = new StringBuilder();
       sb.append("Failed count : " + errors.size());
       sb.append("\n");
       errors.forEach(t -> sb.append(t.getMessage() + "\n"));
+      
+      TestMgr.reset();
       return sb.toString();
     }
   }
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
index 6b53045..030bb4c 100644
--- a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
@@ -19,6 +19,7 @@ package org.apache.servicecomb.authentication;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,6 +32,8 @@ public class TestMgr {
 
   private static String msg = "";
 
+  private static AtomicLong checksCount = new AtomicLong();
+
   public static void setMsg(String msg) {
     TestMgr.msg = msg;
   }
@@ -44,6 +47,7 @@ public class TestMgr {
   }
 
   public static void check(Object expect, Object real, Throwable error) {
+    checksCount.incrementAndGet();
     if (expect == real) {
       return;
     }
@@ -90,6 +94,15 @@ public class TestMgr {
     }
   }
 
+  public static void reset() {
+    errorList.clear();
+    checksCount.set(0);
+  }
+
+  public static String successMessage() {
+    return "Success. Checkes = " + checksCount.get();
+  }
+
   public static List<Throwable> errors() {
     return errorList;
   }
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java
index 862e6c3..be15a24 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java
@@ -19,7 +19,7 @@ package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
-public class GatewayMain {
+public class AuthenticationGatewayMain {
     public static void main(String[] args) throws Exception {
         BeanUtils.init();
     }
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java
similarity index 96%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java
rename to authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java
index f2653ab..5aae72f 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java
@@ -19,7 +19,7 @@ package org.apache.servicecomb.authentication;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
-public class ResourceServer {
+public class ResourceServerMain {
   public static void main(String[] args) {
     try {
       BeanUtils.init();
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
new file mode 100644
index 0000000..c2decce
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
@@ -0,0 +1,39 @@
+/*
+ * 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.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
+import org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.security.access.AccessDeniedException;
+
+public class AccessDeniedExceptionExceptionToProducerResponseConverter
+    implements ExceptionToProducerResponseConverter<AccessDeniedException> {
+
+  @Override
+  public Class<AccessDeniedException> getExceptionClass() {
+    return AccessDeniedException.class;
+  }
+
+  @Override
+  public Response convert(SwaggerInvocation swaggerInvocation, AccessDeniedException e) {
+    return Response.failResp(new InvocationException(403, "forbidden", "not authenticated"));
+  }
+
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java
new file mode 100644
index 0000000..58df6a9
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.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.servicecomb.authentication.resource;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
+import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
+
+@Configuration
+@EnableGlobalMethodSecurity(
+    prePostEnabled = true)
+public class MethodSecurityConfiguration extends GlobalMethodSecurityConfiguration {
+  @Override
+  protected MethodSecurityExpressionHandler createExpressionHandler() {
+    DefaultMethodSecurityExpressionHandler h = (DefaultMethodSecurityExpressionHandler) super.createExpressionHandler();
+    h.setDefaultRolePrefix("");
+    return h;
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
index e07745b..668f774 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
@@ -38,7 +38,7 @@ public class PreMethodAuthEndpoint {
   }
 
   @PostMapping(path = "/guestOrAdminSayHello")
-  @PreAuthorize("hasRole('USER,ADMIN')")
+  @PreAuthorize("hasAnyRole('USER','ADMIN')")
   public String guestOrAdminSayHello(String name) {
     return name;
   }
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
index 800e52d..37de72d 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
@@ -17,6 +17,7 @@
 
 package org.apache.servicecomb.authentication.resource;
 
+import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.commons.lang3.StringUtils;
@@ -28,6 +29,12 @@ import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.apache.servicecomb.swagger.invocation.AsyncResponse;
 import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.context.SecurityContextImpl;
 import org.springframework.security.jwt.Jwt;
 import org.springframework.security.jwt.JwtHelper;
 
@@ -80,7 +87,14 @@ public class ResourceAuthHandler implements Handler {
     }
 
     // pre method authentiation
-    invocation.addLocalContext(Constants.CONTEXT_HEADER_CLAIMS, jwt.getClaims());
+    Set<GrantedAuthority> grantedAuthorities = new HashSet<>(claims.getAuthorities().size());
+    claims.getAuthorities().forEach(v -> grantedAuthorities.add(new SimpleGrantedAuthority(v)));
+    SecurityContext sc = new SecurityContextImpl();
+    Authentication authentication = new SimpleAuthentication(true, grantedAuthorities);
+    sc.setAuthentication(authentication);
+    SecurityContextHolder.setContext(sc);
+
+    // next
     invocation.next(asyncResponse);
   }
 
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
new file mode 100644
index 0000000..a23404c
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
@@ -0,0 +1,77 @@
+/*
+ * 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.servicecomb.authentication.resource;
+
+import java.util.Collection;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+
+public class SimpleAuthentication implements Authentication {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 6077733273349249822L;
+
+  private boolean authenticated;
+
+  private Collection<? extends GrantedAuthority> authorities;
+
+  public SimpleAuthentication(boolean authenticated, Collection<? extends GrantedAuthority> authorities) {
+    this.authenticated = authenticated;
+    this.authorities = authorities;
+  }
+
+
+  @Override
+  public String getName() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public Collection<? extends GrantedAuthority> getAuthorities() {
+    return this.authorities;
+  }
+
+  @Override
+  public Object getCredentials() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public Object getDetails() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public Object getPrincipal() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public boolean isAuthenticated() {
+    return this.authenticated;
+  }
+
+  @Override
+  public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
+    throw new UnsupportedOperationException();
+  }
+
+}
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter b/authentication/ResourceServer/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
new file mode 100644
index 0000000..e6ad477
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.authentication.resource.AccessDeniedExceptionExceptionToProducerResponseConverter
\ No newline at end of file


[servicecomb-samples] 14/32: authentication: initial project commit

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mabin pushed a commit to branch houserush-sample
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git

commit 0991cc9ae8cc873ee939140f0809dc07d6340210
Author: liubao <ba...@huawei.com>
AuthorDate: Wed May 8 14:25:29 2019 +0800

    authentication: initial project commit
---
 authentication/AuthenticationServer/pom.xml        | 155 ++++++++++++++++
 .../authentication/AuthenticationServer.java       |  30 +++
 .../service/AuthenticationServiceImpl.java         |  60 ++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 ++++++
 .../src/main/resources/config/SessionMapper.xml    |  57 ++++++
 .../src/main/resources/config/UserMapper.xml       |  46 +++++
 .../src/main/resources/config/create_db_user.sql   |  46 +++++
 .../src/main/resources/config/mybatis-config.xml   |  27 +++
 .../src/main/resources/log4j2.xml                  |  43 +++++
 .../src/main/resources/microservice.yaml           |  35 ++++
 authentication/Client/pom.xml                      | 128 +++++++++++++
 .../apache/servicecomb/authentication/Client.java  |  30 +++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 ++++++
 .../src/main/resources/config/SessionMapper.xml    |  57 ++++++
 .../src/main/resources/config/UserMapper.xml       |  46 +++++
 .../src/main/resources/config/create_db_user.sql   |  46 +++++
 .../src/main/resources/config/mybatis-config.xml   |  27 +++
 .../Client/src/main/resources/log4j2.xml           |  43 +++++
 .../Client/src/main/resources/microservice.yaml    |  35 ++++
 authentication/Gateway/pom.xml                     |  88 +++++++++
 .../samples/porter/gateway/ApiDispatcher.java      |  68 +++++++
 .../samples/porter/gateway/AuthHandler.java        |  31 ++++
 .../porter/gateway/CustomVertxRestDispatcher.java  | 196 ++++++++++++++++++++
 .../samples/porter/gateway/EdgeSSLCustom.java      |  38 ++++
 .../samples/porter/gateway/GatewayMain.java        |  26 +++
 .../porter/gateway/InternalAccessHandler.java      |  37 ++++
 .../porter/gateway/StaticWebpageDispatcher.java    |  52 ++++++
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  20 ++
 .../main/resources/META-INF/spring/cse.bean.xml    |  27 +++
 .../src/main/resources/config/cse.handler.xml      |  23 +++
 .../Gateway/src/main/resources/log4j2.xml          |  43 +++++
 .../Gateway/src/main/resources/microservice.yaml   |  67 +++++++
 .../Gateway/src/main/resources/ui/css/style.css    |  49 +++++
 .../src/main/resources/ui/js/jquery-1.11.1.min.js  |   4 +
 .../Gateway/src/main/resources/ui/js/login.js      |  52 ++++++
 .../Gateway/src/main/resources/ui/js/upload.js     |  63 +++++++
 .../Gateway/src/main/resources/ui/login.html       |  45 +++++
 .../Gateway/src/main/resources/ui/upload.html      |  61 ++++++
 authentication/README.md                           |  26 +++
 authentication/ResourceServer/pom.xml              | 128 +++++++++++++
 .../servicecomb/authentication/ResourceServer.java |  30 +++
 .../authentication/resource/FileEndpoint.java      |  45 +++++
 .../authentication/resource/FileStoreService.java  |  31 ++++
 .../resource/LocalFileStoreService.java            |  64 +++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 ++++++
 .../src/main/resources/config/SessionMapper.xml    |  57 ++++++
 .../src/main/resources/config/UserMapper.xml       |  46 +++++
 .../src/main/resources/config/create_db_user.sql   |  46 +++++
 .../src/main/resources/config/mybatis-config.xml   |  27 +++
 .../ResourceServer/src/main/resources/log4j2.xml   |  43 +++++
 .../src/main/resources/microservice.yaml           |  35 ++++
 .../api/AuthenticationServer/endpoint/pom.xml      |  38 ++++
 .../authentication/api/AuthenticationEndpoint.java |  39 ++++
 authentication/api/AuthenticationServer/pom.xml    |  36 ++++
 .../api/AuthenticationServer/service/pom.xml       |  31 ++++
 .../authentication/api/AuthenticationService.java  |  35 ++++
 .../servicecomb/authentication/api/Token.java      |  40 ++++
 .../servicecomb/authentication/api/Tokens.java     |  48 +++++
 authentication/api/common/endpoint/pom.xml         |  38 ++++
 .../samples/porter/file/api/InspectorEndpoint.java | 206 +++++++++++++++++++++
 .../samples/porter/file/api/LogEndpoint.java       |  72 +++++++
 authentication/api/common/pom.xml                  |  36 ++++
 authentication/api/common/service/pom.xml          |  31 ++++
 .../samples/porter/common/api/LogService.java      |  26 +++
 authentication/api/pom.xml                         |  90 +++++++++
 65 files changed, 3413 insertions(+)

diff --git a/authentication/AuthenticationServer/pom.xml b/authentication/AuthenticationServer/pom.xml
new file mode 100644
index 0000000..0c7a295
--- /dev/null
+++ b/authentication/AuthenticationServer/pom.xml
@@ -0,0 +1,155 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>authentication-server</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis</artifactId>
+        <version>3.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis-spring</artifactId>
+        <version>1.3.0</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.46</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.security.oauth</groupId>
+        <artifactId>spring-security-oauth2</artifactId>
+        <version>2.3.2.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.security</groupId>
+        <artifactId>spring-security-jwt</artifactId>
+        <version>1.0.7.RELEASE</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.security.oauth</groupId>
+      <artifactId>spring-security-oauth2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.security</groupId>
+      <artifactId>spring-security-jwt</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java
new file mode 100644
index 0000000..f38125a
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.authentication;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class AuthenticationServer {
+  public static void main(String[] args) {
+    try {
+      BeanUtils.init();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
new file mode 100644
index 0000000..be46f5c
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.servicecomb.authentication.service;
+
+import org.apache.servicecomb.authentication.api.AuthenticationService;
+import org.apache.servicecomb.authentication.api.Token;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AuthenticationServiceImpl implements AuthenticationService {
+  @Autowired
+  @Qualifier("userDetailsService")
+  private UserDetailsService userDetailsService;
+  
+  @Autowired
+  @Qualifier("passwordEncoder")
+  private PasswordEncoder passwordEncoder;
+
+  @Override
+  public Token login(String userName, String password) {
+    UserDetails userDetails;
+    try {
+      userDetails = userDetailsService.loadUserByUsername(userName);
+    } catch (UsernameNotFoundException e) {
+      return null;
+    }
+    if(passwordEncoder.matches(password, userDetails.getPassword())) {
+      return null;
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public Token refresh(String refreshToken) {
+    return null;
+  }
+
+}
diff --git a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
new file mode 100644
index 0000000..661608f
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
@@ -0,0 +1,56 @@
+<?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:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+    
+    <bean id="dataSource"
+        class="org.apache.commons.dbcp2.BasicDataSource"
+        destroy-method="close">
+        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
+        <property name="url"
+            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
+        <property name="username" value="${db.username:root}" />
+        <property name="password" value="${db.password:}" />
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
+    </bean>
+
+    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
new file mode 100644
index 0000000..989e786
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
@@ -0,0 +1,57 @@
+<?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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
+    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
+        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
+    </sql>
+
+    <sql id="all_column_auto">
+        SESSION_ID, USER_NAME, ROLE_NAME
+    </sql>
+
+    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        insert into T_SESSION (
+        <include refid="all_column_auto" />
+        )
+        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
+        #{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getSessioinInfo" parameterType="java.lang.String"
+        resultMap="sessionInfo">
+        select
+        <include refid="all_column" />
+        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
+    </select>
+    
+    <update id="updateSessionInfo" parameterType="java.lang.String">
+        update T_SESSION
+        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
+    </update>
+</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml
new file mode 100644
index 0000000..c02e60d
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/UserMapper.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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
+    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, USER_NAME, PASSWORD, ROLE_NAME
+    </sql>
+
+    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        insert into T_USER (
+        <include refid="all_column" />
+        )
+        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
+        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getUserInfo" parameterType="java.lang.String"
+        resultMap="userInfo">
+        select
+        <include refid="all_column" />
+        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql b/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
new file mode 100644
index 0000000..a07c5d9
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+CREATE DATABASE IF NOT EXISTS porter_user_db;
+
+USE porter_user_db;
+
+DROP TABLE IF EXISTS T_USER;
+
+CREATE TABLE `T_USER` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  PRIMARY KEY (`ID`)
+);
+
+#### password is encrypted for test
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
+
+DROP TABLE IF EXISTS T_SESSION;
+
+CREATE TABLE `T_SESSION` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
+  PRIMARY KEY (`ID`)
+);
diff --git a/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml b/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
new file mode 100644
index 0000000..894caac
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
@@ -0,0 +1,27 @@
+<?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.
+  -->
+
+<!DOCTYPE configuration
+  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <mappers>
+        <mapper resource="config/UserMapper.xml"/>
+        <mapper resource="config/SessionMapper.xml"/>
+    </mappers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/log4j2.xml b/authentication/AuthenticationServer/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3c70391
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./user/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/microservice.yaml b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..1e6b0af
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: authentication-server
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9091
diff --git a/authentication/Client/pom.xml b/authentication/Client/pom.xml
new file mode 100644
index 0000000..60978df
--- /dev/null
+++ b/authentication/Client/pom.xml
@@ -0,0 +1,128 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>client</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis</artifactId>
+        <version>3.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis-spring</artifactId>
+        <version>1.3.0</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.46</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java
new file mode 100644
index 0000000..4ba1070
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.authentication;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class Client {
+  public static void main(String[] args) {
+    try {
+      BeanUtils.init();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml b/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
new file mode 100644
index 0000000..661608f
--- /dev/null
+++ b/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
@@ -0,0 +1,56 @@
+<?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:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+    
+    <bean id="dataSource"
+        class="org.apache.commons.dbcp2.BasicDataSource"
+        destroy-method="close">
+        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
+        <property name="url"
+            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
+        <property name="username" value="${db.username:root}" />
+        <property name="password" value="${db.password:}" />
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
+    </bean>
+
+    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/SessionMapper.xml b/authentication/Client/src/main/resources/config/SessionMapper.xml
new file mode 100644
index 0000000..989e786
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/SessionMapper.xml
@@ -0,0 +1,57 @@
+<?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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
+    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
+        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
+    </sql>
+
+    <sql id="all_column_auto">
+        SESSION_ID, USER_NAME, ROLE_NAME
+    </sql>
+
+    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        insert into T_SESSION (
+        <include refid="all_column_auto" />
+        )
+        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
+        #{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getSessioinInfo" parameterType="java.lang.String"
+        resultMap="sessionInfo">
+        select
+        <include refid="all_column" />
+        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
+    </select>
+    
+    <update id="updateSessionInfo" parameterType="java.lang.String">
+        update T_SESSION
+        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
+    </update>
+</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/UserMapper.xml b/authentication/Client/src/main/resources/config/UserMapper.xml
new file mode 100644
index 0000000..c02e60d
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/UserMapper.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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
+    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, USER_NAME, PASSWORD, ROLE_NAME
+    </sql>
+
+    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        insert into T_USER (
+        <include refid="all_column" />
+        )
+        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
+        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getUserInfo" parameterType="java.lang.String"
+        resultMap="userInfo">
+        select
+        <include refid="all_column" />
+        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/create_db_user.sql b/authentication/Client/src/main/resources/config/create_db_user.sql
new file mode 100644
index 0000000..a07c5d9
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/create_db_user.sql
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+CREATE DATABASE IF NOT EXISTS porter_user_db;
+
+USE porter_user_db;
+
+DROP TABLE IF EXISTS T_USER;
+
+CREATE TABLE `T_USER` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  PRIMARY KEY (`ID`)
+);
+
+#### password is encrypted for test
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
+
+DROP TABLE IF EXISTS T_SESSION;
+
+CREATE TABLE `T_SESSION` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
+  PRIMARY KEY (`ID`)
+);
diff --git a/authentication/Client/src/main/resources/config/mybatis-config.xml b/authentication/Client/src/main/resources/config/mybatis-config.xml
new file mode 100644
index 0000000..894caac
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/mybatis-config.xml
@@ -0,0 +1,27 @@
+<?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.
+  -->
+
+<!DOCTYPE configuration
+  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <mappers>
+        <mapper resource="config/UserMapper.xml"/>
+        <mapper resource="config/SessionMapper.xml"/>
+    </mappers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/log4j2.xml b/authentication/Client/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3c70391
--- /dev/null
+++ b/authentication/Client/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./user/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/microservice.yaml b/authentication/Client/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..411b4c6
--- /dev/null
+++ b/authentication/Client/src/main/resources/microservice.yaml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: authentication-server
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9092
diff --git a/authentication/Gateway/pom.xml b/authentication/Gateway/pom.xml
new file mode 100644
index 0000000..9223b6b
--- /dev/null
+++ b/authentication/Gateway/pom.xml
@@ -0,0 +1,88 @@
+<!--
+  ~ 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>gateway</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>edge-core</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
new file mode 100644
index 0000000..e801ebd
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.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.servicecomb.samples.porter.gateway;
+
+import java.util.Map;
+
+import org.apache.servicecomb.edge.core.AbstractEdgeDispatcher;
+import org.apache.servicecomb.edge.core.EdgeInvocation;
+
+import io.vertx.ext.web.Cookie;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.CookieHandler;
+
+public class ApiDispatcher extends AbstractEdgeDispatcher {
+  @Override
+  public int getOrder() {
+    return 10002;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "/api/([^\\/]+)/(.*)";
+    router.routeWithRegex(regex).handler(CookieHandler.create());
+    router.routeWithRegex(regex).handler(createBodyHandler());
+    router.routeWithRegex(regex).failureHandler(this::onFailure).handler(this::onRequest);
+  }
+
+  protected void onRequest(RoutingContext context) {
+    Map<String, String> pathParams = context.pathParams();
+    String microserviceName = pathParams.get("param0");
+    String path = "/" + pathParams.get("param1");
+
+    EdgeInvocation invoker = new EdgeInvocation() {
+      // Authentication. Notice: adding context must after setContext or will override by network
+      protected void setContext() throws Exception {
+        super.setContext();
+        // get session id from header and cookie for debug reasons
+        String sessionId = context.request().getHeader("session-id");
+        if (sessionId != null) {
+          this.invocation.addContext("session-id", sessionId);
+        } else {
+          Cookie sessionCookie = context.getCookie("session-id");
+          if (sessionCookie != null) {
+            this.invocation.addContext("session-id", sessionCookie.getValue());
+          }
+        }
+      }
+    };
+    invoker.init(microserviceName, context, path, httpServerFilters);
+    invoker.edgeInvoke();
+  }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
new file mode 100644
index 0000000..7119753
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
@@ -0,0 +1,31 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+
+
+public class AuthHandler implements Handler {
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception {
+    // TODO check session
+    invocation.next(asyncResponse);
+  }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
new file mode 100644
index 0000000..a2941be
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
@@ -0,0 +1,196 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.servicecomb.common.rest.AbstractRestInvocation;
+import org.apache.servicecomb.common.rest.RestConst;
+import org.apache.servicecomb.common.rest.VertxRestInvocation;
+import org.apache.servicecomb.core.Const;
+import org.apache.servicecomb.core.CseContext;
+import org.apache.servicecomb.core.Transport;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
+import org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest;
+import org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.apache.servicecomb.transport.rest.vertx.AbstractVertxHttpDispatcher;
+import org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
+import io.vertx.core.json.JsonObject;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.CookieHandler;
+
+// copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher
+public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
+  private static final Logger LOGGER = LoggerFactory.getLogger(VertxRestDispatcher.class);
+
+  private Transport transport;
+
+  @Override
+  public int getOrder() {
+    return 10001;
+  }
+
+  @Override
+  public boolean enabled() {
+    return true;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "[/v1/log/|/inspector|/v1/auth](.*)";
+    router.routeWithRegex(regex).handler(CookieHandler.create());
+    router.routeWithRegex(regex).handler(createBodyHandler());
+    router.routeWithRegex(regex).failureHandler(this::failureHandler).handler(this::onRequest);
+  }
+
+  private void failureHandler(RoutingContext context) {
+    LOGGER.error("http server failed.", context.failure());
+
+    AbstractRestInvocation restProducerInvocation = context.get(RestConst.REST_PRODUCER_INVOCATION);
+    Throwable e = context.failure();
+    if (ErrorDataDecoderException.class.isInstance(e)) {
+      Throwable cause = e.getCause();
+      if (InvocationException.class.isInstance(cause)) {
+        e = cause;
+      }
+    }
+
+    // only when unexpected exception happens, it will run into here.
+    // the connection should be closed.
+    handleFailureAndClose(context, restProducerInvocation, e);
+  }
+
+  /**
+   * Try to find out the failure information and send it in response.
+   */
+  private void handleFailureAndClose(RoutingContext context, AbstractRestInvocation restProducerInvocation,
+      Throwable e) {
+    if (null != restProducerInvocation) {
+      // if there is restProducerInvocation, let it send exception in response. The exception is allowed to be null.
+      sendFailResponseByInvocation(context, restProducerInvocation, e);
+      return;
+    }
+
+    if (null != e) {
+      // if there exists exception, try to send this exception by RoutingContext
+      sendExceptionByRoutingContext(context, e);
+      return;
+    }
+
+    // if there is no exception, the response is determined by status code.
+    sendFailureRespDeterminedByStatus(context);
+  }
+
+  /**
+   * Try to determine response by status code, and send response.
+   */
+  private void sendFailureRespDeterminedByStatus(RoutingContext context) {
+    Family statusFamily = Family.familyOf(context.statusCode());
+    if (Family.CLIENT_ERROR.equals(statusFamily) || Family.SERVER_ERROR.equals(statusFamily) || Family.OTHER
+        .equals(statusFamily)) {
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(context.statusCode()).end();
+    } else {
+      // it seems the status code is not set properly
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode())
+          .setStatusMessage(Status.INTERNAL_SERVER_ERROR.getReasonPhrase())
+          .end(wrapResponseBody(Status.INTERNAL_SERVER_ERROR.getReasonPhrase()));
+    }
+    context.response().close();
+  }
+
+  /**
+   * Use routingContext to send failure information in throwable.
+   */
+  private void sendExceptionByRoutingContext(RoutingContext context, Throwable e) {
+    if (InvocationException.class.isInstance(e)) {
+      InvocationException invocationException = (InvocationException) e;
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(invocationException.getStatusCode()).setStatusMessage(invocationException.getReasonPhrase())
+          .end(wrapResponseBody(invocationException.getReasonPhrase()));
+    } else {
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).end(wrapResponseBody(e.getMessage()));
+    }
+    context.response().close();
+  }
+
+  /**
+   * Consumer will treat the response body as json by default, so it's necessary to wrap response body as Json string
+   * to avoid deserialization error.
+   *
+   * @param message response body
+   * @return response body wrapped as Json string
+   */
+  String wrapResponseBody(String message) {
+    if (isValidJson(message)) {
+      return message;
+    }
+
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.put("message", message);
+
+    return jsonObject.toString();
+  }
+
+  /**
+   * Check if the message is a valid Json string.
+   * @param message the message to be checked.
+   * @return true if message is a valid Json string, otherwise false.
+   */
+  private boolean isValidJson(String message) {
+    try {
+      new JsonObject(message);
+    } catch (Exception ignored) {
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Use restProducerInvocation to send failure message. The throwable is allowed to be null.
+   */
+  private void sendFailResponseByInvocation(RoutingContext context, AbstractRestInvocation restProducerInvocation,
+      Throwable e) {
+    restProducerInvocation.sendFailResponse(e);
+    context.response().close();
+  }
+
+  private void onRequest(RoutingContext context) {
+    if (transport == null) {
+      transport = CseContext.getInstance().getTransportManager().findTransport(Const.RESTFUL);
+    }
+    HttpServletRequestEx requestEx = new VertxServerRequestToHttpServletRequest(context);
+    HttpServletResponseEx responseEx = new VertxServerResponseToHttpServletResponse(context.response());
+
+    VertxRestInvocation vertxRestInvocation = new VertxRestInvocation();
+    context.put(RestConst.REST_PRODUCER_INVOCATION, vertxRestInvocation);
+    vertxRestInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
+  }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
new file mode 100644
index 0000000..159c10d
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
@@ -0,0 +1,38 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import java.io.File;
+
+import org.apache.servicecomb.foundation.ssl.SSLCustom;
+
+public class EdgeSSLCustom extends SSLCustom {
+
+    @Override
+    public char[] decode(char[] plain) {
+        return plain;
+    }
+
+    @Override
+    public String getFullPath(String name) {
+        String fullName = System.getProperty("user.dir") + File.separator + name;
+        System.out.println(fullName);
+        return (new File(fullName)).getAbsolutePath();
+    }
+
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
new file mode 100644
index 0000000..a219d2d
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
@@ -0,0 +1,26 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class GatewayMain {
+    public static void main(String[] args) throws Exception {
+        BeanUtils.init();
+    }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
new file mode 100644
index 0000000..0b181d8
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
@@ -0,0 +1,37 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+
+public class InternalAccessHandler implements Handler {
+
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncReponse) throws Exception {
+    if (invocation.getOperationMeta().getSwaggerOperation().getTags() != null
+        && invocation.getOperationMeta().getSwaggerOperation().getTags().contains("INTERNAL")) {
+      asyncReponse.consumerFail(new InvocationException(403, "", "not allowed"));
+      return;
+    }
+    invocation.next(asyncReponse);
+  }
+
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
new file mode 100644
index 0000000..791c512
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
@@ -0,0 +1,52 @@
+/*
+ * 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.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.handler.StaticHandler;
+
+public class StaticWebpageDispatcher implements VertxHttpDispatcher {
+  private static final Logger LOGGER = LoggerFactory.getLogger(StaticWebpageDispatcher.class);
+
+  private static final String WEB_ROOT = DynamicPropertyFactory.getInstance()
+      .getStringProperty("gateway.webroot", "/var/static")
+      .get();
+
+  @Override
+  public int getOrder() {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "/ui/(.*)";
+    StaticHandler webpageHandler = StaticHandler.create();
+    webpageHandler.setWebRoot(WEB_ROOT);
+    LOGGER.info("server static web page for WEB_ROOT={}", WEB_ROOT);
+    router.routeWithRegex(regex).failureHandler((context) -> {
+      LOGGER.error("", context.failure());
+    }).handler(webpageHandler);
+  }
+
+}
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
new file mode 100644
index 0000000..bada1de
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
+org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
+org.apache.servicecomb.samples.porter.gateway.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml b/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
new file mode 100644
index 0000000..b5816c3
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
@@ -0,0 +1,27 @@
+<?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:context="http://www.springframework.org/schema/context"
+  xsi:schemaLocation="
+		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+</beans>
diff --git a/authentication/Gateway/src/main/resources/config/cse.handler.xml b/authentication/Gateway/src/main/resources/config/cse.handler.xml
new file mode 100644
index 0000000..e9dd306
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/config/cse.handler.xml
@@ -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.
+  -->
+
+<config>
+  <handler id="auth"
+    class="org.apache.servicecomb.samples.porter.gateway.AuthHandler" />
+  <handler id="internalAccess"
+    class="org.apache.servicecomb.samples.porter.gateway.InternalAccessHandler" />
+</config>
diff --git a/authentication/Gateway/src/main/resources/log4j2.xml b/authentication/Gateway/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..b51f28e
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./gateway/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/Gateway/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..5b1cd91
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/microservice.yaml
@@ -0,0 +1,67 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: gateway
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9090
+
+  handler:
+    chain:
+      Consumer:
+        default: internalAccess,auth,qps-flowcontrol-consumer,loadbalance
+
+  uploads:
+    directory: tmp_for_upload_gateway
+
+  samples:
+    logdir: D:\code\servicecomb-samples\porter_lightweight\gateway-service
+    
+  inspector:
+    enabled: false
+
+  executors:
+   Provider:
+     log: servicecomb.samples.executor.groupThreadPool
+     inspector: servicecomb.samples.executor.groupThreadPool
+
+# disable all servicecomb difault dispatchers, all of them are overriden
+  http:
+    dispatcher:
+      edge:
+        default:
+          enabled: false # overriden by ApiDispatcher
+      rest:
+        eanbled: false # overriden by CustomVertxRestDispatcher
+
+# StaticWebpageDispatcher checking file exists is async, and will mark request status to ended, and VertxRestDispatcher read 
+# body will print exception. 
+#gateway.webroot: /code/servicecomb-samples/porter_lightweight/gateway-service/src/main/resources
diff --git a/authentication/Gateway/src/main/resources/ui/css/style.css b/authentication/Gateway/src/main/resources/ui/css/style.css
new file mode 100644
index 0000000..5731863
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/css/style.css
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+.error {
+    font-family:verdana;
+    color:red;
+}
+
+.header {
+    background-color:black;
+    color:white;
+    text-align:center;
+    padding:5px;
+}
+
+.nav {
+    line-height:30px;
+    background-color:#eeeeee;
+    height:300px;
+    width:100px;
+    float:left;
+    padding:5px; 
+}
+
+.section {
+    text-align:center;
+    padding:5px;
+}
+
+.footer {
+    color:red;
+    clear:both;
+    text-align:center;
+    padding:25px; 
+}
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js b/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js
new file mode 100644
index 0000000..ab28a24
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js
@@ -0,0 +1,4 @@
+/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
+!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b [...]
+if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&& [...]
+},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.prop [...]
diff --git a/authentication/Gateway/src/main/resources/ui/js/login.js b/authentication/Gateway/src/main/resources/ui/js/login.js
new file mode 100644
index 0000000..c7e7c8e
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/js/login.js
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+function loginAction() {
+     var username = document.getElementById("username").value;
+     var password = document.getElementById("paasword").value;
+     var formData = {};
+     formData.userName = username;
+     formData.password = password;
+
+     $.ajax({
+        type: 'POST',
+        url: "/api/user-service/v1/user/login",
+        data: formData,
+        success: function (data) {
+            console.log(data);
+            setCookie("session-id", data.sessiondId, 1);
+            window.location = "/ui/upload.html";
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Login failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
+
+function setCookie(name,value,days) {
+    var expires = "";
+    if (days) {
+        var date = new Date();
+        date.setTime(date.getTime() + (days*24*60*60*1000));
+        expires = "; expires=" + date.toUTCString();
+    }
+    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
+}
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/js/upload.js b/authentication/Gateway/src/main/resources/ui/js/upload.js
new file mode 100644
index 0000000..7d66555
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/js/upload.js
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+function uploadAction() {
+     var formData = new FormData(document.getElementById("upload_form"));
+
+     $.ajax({
+        type: 'POST',
+        url: "/api/file-service/upload",
+        data: formData,
+        processData:false,
+        contentType:false,
+        success: function (data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Upload Successfully";
+            error.hidden=false;
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Upload failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
+
+function deleteAction() {
+     var fileID = document.getElementById("fileID").value;
+     $.ajax({
+        type: 'DELETE',
+        url: "/api/file-service/delete?" + $.param({ id: fileID }),
+        data: {},
+        success: function (data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Delete successfully";
+            error.hidden=false;
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Delete failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/login.html b/authentication/Gateway/src/main/resources/ui/login.html
new file mode 100644
index 0000000..c8b45fb
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/login.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+
+<!--
+  ~ 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.
+  -->
+
+<html>
+
+    <head>
+        <title>PORTER</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
+        <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
+        <script type="text/javascript" src="js/login.js"></script>
+    </head>
+
+    <body>
+    <div class="header">
+        <h2>Login</h2>
+    </div>
+    <div class="section">
+        <form method="POST" enctype="multipart/form-data">
+            <input id="username" type="text" placeholder="Username" required="true"/>
+            <input id="paasword" type="password" placeholder="Password" required="true"/>
+            <input type="button" value="Login" onclick="loginAction()">
+        </form>
+    </div>
+    <div class="footer">
+        <p id="error" hidden="true" class="error"/>
+    </div>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/upload.html b/authentication/Gateway/src/main/resources/ui/upload.html
new file mode 100644
index 0000000..bd5eeff
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/upload.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<!--
+  ~ 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.
+  -->
+
+<html>
+
+    <head>
+        <title>PORTER</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
+        <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
+        <script type="text/javascript" src="js/upload.js"></script>
+    </head>
+
+    <body>
+    <div class="header">
+        <h2>Upload</h2>
+    </div>
+    <div class="section">
+        <form id="upload_form" method="POST">
+            <p>
+                File Name: <input type="file" name="fileName"/>
+            </p>
+            <p>
+                <input type="button" value="Upload" onclick="uploadAction()">
+            </p>
+        </form>
+    </div>
+
+    <div class="header">
+        <h2>Delete file</h2>
+    </div>
+    <div class="section">
+        <form id="delete_form" method="DELETE">
+            <p>
+                File ID: <input id="fileID" type="text"/>
+            </p>
+            <p>
+                <input type="button" value="Delete" onclick="deleteAction()">
+            </p>
+        </form>
+    </div>
+    <div class="footer">
+        <p id="error" hidden="true" class="error"/>
+    </div>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/authentication/README.md b/authentication/README.md
new file mode 100644
index 0000000..48798cd
--- /dev/null
+++ b/authentication/README.md
@@ -0,0 +1,26 @@
+本项目提供认证鉴权服务的实现,主要提供了基于角色的权限管理,和基于JWT的微服务授权模式。微服务的命名参考了OAuth2协议里面的命名方式。可以参考[OAuth2.0原理和验证流程分析](https://www.jianshu.com/p/d74ce6ca0c33)对于OAuth2认证过程的介绍,本项目的认证过程非常类似OAuth2的密码模式。
+
+项目的目标是提供一个商业可用的鉴权实现,对于项目代码实现的问题可以提交issue,本项目也接纳PR,共同完善。
+
+* AuthenticationServer
+
+认证鉴权服务。提供用户管理、角色管理。并提供登录认证、权限查询等接口。鉴权服务及相关API是核心交付件,也是能够被重用的部分。开发者可以基于这个项目开发认证鉴权服务。
+
+* Gateway
+提供请求拦截,校验用户是否已经经过认证。一方面演示网关如何和配套鉴权服务完成开发,本项目也是自动化测试的组成部分。
+
+* Client
+Client模拟的是使用使用者。一方面演示客户端如何获取Token,本项目也是自动化测试的组成部分。
+
+* ResourceServer
+ResourceServer模拟的是业务服务。一方面演示业务服务如何进行权限配置,本项目也是自动化测试的组成部分。
+
+
+## 实现说明
+
+* 用户管理
+用户管理采用了org.springframework.security.core.userdetails的模型,包括:
+  1. UserDetailsService:加载用户信息。
+  2. UserDetails:用户信息。
+  3. GrantedAuthority:角色信息。
+  4. PasswordEncoder:用户密码加密和匹配。
\ No newline at end of file
diff --git a/authentication/ResourceServer/pom.xml b/authentication/ResourceServer/pom.xml
new file mode 100644
index 0000000..52aea79
--- /dev/null
+++ b/authentication/ResourceServer/pom.xml
@@ -0,0 +1,128 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>resource-server</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis</artifactId>
+        <version>3.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis-spring</artifactId>
+        <version>1.3.0</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.46</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java
new file mode 100644
index 0000000..f2653ab
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.authentication;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class ResourceServer {
+  public static void main(String[] args) {
+    try {
+      BeanUtils.init();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
new file mode 100644
index 0000000..4b6a5b6
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
@@ -0,0 +1,45 @@
+/*
+ * 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.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+@RestSchema(schemaId = "FileEndpoint")
+@RequestMapping(path = "/v1/file")
+public class FileEndpoint {
+    @Autowired
+    private FileStoreService fileService;
+
+    @PostMapping(path = "/upload", produces = MediaType.TEXT_PLAIN_VALUE)
+    public String uploadFile(@RequestPart(name = "fileName") MultipartFile file) {
+        return fileService.uploadFile(file);
+    }
+
+    @DeleteMapping(path = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
+    public boolean deleteFile(@RequestParam(name = "id") String id) {
+        return fileService.deleteFile(id);
+    }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
new file mode 100644
index 0000000..ed03665
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
@@ -0,0 +1,31 @@
+/*
+ * 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.servicecomb.authentication.resource;
+
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * file storage service, can implement using file system, OBS, etc.
+ */
+public interface FileStoreService {
+
+    public String uploadFile(MultipartFile file);
+
+    public boolean deleteFile(String id);
+
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
new file mode 100644
index 0000000..d487144
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
@@ -0,0 +1,64 @@
+/*
+ * 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.servicecomb.authentication.resource;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.UUID;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ *  Simple file storage implementation.
+ *  Caution: file check and other security constraints not implemented. 
+ */
+@Component
+public class LocalFileStoreService implements FileStoreService {
+    // maxmum BUFFER_SIZE * BUFFER_NUM
+    private static final int BUFFER_SIZE = 10240;
+
+    private static final File BASE_FILE = new File(".");
+
+    @Override
+    public String uploadFile(MultipartFile file) {
+        byte[] buffer = new byte[BUFFER_SIZE];
+        String fileId = UUID.randomUUID().toString();
+
+        File outFile = new File(BASE_FILE, fileId);
+        int len;
+        try (InputStream is = file.getInputStream(); OutputStream os = new FileOutputStream(outFile)) {
+            while ((len = is.read(buffer)) != -1) {
+                os.write(buffer, 0, len);
+            }
+        } catch (IOException e) {
+            return null;
+        }
+        return fileId;
+    }
+
+    @Override
+    public boolean deleteFile(String id) {
+        File outFile = new File(BASE_FILE, id);
+        return outFile.delete();
+    }
+
+}
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
new file mode 100644
index 0000000..661608f
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
@@ -0,0 +1,56 @@
+<?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:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+    
+    <bean id="dataSource"
+        class="org.apache.commons.dbcp2.BasicDataSource"
+        destroy-method="close">
+        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
+        <property name="url"
+            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
+        <property name="username" value="${db.username:root}" />
+        <property name="password" value="${db.password:}" />
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
+    </bean>
+
+    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml b/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
new file mode 100644
index 0000000..989e786
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
@@ -0,0 +1,57 @@
+<?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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
+    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
+        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
+    </sql>
+
+    <sql id="all_column_auto">
+        SESSION_ID, USER_NAME, ROLE_NAME
+    </sql>
+
+    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        insert into T_SESSION (
+        <include refid="all_column_auto" />
+        )
+        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
+        #{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getSessioinInfo" parameterType="java.lang.String"
+        resultMap="sessionInfo">
+        select
+        <include refid="all_column" />
+        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
+    </select>
+    
+    <update id="updateSessionInfo" parameterType="java.lang.String">
+        update T_SESSION
+        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
+    </update>
+</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/UserMapper.xml b/authentication/ResourceServer/src/main/resources/config/UserMapper.xml
new file mode 100644
index 0000000..c02e60d
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/UserMapper.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.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
+    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, USER_NAME, PASSWORD, ROLE_NAME
+    </sql>
+
+    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        insert into T_USER (
+        <include refid="all_column" />
+        )
+        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
+        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getUserInfo" parameterType="java.lang.String"
+        resultMap="userInfo">
+        select
+        <include refid="all_column" />
+        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/create_db_user.sql b/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
new file mode 100644
index 0000000..a07c5d9
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+CREATE DATABASE IF NOT EXISTS porter_user_db;
+
+USE porter_user_db;
+
+DROP TABLE IF EXISTS T_USER;
+
+CREATE TABLE `T_USER` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  PRIMARY KEY (`ID`)
+);
+
+#### password is encrypted for test
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
+
+DROP TABLE IF EXISTS T_SESSION;
+
+CREATE TABLE `T_SESSION` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
+  PRIMARY KEY (`ID`)
+);
diff --git a/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml b/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
new file mode 100644
index 0000000..894caac
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
@@ -0,0 +1,27 @@
+<?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.
+  -->
+
+<!DOCTYPE configuration
+  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <mappers>
+        <mapper resource="config/UserMapper.xml"/>
+        <mapper resource="config/SessionMapper.xml"/>
+    </mappers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/log4j2.xml b/authentication/ResourceServer/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3c70391
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./user/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/microservice.yaml b/authentication/ResourceServer/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..47b05c1
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/microservice.yaml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: resource-server
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9092
diff --git a/authentication/api/AuthenticationServer/endpoint/pom.xml b/authentication/api/AuthenticationServer/endpoint/pom.xml
new file mode 100644
index 0000000..5eebece
--- /dev/null
+++ b/authentication/api/AuthenticationServer/endpoint/pom.xml
@@ -0,0 +1,38 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-server-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-server-api-endpoint</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
new file mode 100644
index 0000000..dfc9c51
--- /dev/null
+++ b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
@@ -0,0 +1,39 @@
+/*
+ * 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.servicecomb.authentication.api;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "AuthenticationEndpoint")
+@RequestMapping(path = "/v1/auth/login")
+public class AuthenticationEndpoint {
+  @Autowired
+  private AuthenticationService authenticationService;
+
+  public Token login(@RequestParam(name = "userName") String userName,
+      @RequestParam(name = "password") String password) {
+    return authenticationService.login(userName, password);
+  }
+
+  public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
+    return authenticationService.refresh(refreshToken);
+  }
+}
diff --git a/authentication/api/AuthenticationServer/pom.xml b/authentication/api/AuthenticationServer/pom.xml
new file mode 100644
index 0000000..946a2fb
--- /dev/null
+++ b/authentication/api/AuthenticationServer/pom.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.
+  -->
+
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-server-api</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/authentication/api/AuthenticationServer/service/pom.xml b/authentication/api/AuthenticationServer/service/pom.xml
new file mode 100644
index 0000000..4433ff6
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/pom.xml
@@ -0,0 +1,31 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-server-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-server-api-service</artifactId>
+  <packaging>jar</packaging>
+
+</project>
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
new file mode 100644
index 0000000..77635ad
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
@@ -0,0 +1,35 @@
+/*
+ * 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.servicecomb.authentication.api;
+
+public interface AuthenticationService {
+  /**
+   * login using user name and password.
+   * @param userName user name
+   * @param password password
+   * @return After successfully login, token is created. Or null is returned. 
+   */
+  Token login(String userName, String password);
+
+  /**
+   * acquired new token using refresh token.
+   * @param refreshToken refresh token
+   * @return After successfully authenticated, token is created. Or null is returned. 
+   */
+  Token refresh(String refreshToken);
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
new file mode 100644
index 0000000..732fe22
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
@@ -0,0 +1,40 @@
+/*
+ * 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.servicecomb.authentication.api;
+
+public class Token {
+  private String accessToken;
+
+  private String refreshToken;
+
+  public String getAccessToken() {
+    return accessToken;
+  }
+
+  public void setAccessToken(String accessToken) {
+    this.accessToken = accessToken;
+  }
+
+  public String getRefreshToken() {
+    return refreshToken;
+  }
+
+  public void setRefreshToken(String refreshToken) {
+    this.refreshToken = refreshToken;
+  }
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
new file mode 100644
index 0000000..54c2175
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
@@ -0,0 +1,48 @@
+/*
+ * 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.servicecomb.authentication.api;
+
+/**
+ * 
+ * After successfully login, tokens are created. </br>
+ * <B>Access Token:</B> used to access resources.</br>
+ * <B>Refresh Token:</B> used to acquire new tokens.</br>
+ *
+ */
+public class Tokens {
+  private String accessToken;
+
+  private String refreshToken;
+
+  public String getAccessToken() {
+    return accessToken;
+  }
+
+  public void setAccessToken(String accessToken) {
+    this.accessToken = accessToken;
+  }
+
+  public String getRefreshToken() {
+    return refreshToken;
+  }
+
+  public void setRefreshToken(String refreshToken) {
+    this.refreshToken = refreshToken;
+  }
+
+}
diff --git a/authentication/api/common/endpoint/pom.xml b/authentication/api/common/endpoint/pom.xml
new file mode 100644
index 0000000..de2736a
--- /dev/null
+++ b/authentication/api/common/endpoint/pom.xml
@@ -0,0 +1,38 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-common-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-common-api-endpoint</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
new file mode 100644
index 0000000..731f6ac
--- /dev/null
+++ b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
@@ -0,0 +1,206 @@
+/*
+ * 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.servicecomb.samples.porter.file.api;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.Map.Entry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.servlet.http.Part;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.servicecomb.common.rest.resource.ClassPathStaticResourceHandler;
+import org.apache.servicecomb.common.rest.resource.StaticResourceHandler;
+import org.apache.servicecomb.config.inject.ConfigObjectFactory;
+import org.apache.servicecomb.foundation.common.part.InputStreamPart;
+import org.apache.servicecomb.inspector.internal.InspectorConfig;
+import org.apache.servicecomb.inspector.internal.swagger.AppendStyleProcessor;
+import org.apache.servicecomb.inspector.internal.swagger.SchemaFormat;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.swagger.SwaggerUtils;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.asciidoctor.Asciidoctor;
+import org.asciidoctor.Asciidoctor.Factory;
+import org.asciidoctor.Attributes;
+import org.asciidoctor.AttributesBuilder;
+import org.asciidoctor.OptionsBuilder;
+import org.asciidoctor.SafeMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Ordering;
+
+import io.github.swagger2markup.Swagger2MarkupConfig;
+import io.github.swagger2markup.Swagger2MarkupConverter;
+import io.github.swagger2markup.Swagger2MarkupConverter.Builder;
+import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.models.parameters.Parameter;
+
+// copied from org.apache.servicecomb.inspector.internal.InspectorImpl;
+@RestSchema(schemaId = "inspector")
+@Path("/inspector")
+public class InspectorEndpoint {
+  private static final Logger LOGGER = LoggerFactory.getLogger(InspectorEndpoint.class);
+
+  private InspectorConfig inspectorConfig;
+
+  private volatile Asciidoctor asciidoctor;
+
+  private StaticResourceHandler resourceHandler = new ClassPathStaticResourceHandler();
+
+  public InspectorEndpoint() {
+    this.inspectorConfig = new ConfigObjectFactory().create(InspectorConfig.class);
+  }
+
+  @Path("/schemas")
+  @GET
+  public Collection<String> getSchemaIds() {
+    return RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().keySet();
+  }
+
+  @Path("/download/schemas")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response downloadSchemas(@QueryParam("format") SchemaFormat format) {
+    if (format == null) {
+      format = SchemaFormat.SWAGGER;
+    }
+
+    // normally, schema will not be too big, just save them in memory temporarily
+    ByteArrayOutputStream os = new ByteArrayOutputStream();
+    try (ZipOutputStream zos = new ZipOutputStream(os)) {
+      for (Entry<String, String> entry : RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().entrySet()) {
+        // begin writing a new ZIP entry, positions the stream to the start of the entry data
+        zos.putNextEntry(new ZipEntry(entry.getKey() + format.getSuffix()));
+
+        String content = entry.getValue();
+        if (SchemaFormat.HTML.equals(format)) {
+          content = swaggerToHtml(content);
+        }
+        zos.write(content.getBytes(StandardCharsets.UTF_8));
+        zos.closeEntry();
+      }
+    } catch (Throwable e) {
+      String msg = "failed to create schemas zip file, format=" + format + ".";
+      LOGGER.error(msg, e);
+      return Response.failResp(new InvocationException(Status.INTERNAL_SERVER_ERROR, msg));
+    }
+
+    Part part = new InputStreamPart(null, new ByteArrayInputStream(os.toByteArray()))
+        .setSubmittedFileName(RegistryUtils.getMicroservice().getServiceName() + format.getSuffix() + ".zip");
+    return Response.ok(part);
+  }
+
+  @Path("/schemas/{schemaId}")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response getSchemaContentById(@PathParam("schemaId") String schemaId,
+      @QueryParam("format") SchemaFormat format, @QueryParam("download") boolean download) {
+    String swaggerContent = RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().get(schemaId);
+    if (swaggerContent == null) {
+      return Response.failResp(new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase()));
+    }
+
+    if (format == null) {
+      format = SchemaFormat.SWAGGER;
+    }
+
+    byte[] bytes;
+    if (SchemaFormat.HTML.equals(format)) {
+      String html = swaggerToHtml(swaggerContent);
+      bytes = html.getBytes(StandardCharsets.UTF_8);
+    } else {
+      bytes = swaggerContent.getBytes(StandardCharsets.UTF_8);
+    }
+
+    Part part = new InputStreamPart(null, new ByteArrayInputStream(bytes))
+        .setSubmittedFileName(schemaId + format.getSuffix());
+
+    Response response = Response.ok(part);
+    if (!download) {
+      response.getHeaders().addHeader(HttpHeaders.CONTENT_DISPOSITION, "inline");
+    }
+    response.getHeaders().addHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML);
+    return response;
+  }
+
+  // swagger not support cookie parameter
+  // so if swaggerContent contains cookie parameter, will cause problem.
+  private String swaggerToHtml(String swaggerContent) {
+    if (asciidoctor == null) {
+      synchronized (this) {
+        if (asciidoctor == null) {
+          // very slow, need a few seconds
+          LOGGER.info("create AsciiDoctor start.");
+          asciidoctor = Factory.create();
+          asciidoctor.javaExtensionRegistry().docinfoProcessor(AppendStyleProcessor.class);
+          LOGGER.info("create AsciiDoctor end.");
+        }
+      }
+    }
+
+    // swagger to markup
+    Builder markupBuilder = Swagger2MarkupConverter.from(SwaggerUtils.parseSwagger(swaggerContent));
+    // default not support cookie parameter
+    // so must customize config
+    Swagger2MarkupConfig markupConfig = new Swagger2MarkupConfigBuilder()
+        .withParameterOrdering(Ordering
+            .explicit("path", "query", "header", "cookie", "formData", "body")
+            .onResultOf(Parameter::getIn))
+        .build();
+    String markup = markupBuilder.withConfig(markupConfig).build().toString();
+
+    // markup to html
+    OptionsBuilder builder = OptionsBuilder.options();
+    builder.docType("book")
+        .backend("html5")
+        .headerFooter(true)
+        .safe(SafeMode.UNSAFE)
+        .attributes(AttributesBuilder.attributes()
+            .attribute("toclevels", 3)
+            .attribute(Attributes.TOC_2, true)
+            .attribute(Attributes.TOC_POSITION, "left")
+            .attribute(Attributes.LINK_CSS, true)
+            .attribute(Attributes.STYLESHEET_NAME, inspectorConfig.getAsciidoctorCss())
+            .attribute(Attributes.SECTION_NUMBERS, true)
+            .attribute(Attributes.SECT_NUM_LEVELS, 4));
+    return asciidoctor.convert(markup, builder.asMap());
+  }
+
+  @Path("/{path : .+}")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response getStaticResource(@PathParam("path") String path) {
+    return resourceHandler.handle(path);
+  }
+}
+
diff --git a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
new file mode 100644
index 0000000..8e49a6e
--- /dev/null
+++ b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
@@ -0,0 +1,72 @@
+/*
+ * 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.servicecomb.samples.porter.file.api;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.porter.common.api.LogService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+@RestSchema(schemaId = "log")
+@RequestMapping(path = "/v1/log")
+public class LogEndpoint implements LogService {
+  // protect your file in real applications
+  private static final File LOG_DIR =
+      new File(DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.samples.logdir", ".").get());
+
+  private static final String FILE_POST_FIX = ".log";
+
+  @Override
+  @GetMapping(path = "/getLogFileList")
+  public List<String> getLogFileList() {
+    File[] files = LOG_DIR.listFiles(new FileFilter() {
+      @Override
+      public boolean accept(File file) {
+        return isLogFile(file);
+      }
+    });
+
+    List<String> result = new ArrayList<>(files.length);
+    for (int i = 0; i < files.length; i++) {
+      result.add(files[i].getName());
+    }
+    return result;
+  }
+
+  @Override
+  @GetMapping(path = "/getLogFileContent")
+  public File getLogFileContent(@RequestParam(name = "fileName") String fileName) {
+    File file = new File(LOG_DIR, fileName);
+    if (isLogFile(file)) {
+      return file;
+    }
+    return null;
+  }
+
+  private boolean isLogFile(File file) {
+    return file.isFile() && file.canRead() && file.getName().endsWith(FILE_POST_FIX);
+  }
+}
diff --git a/authentication/api/common/pom.xml b/authentication/api/common/pom.xml
new file mode 100644
index 0000000..b4a9fbc
--- /dev/null
+++ b/authentication/api/common/pom.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.
+  -->
+
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-common-api</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/authentication/api/common/service/pom.xml b/authentication/api/common/service/pom.xml
new file mode 100644
index 0000000..538be70
--- /dev/null
+++ b/authentication/api/common/service/pom.xml
@@ -0,0 +1,31 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-common-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-common-api-service</artifactId>
+  <packaging>jar</packaging>
+
+</project>
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
new file mode 100644
index 0000000..9991543
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
@@ -0,0 +1,26 @@
+/*
+ * 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.servicecomb.samples.porter.common.api;
+
+import java.io.File;
+import java.util.List;
+
+public interface LogService {
+  List<String> getLogFileList();
+  File getLogFileContent(String fileName);
+}
diff --git a/authentication/api/pom.xml b/authentication/api/pom.xml
new file mode 100644
index 0000000..cdc3926
--- /dev/null
+++ b/authentication/api/pom.xml
@@ -0,0 +1,90 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>authentication-api</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <modules>
+    <module>common</module>
+    <module>AuthenticationServer</module>
+  </modules>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file