Skip to content

Commit

Permalink
package refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
archcentric committed Apr 18, 2018
1 parent 067f185 commit b71ac1c
Show file tree
Hide file tree
Showing 46 changed files with 105 additions and 428 deletions.
9 changes: 8 additions & 1 deletion lab05/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@

[源码](https://github.com/Baeldung/spring-security-oauth)


### 实验步骤
1. 需要启动mysql数据库,在oauth-server/src/main/resources/persistence.properties设置数据库访问用户名/密码
2. 依次启动:
* 授权服务器oauth-server(8081)
* 资源服务器oauth-resource(8082)
* AngularJS单页应用oauth-ui-implicit(0803)
3. 浏览器打开http://localhost:8083 开始实验
4. 登录用户名密码在oauth-server/.../WebSecurityConfig中配置
16 changes: 16 additions & 0 deletions lab05/angularjs/oauth-ui-implicit/.springBeans
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[3.9.2.201712210913-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>java:io.spring2go.config.UiApplication</config>
</configs>
<autoconfigs>
</autoconfigs>
<configSets>
</configSets>
</beansProjectDescription>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<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>
<artifactId>spring-security-oauth-ui-implicit</artifactId>
<artifactId>oauth-ui-implicit</artifactId>

<name>spring-security-oauth-ui-implicit</name>
<name>oauth-ui-implicit</name>
<packaging>war</packaging>

<parent>
<groupId>org.baeldung</groupId>
<groupId>io.spring2go</groupId>
<artifactId>spring-security-oauth</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
Expand Down Expand Up @@ -56,7 +56,7 @@
</dependencies>

<build>
<finalName>spring-security-oauth-ui-implicit</finalName>
<finalName>oauth-ui-implicit</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


<oauth
site="http://localhost:8081/spring-security-oauth-server"
site="http://localhost:8081"
client-id="sampleClientId"
redirect-uri="http://localhost:8083/"
scope="read write foo bar"
Expand Down Expand Up @@ -57,7 +57,7 @@
});

$scope.foo = {id:0 , name:"sample foo"};
$scope.foos = $resource("http://localhost:8082/spring-security-oauth-resource/foos/:fooId",{fooId:'@id'});
$scope.foos = $resource("http://localhost:8082/foos/:fooId",{fooId:'@id'});

$scope.getFoo = function(){
$scope.foo = $scope.foos.get({fooId:$scope.foo.id});
Expand All @@ -77,7 +77,7 @@

// bar
$scope.bar = {id:0 , name:"sample bar"};
$scope.bars = $resource("http://localhost:8082/spring-security-oauth-resource/bars/:barId",{barId:'@id'});
$scope.bars = $resource("http://localhost:8082/bars/:barId",{barId:'@id'});

$scope.getBar = function(){
$scope.bar = $scope.bars.get({barId:$scope.bar.id});
Expand All @@ -95,8 +95,8 @@
});
}

$scope.revokeToken = $resource("http://localhost:8081/spring-security-oauth-server/oauth/token/revokeById/:tokenId",{tokenId:'@tokenId'});
$scope.tokens = $resource("http://localhost:8081/spring-security-oauth-server/tokens");
$scope.revokeToken = $resource("http://localhost:8081/oauth/token/revokeById/:tokenId",{tokenId:'@tokenId'});
$scope.tokens = $resource("http://localhost:8081/tokens");

$scope.getTokens = function(){
$scope.tokenList = $scope.tokens.query();
Expand Down

This file was deleted.

16 changes: 16 additions & 0 deletions lab05/oauth-resource/.springBeans
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[3.9.2.201712210913-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>java:io.spring2go.config.ResourceServerApplication</config>
</configs>
<autoconfigs>
</autoconfigs>
<configSets>
</configSets>
</beansProjectDescription>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<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>
<artifactId>spring-security-oauth-resource</artifactId>
<name>spring-security-oauth-resource</name>
<artifactId>oauth-resource</artifactId>
<name>oauth-resource</name>
<packaging>war</packaging>

<parent>
<groupId>org.baeldung</groupId>
<groupId>io.spring2go</groupId>
<artifactId>spring-security-oauth</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
Expand Down Expand Up @@ -45,11 +45,6 @@
<artifactId>spring-security-oauth2</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down Expand Up @@ -95,7 +90,7 @@
</dependencies>

<build>
<finalName>spring-security-oauth-resource</finalName>
<finalName>oauth-resource</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -26,7 +26,7 @@ public void configure(final HttpSecurity http) throws Exception {
@Bean
public RemoteTokenServices tokenServices() {
final RemoteTokenServices tokenService = new RemoteTokenServices();
tokenService.setCheckTokenEndpointUrl("http://localhost:8081/spring-security-oauth-server/oauth/check_token");
tokenService.setCheckTokenEndpointUrl("http://localhost:8081/oauth/check_token");
tokenService.setClientId("fooClientIdPassword");
tokenService.setClientSecret("secret");
return tokenService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
Expand All @@ -7,7 +7,7 @@

@Configuration
@EnableWebMvc
@ComponentScan({ "org.baeldung.web.controller" })
@ComponentScan({ "io.spring2go.web.controller" })
public class ResourceServerWebConfig extends WebMvcConfigurerAdapter {
//
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.baeldung.web.controller;
package io.spring2go.web.controller;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;

import org.baeldung.web.dto.Bar;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
Expand All @@ -14,6 +13,8 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import io.spring2go.web.dto.Bar;

@Controller
public class BarController {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.baeldung.web.controller;
package io.spring2go.web.controller;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;

import org.baeldung.web.dto.Foo;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
Expand All @@ -14,6 +13,8 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import io.spring2go.web.dto.Foo;

@Controller
public class FooController {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package io.spring2go.web.dto;

public class Bar {
private long id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package io.spring2go.web.dto;

public class Foo {
private long id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
server.contextPath=/spring-security-oauth-resource
server.port=8082
logging.level.org=INFO
#endpoints.cors.allowed-origins=*
16 changes: 16 additions & 0 deletions lab05/oauth-server/.springBeans
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[3.9.2.201712210913-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>java:io.spring2go.config.AuthorizationServerApplication</config>
</configs>
<autoconfigs>
</autoconfigs>
<configSets>
</configSets>
</beansProjectDescription>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<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>
<artifactId>spring-security-oauth-server</artifactId>
<artifactId>oauth-server</artifactId>

<name>spring-security-oauth-server</name>
<name>oauth-server</name>
<packaging>war</packaging>

<parent>
<groupId>org.baeldung</groupId>
<groupId>io.spring2go</groupId>
<artifactId>spring-security-oauth</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
Expand Down Expand Up @@ -47,11 +47,6 @@
<artifactId>spring-security-oauth2</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down Expand Up @@ -94,7 +89,7 @@
</dependencies>

<build>
<finalName>spring-security-oauth-server</finalName>
<finalName>oauth-server</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -165,7 +160,7 @@

<properties>
<!-- The main class to start by executing java -jar -->
<start-class>org.baeldung.config.AuthorizationServerApplication</start-class>
<start-class>io.spring2go.AuthorizationServerApplication</start-class>
</properties>
<!-- <profiles> <profile> <id>dev</id> <build> <resources> <resource> <directory>src/main/resources</directory>
<filtering>true</filtering> <excludes> <exclude>*.jks</exclude> </excludes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import java.util.ArrayList;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.baeldung.config;
package io.spring2go.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
Expand Down
3 changes: 3 additions & 0 deletions lab05/oauth-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
server.port=8081

#spring.profiles.active=dev
Loading

0 comments on commit b71ac1c

Please sign in to comment.