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 <[email protected]> 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 {
