Skip to content

Commit 0198fd2

Browse files
committed
增加OAuth2
1 parent 7e48f4b commit 0198fd2

File tree

20 files changed

+1122
-12
lines changed

20 files changed

+1122
-12
lines changed

hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Authorization.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
/**
2828
* 用户授权信息,当前登录用户的权限信息,包括用户的基本信息,角色,权限集合等常用信息<br>
29-
* 如何获取:
29+
* 获取方式:
3030
* <ul>
31-
* <li>springmvc 入参方式: ResponseMessage myTest(@AuthInfo Authorization auth){}</li>
31+
* <li>springmvc 入参方式: ResponseMessage myTest(Authorization auth){}</li>
3232
* <li>静态方法方式:AuthorizationHolder.get();</li>
3333
* </ul>
3434
*
@@ -39,23 +39,17 @@
3939
public interface Authorization extends Serializable {
4040

4141
/**
42-
* 获取用户基本信息
43-
*
4442
* @return 用户信息
4543
*/
4644
User getUser();
4745

4846
/**
49-
* 获取持有的角色集合
50-
*
51-
* @return 角色集合
47+
* @return 用户持有的角色集合
5248
*/
5349
List<Role> getRoles();
5450

5551
/**
56-
* 获取持有的权限集合
57-
*
58-
* @return 权限集合
52+
* @return 用户持有的权限集合
5953
*/
6054
List<Permission> getPermissions();
6155

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
*/
18+
19+
package org.hswebframework.web.authorization;
20+
21+
/**
22+
* TODO 完成注释
23+
*
24+
* @author zhouhao
25+
*/
26+
public interface AuthorizationInitializeService {
27+
Authorization initUserAuthorization(String userId);
28+
29+
Authorization initAdminAuthorization(String userId);
30+
}

hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Permission.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
import java.util.Set;
2525

2626
/**
27-
* 用户持有的权限信息
27+
* 用户持有的权限信息,包含了权限基本信息、可操作范围(action)、行,列级权限控制规则。
28+
* 是用户权限的重要接口。
2829
*
2930
* @author zhouhao
3031
* @see Authorization
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2016 http://www.hswebframework.org
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
~
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<parent>
24+
<artifactId>hsweb-authorization-oauth2-server</artifactId>
25+
<groupId>org.hswebframework.web</groupId>
26+
<version>3.0-SNAPSHOT</version>
27+
</parent>
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<artifactId>hsweb-authorization-oauth2-server-api</artifactId>
31+
32+
<dependencies>
33+
<dependency>
34+
<groupId>org.hswebframework.web</groupId>
35+
<artifactId>hsweb-authorization-oauth2-server-entity</artifactId>
36+
<version>${project.version}</version>
37+
</dependency>
38+
</dependencies>
39+
</project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
*/
18+
19+
package org.hswebframework.web.authorization.oauth2.api;
20+
21+
import org.hswebframework.web.authorization.oauth2.entity.OAuth2AccessEntity;
22+
import org.hswebframework.web.authorization.oauth2.entity.OAuth2ClientEntity;
23+
24+
/**
25+
* @author zhouhao
26+
*/
27+
public interface OAuth2ServerService {
28+
29+
OAuth2ClientEntity getClient(String clientId);
30+
31+
OAuth2ClientEntity getClient(String clientId, String clientSecret);
32+
33+
OAuth2AccessEntity getAccessByToken(String accessToken);
34+
35+
String requestCode(String clientId, String userId, String scope);
36+
37+
OAuth2AccessEntity requestTokenByCode(String code, String clientId, String clientSecret, String scope);
38+
39+
OAuth2AccessEntity requestTokenByClientCredential(String clientId, String clientSecret);
40+
41+
OAuth2AccessEntity requestTokenByPassword(String username, String password);
42+
43+
OAuth2AccessEntity refreshToken(String clientId, String clientSecret, String refreshToken, String scope);
44+
45+
OAuth2AccessEntity getAccessToken(String accessToken);
46+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2016 http://www.hswebframework.org
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
~
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<parent>
24+
<artifactId>hsweb-authorization-oauth2-server-dao</artifactId>
25+
<groupId>org.hswebframework.web</groupId>
26+
<version>3.0-SNAPSHOT</version>
27+
</parent>
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<artifactId>hsweb-authorization-oauth2-server-dao-api</artifactId>
31+
32+
<dependencies>
33+
<dependency>
34+
<groupId>org.hswebframework.web</groupId>
35+
<artifactId>hsweb-commons-dao-api</artifactId>
36+
<version>${project.version}</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.hswebframework.web</groupId>
40+
<artifactId>hsweb-authorization-oauth2-server-entity</artifactId>
41+
<version>${project.version}</version>
42+
</dependency>
43+
</dependencies>
44+
45+
</project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
*/
18+
19+
package org.hswebframework.web.authorization.oauth2.dao;
20+
21+
import org.hswebframework.web.authorization.oauth2.entity.AuthorizationCodeEntity;
22+
import org.hswebframework.web.dao.InsertDao;
23+
import org.hswebframework.web.dao.dynamic.DeleteByEntityDao;
24+
import org.hswebframework.web.dao.dynamic.QueryByEntityDao;
25+
26+
/**
27+
* TODO 完成注释
28+
*
29+
* @author zhouhao
30+
*/
31+
public interface AuthorizationCodeDao extends
32+
InsertDao<AuthorizationCodeEntity>,
33+
DeleteByEntityDao,
34+
QueryByEntityDao<AuthorizationCodeEntity> {
35+
36+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
*/
18+
19+
package org.hswebframework.web.authorization.oauth2.dao;
20+
21+
import org.hswebframework.web.authorization.oauth2.entity.OAuth2AccessEntity;
22+
import org.hswebframework.web.dao.InsertDao;
23+
import org.hswebframework.web.dao.dynamic.DeleteByEntityDao;
24+
import org.hswebframework.web.dao.dynamic.QueryByEntityDao;
25+
import org.hswebframework.web.dao.dynamic.UpdateByEntityDao;
26+
27+
/**
28+
* @author zhouhao
29+
*/
30+
public interface OAuth2AccessDao extends
31+
InsertDao<OAuth2AccessEntity>,
32+
DeleteByEntityDao,
33+
UpdateByEntityDao,
34+
QueryByEntityDao<OAuth2AccessEntity> {
35+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
*/
18+
19+
package org.hswebframework.web.authorization.oauth2.dao;
20+
21+
import org.hswebframework.web.authorization.oauth2.entity.OAuth2ClientEntity;
22+
import org.hswebframework.web.dao.CrudDao;
23+
24+
/**
25+
* TODO 完成注释
26+
*
27+
* @author zhouhao
28+
*/
29+
public interface OAuth2ClientDao extends CrudDao<OAuth2ClientEntity, String> {
30+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2016 http://www.hswebframework.org
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
~
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<parent>
24+
<artifactId>hsweb-authorization-oauth2-server</artifactId>
25+
<groupId>org.hswebframework.web</groupId>
26+
<version>3.0-SNAPSHOT</version>
27+
</parent>
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<artifactId>hsweb-authorization-oauth2-server-dao</artifactId>
31+
<packaging>pom</packaging>
32+
<modules>
33+
<module>hsweb-authorization-oauth2-server-dao-api</module>
34+
</modules>
35+
36+
37+
</project>

0 commit comments

Comments
 (0)