You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/06/29 05:48:28 UTC
[21/50] kylin git commit: upgrade to Spring 4
upgrade to Spring 4
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/247f3cd2
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/247f3cd2
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/247f3cd2
Branch: refs/heads/master
Commit: 247f3cd266c77480ac0f8d329e8e7adb617b5de0
Parents: 5a4e465
Author: Yang Li <li...@apache.org>
Authored: Mon Jun 19 21:58:25 2017 +0800
Committer: Roger Shi <ro...@gmail.com>
Committed: Tue Jun 20 15:28:30 2017 +0800
----------------------------------------------------------------------
.../apache/kylin/common/KylinConfigBase.java | 3 ++
pom.xml | 28 ++++++++++++++----
.../rest/controller2/UserControllerV2.java | 7 +++--
.../kylin/rest/response/EnvelopeResponse.java | 6 ++--
.../apache/kylin/rest/service/UserService.java | 6 ++--
.../src/main/resources/applicationContext.xml | 31 +++++++-------------
server/src/main/resources/kylinSecurity.xml | 17 ++++++-----
7 files changed, 53 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/247f3cd2/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
index e64dddb..2ccf3cf 100644
--- a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
+++ b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
@@ -62,6 +62,9 @@ abstract public class KylinConfigBase implements Serializable {
public static String getKylinHome() {
String kylinHome = System.getenv("KYLIN_HOME");
if (StringUtils.isEmpty(kylinHome)) {
+ kylinHome = System.getProperty("KYLIN_HOME");
+ }
+ if (StringUtils.isEmpty(kylinHome)) {
logger.warn("KYLIN_HOME was not set");
}
return kylinHome;
http://git-wip-us.apache.org/repos/asf/kylin/blob/247f3cd2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f887c8d..506d734 100644
--- a/pom.xml
+++ b/pom.xml
@@ -114,11 +114,11 @@
<tomcat.version>7.0.69</tomcat.version>
<t-digest.version>3.1</t-digest.version>
- <!-- REST Service -->
- <spring.framework.version>3.2.17.RELEASE</spring.framework.version>
- <spring.framework.security.version>3.1.2.RELEASE</spring.framework.security.version>
- <spring.framework.security.extensions.version>1.0.2.RELEASE
- </spring.framework.security.extensions.version>
+ <!-- REST Service, ref https://github.com/spring-projects/spring-boot/blob/v1.3.8.RELEASE/spring-boot-dependencies/pom.xml -->
+ <spring.boot.version>1.3.8.RELEASE</spring.boot.version>
+ <spring.framework.version>4.2.8.RELEASE</spring.framework.version>
+ <spring.framework.security.version>4.0.4.RELEASE</spring.framework.security.version>
+ <spring.framework.security.extensions.version>1.0.2.RELEASE</spring.framework.security.extensions.version>
<opensaml.version>2.6.4</opensaml.version>
<aspectj.version>1.8.9</aspectj.version>
@@ -768,14 +768,30 @@
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-config</artifactId>
+ <version>${spring.framework.security.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ <version>${spring.framework.security.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>${spring.framework.security.version}</version>
</dependency>
<dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-web</artifactId>
+ <version>${spring.framework.security.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework.security.extensions</groupId>
<artifactId>spring-security-saml2-core</artifactId>
<version>${spring.framework.security.extensions.version}</version>
</dependency>
+
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
@@ -1046,7 +1062,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
- <version>1.3.6.RELEASE</version>
+ <version>${spring.boot.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
http://git-wip-us.apache.org/repos/asf/kylin/blob/247f3cd2/server-base/src/main/java/org/apache/kylin/rest/controller2/UserControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/UserControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/UserControllerV2.java
index 2f7a404..c0f5c17 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/UserControllerV2.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/controller2/UserControllerV2.java
@@ -19,6 +19,7 @@
package org.apache.kylin.rest.controller2;
import java.io.IOException;
+import java.util.List;
import org.apache.kylin.rest.controller.BasicController;
import org.apache.kylin.rest.exception.UnauthorizedException;
@@ -59,7 +60,7 @@ public class UserControllerV2 extends BasicController {
@RequestMapping(value = "/authentication", method = RequestMethod.POST, produces = {
"application/vnd.apache.kylin-v2+json" })
@ResponseBody
- public EnvelopeResponse authenticateV2() {
+ public EnvelopeResponse<UserDetails> authenticateV2() {
EnvelopeResponse response = authenticatedUserV2();
logger.debug("User login: {}", response.data);
return response;
@@ -68,7 +69,7 @@ public class UserControllerV2 extends BasicController {
@RequestMapping(value = "/authentication", method = RequestMethod.GET, produces = {
"application/vnd.apache.kylin-v2+json" })
@ResponseBody
- public EnvelopeResponse authenticatedUserV2() {
+ public EnvelopeResponse<UserDetails> authenticatedUserV2() {
Message msg = MsgPicker.getMsg();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
@@ -95,7 +96,7 @@ public class UserControllerV2 extends BasicController {
@RequestMapping(value = "/authentication/authorities", method = RequestMethod.GET, produces = {
"application/vnd.apache.kylin-v2+json" })
@ResponseBody
- public EnvelopeResponse getAuthoritiesV2() throws IOException {
+ public EnvelopeResponse<List<String>> getAuthoritiesV2() throws IOException {
return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, userService.listUserAuthorities(), "");
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/247f3cd2/server-base/src/main/java/org/apache/kylin/rest/response/EnvelopeResponse.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/response/EnvelopeResponse.java b/server-base/src/main/java/org/apache/kylin/rest/response/EnvelopeResponse.java
index 7855dee..8350536 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/response/EnvelopeResponse.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/response/EnvelopeResponse.java
@@ -18,17 +18,17 @@
package org.apache.kylin.rest.response;
-public class EnvelopeResponse {
+public class EnvelopeResponse<T> {
public String code;
- public Object data;
+ public T data;
public String msg;
//only for child
protected EnvelopeResponse() {
}
- public EnvelopeResponse(String code, Object data, String msg) {
+ public EnvelopeResponse(String code, T data, String msg) {
this.code = code;
this.data = data;
this.msg = msg;
http://git-wip-us.apache.org/repos/asf/kylin/blob/247f3cd2/server-base/src/main/java/org/apache/kylin/rest/service/UserService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/UserService.java b/server-base/src/main/java/org/apache/kylin/rest/service/UserService.java
index 5452543..9adfcb8 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/UserService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/UserService.java
@@ -30,13 +30,11 @@ import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.persistence.ResourceStore;
import org.apache.kylin.common.persistence.Serializer;
import org.apache.kylin.common.util.JsonUtil;
-import org.apache.kylin.rest.constant.Constant;
import org.apache.kylin.rest.exception.InternalErrorException;
import org.apache.kylin.rest.msg.Message;
import org.apache.kylin.rest.msg.MsgPicker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
@@ -61,13 +59,13 @@ public class UserService implements UserDetailsManager {
}
@Override
- @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
+ //@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN) --- DON'T DO THIS, CAUSES CIRCULAR DEPENDENCY BETWEEN UserService & AclService
public void createUser(UserDetails user) {
updateUser(user);
}
@Override
- @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
+ //@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN) --- DON'T DO THIS, CAUSES CIRCULAR DEPENDENCY BETWEEN UserService & AclService
public void updateUser(UserDetails user) {
try {
deleteUser(user.getUsername());
http://git-wip-us.apache.org/repos/asf/kylin/blob/247f3cd2/server/src/main/resources/applicationContext.xml
----------------------------------------------------------------------
diff --git a/server/src/main/resources/applicationContext.xml b/server/src/main/resources/applicationContext.xml
index 8416f25..88286b5 100644
--- a/server/src/main/resources/applicationContext.xml
+++ b/server/src/main/resources/applicationContext.xml
@@ -21,15 +21,15 @@
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
+ http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/task
- http://www.springframework.org/schema/task/spring-task-3.1.xsd
+ http://www.springframework.org/schema/task/spring-task-4.2.xsd
http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
+ http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
+ http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
@@ -48,8 +48,7 @@
<!-- Rest service binding -->
- <bean
- class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
+ <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
@@ -58,8 +57,7 @@
<bean id="formHttpMessageConverter"
class="org.springframework.http.converter.FormHttpMessageConverter"/>
- <bean
- class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
+ <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter"/>
@@ -69,19 +67,11 @@
</property>
</bean>
- <bean
- class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
- <property name="mediaTypes">
- <map>
- <entry key="html" value="text/html"/>
- <entry key="json" value="application/json"/>
- </map>
- </property>
+ <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
- <bean
- class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- <property name="prefix" value="/WEB-INF/jsp/"/> -->
<property name="suffix" value=".jsp"/>
</bean>
@@ -89,8 +79,7 @@
</property>
<property name="defaultViews">
<list>
- <bean
- class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
+ <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
</list>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/kylin/blob/247f3cd2/server/src/main/resources/kylinSecurity.xml
----------------------------------------------------------------------
diff --git a/server/src/main/resources/kylinSecurity.xml b/server/src/main/resources/kylinSecurity.xml
index 374341c..43a0082 100644
--- a/server/src/main/resources/kylinSecurity.xml
+++ b/server/src/main/resources/kylinSecurity.xml
@@ -17,12 +17,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/security
- http://www.springframework.org/schema/security/spring-security-3.1.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
-
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ http://www.springframework.org/schema/security/spring-security-4.0.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util-4.2.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context.xsd">
<scr:global-method-security pre-post-annotations="enabled">
<scr:expression-handler ref="expressionHandler"/>
@@ -45,13 +46,13 @@
class="org.springframework.security.acls.domain.AclAuthorizationStrategyImpl">
<constructor-arg>
<list>
- <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+ <bean class="org.springframework.security.core.authority.SimpleGrantedAuthority">
<constructor-arg value="ROLE_ADMIN"/>
</bean>
- <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+ <bean class="org.springframework.security.core.authority.SimpleGrantedAuthority">
<constructor-arg value="ROLE_ADMIN"/>
</bean>
- <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+ <bean class="org.springframework.security.core.authority.SimpleGrantedAuthority">
<constructor-arg value="ROLE_ADMIN"/>
</bean>
</list>