Browse Source

完善部分注释

zhou-hao 7 years ago
parent
commit
c8f203b9ee
25 changed files with 148 additions and 39 deletions
  1. 4 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/builder/AuthenticationBuilderFactory.java
  2. 4 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/builder/DataAccessConfigBuilderFactory.java
  3. 1 3
      hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/WebUserTokenInterceptor.java
  4. 1 1
      hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/AuthorizationServerAutoConfiguration.java
  5. 2 3
      hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/EnableAuthorizationClient.java
  6. 2 3
      hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/EnableAuthorizationServer.java
  7. 1 3
      hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/client/feign/FeignAuthorizationAutoConfiguration.java
  8. 1 1
      hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/client/feign/FeignUserTokenManager.java
  9. 6 2
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/AuthorizationService.java
  10. 10 1
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/client/ClientCredentialGranter.java
  11. 7 1
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/code/AuthorizationCodeGranter.java
  12. 20 1
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/code/AuthorizationCodeRequest.java
  13. 16 1
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/code/AuthorizationCodeTokenRequest.java
  14. 1 2
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/password/PasswordGranter.java
  15. 0 2
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/request/definition/ResponseConvertForProviderDefinition.java
  16. 7 0
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/pom.xml
  17. 40 0
      hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/scope/ScopeParser.java
  18. 3 3
      hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/AsyncJobException.java
  19. 4 1
      hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/AsyncJobService.java
  20. 0 2
      hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/AsyncJobServiceAutoConfiguration.java
  21. 2 1
      hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/SpringTransactionSupportJob.java
  22. 7 2
      hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/TransactionSupportJob.java
  23. 8 1
      hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/TransactionSupportJobWrapper.java
  24. 0 1
      hsweb-concurrent/hsweb-concurrent-async-job/src/test/java/org/hswebframework/web/async/TransactionSupportAsyncJobServiceTest.java
  25. 1 2
      hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-entity/src/main/java/org/hswebframework/web/authorization/oauth2/server/entity/AuthorizationCodeEntity.java

+ 4 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/builder/AuthenticationBuilderFactory.java

@@ -1,10 +1,13 @@
 package org.hswebframework.web.authorization.builder;
 
 /**
- * TODO 完成注释
+ * 权限构造器工厂
  *
  * @author zhouhao
  */
 public interface AuthenticationBuilderFactory {
+    /**
+     * @return 新建一个权限构造器
+     */
     AuthenticationBuilder create();
 }

+ 4 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/builder/DataAccessConfigBuilderFactory.java

@@ -1,10 +1,13 @@
 package org.hswebframework.web.authorization.builder;
 
 /**
- * TODO 完成注释
+ * 数据权限配置构造器工厂
  *
  * @author zhouhao
  */
 public interface DataAccessConfigBuilderFactory {
+    /**
+     * @return 新建一个数据权限配置构造器工厂
+     */
     DataAccessConfigBuilder create();
 }

+ 1 - 3
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/WebUserTokenInterceptor.java

@@ -1,7 +1,5 @@
 package org.hswebframework.web.authorization.basic.web;
 
-import org.hswebframework.web.authorization.exception.UnAuthorizedException;
-import org.hswebframework.web.authorization.token.TokenState;
 import org.hswebframework.web.authorization.token.UserToken;
 import org.hswebframework.web.authorization.token.UserTokenHolder;
 import org.hswebframework.web.authorization.token.UserTokenManager;
@@ -14,7 +12,7 @@ import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
- * TODO 完成注释
+ * 用户令牌拦截器,用于拦截用户请求并从中解析用户令牌信息
  *
  * @author zhouhao
  */

+ 1 - 1
hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/AuthorizationServerAutoConfiguration.java

@@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration;
 
 /**
  * @author zhouhao
- * @since
+ * @since 3.0
  */
 @Configuration
 public class AuthorizationServerAutoConfiguration {

+ 2 - 3
hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/EnableAuthorizationClient.java

@@ -5,10 +5,9 @@ import org.springframework.context.annotation.Import;
 import java.lang.annotation.*;
 
 /**
- * TODO 完成注释
- *
+ * 启用权限认证客户端
  * @author zhouhao
- * @since
+ * @since 3.0
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)

+ 2 - 3
hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/EnableAuthorizationServer.java

@@ -5,10 +5,9 @@ import org.springframework.context.annotation.Import;
 import java.lang.annotation.*;
 
 /**
- * TODO 完成注释
- *
+ * 启用权限认证服务端
  * @author zhouhao
- * @since
+ * @since 3.0
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)

+ 1 - 3
hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/client/feign/FeignAuthorizationAutoConfiguration.java

@@ -4,10 +4,8 @@ import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.annotation.Configuration;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
- * @since
+ * @since 3.0
  */
 @Configuration
 @EnableFeignClients("org.hswebframework.web.authorization.cloud.client.feign")

+ 1 - 1
hsweb-authorization/hsweb-authorization-cloud/src/main/java/org/hswebframework/web/authorization/cloud/client/feign/FeignUserTokenManager.java

@@ -10,7 +10,7 @@ import java.util.List;
 
 /**
  * @author zhouhao
- * @since
+ * @since 3.0
  */
 @FeignClient(name = "${hsweb.cloud.user-center.name:user-center}")
 public interface FeignUserTokenManager extends UserTokenManager {

+ 6 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/AuthorizationService.java

@@ -19,9 +19,13 @@
 package org.hswebframework.web.authorization.oauth2.server;
 
 /**
- * TODO 完成注释
- *
+ * 授权服务
  * @author zhouhao
+ * @see org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCodeGranter
+ * @see org.hswebframework.web.authorization.oauth2.server.support.client.ClientCredentialGranter
+ * @see org.hswebframework.web.authorization.oauth2.server.support.refresh.RefreshTokenGranter
+ * @see org.hswebframework.web.authorization.oauth2.server.support.implicit.ImplicitGranter
+ * @see org.hswebframework.web.authorization.oauth2.server.support.password.PasswordGranter
  */
 public interface AuthorizationService {
 }

+ 10 - 1
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/client/ClientCredentialGranter.java

@@ -20,12 +20,21 @@ package org.hswebframework.web.authorization.oauth2.server.support.client;
 
 import org.hswebframework.web.authorization.oauth2.server.AuthorizationService;
 import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken;
+import org.hswebframework.web.authorization.oauth2.server.exception.GrantTokenException;
 
 /**
- * TODO 完成注释
+ * client_credential方式认证器
  *
  * @author zhouhao
+ * @see org.hswebframework.web.oauth2.core.GrantType#client_credentials
  */
 public interface ClientCredentialGranter extends AuthorizationService {
+    /**
+     * 申请token
+     * @param request 请求参数
+     * @return 申请成功的token信息
+     * @throws GrantTokenException
+     * @see org.hswebframework.web.oauth2.core.ErrorType
+     */
     OAuth2AccessToken requestToken(ClientCredentialRequest request);
 }

+ 7 - 1
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/code/AuthorizationCodeGranter.java

@@ -22,10 +22,16 @@ import org.hswebframework.web.authorization.oauth2.server.AuthorizationService;
 import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken;
 
 /**
- * TODO 完成注释
+ * authorization_code方式申请token
  *
  * @author zhouhao
+ * @see org.hswebframework.web.oauth2.core.GrantType#authorization_code
  */
 public interface AuthorizationCodeGranter extends AuthorizationService {
+    /**
+     * 申请token
+     * @param request
+     * @return
+     */
     OAuth2AccessToken requestToken(AuthorizationCodeTokenRequest request);
 }

+ 20 - 1
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/code/AuthorizationCodeRequest.java

@@ -18,19 +18,38 @@
 
 package org.hswebframework.web.authorization.oauth2.server.support.code;
 
+import org.hswebframework.web.authorization.User;
+import org.hswebframework.web.authorization.oauth2.server.client.OAuth2Client;
+
 import java.util.Set;
 
 /**
- * TODO 完成注释
+ * 授权码请求
  *
  * @author zhouhao
  */
 public interface AuthorizationCodeRequest {
+    /**
+     * @return oauth2客户端id
+     * @see org.hswebframework.web.oauth2.core.OAuth2Constants#client_id
+     * @see OAuth2Client#getId()
+     */
     String getClientId();
 
+    /**
+     * @return 与授权码关联的用户ID
+     * @see User#getId()
+     */
     String getUserId();
 
+    /**
+     * @return 允许授权的范围
+     */
     Set<String> getScope();
 
+    /**
+     * @return 重定向地址
+     * @see org.hswebframework.web.oauth2.core.OAuth2Constants#redirect_uri
+     */
     String getRedirectUri();
 }

+ 16 - 1
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/code/AuthorizationCodeTokenRequest.java

@@ -23,18 +23,33 @@ import org.hswebframework.web.authorization.oauth2.server.TokenRequest;
 import java.util.Set;
 
 /**
- * TODO 完成注释
+ * 授权码方式token请求
  *
  * @author zhouhao
  */
 public interface AuthorizationCodeTokenRequest extends TokenRequest {
+    /**
+     * @return 搜权码
+     */
     String getCode();
 
+    /**
+     * @return oauth2客户端id
+     */
     String getClientId();
 
+    /**
+     * @return oauth2客户端密钥
+     */
     String getClientSecret();
 
+    /**
+     * @return 申请授权范围
+     */
     Set<String> getScope();
 
+    /**
+     * @return 重定向地址
+     */
     String getRedirectUri();
 }

+ 1 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/password/PasswordGranter.java

@@ -22,8 +22,7 @@ import org.hswebframework.web.authorization.oauth2.server.AuthorizationService;
 import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken;
 
 /**
- * TODO 完成注释
- *
+ * 密码方式授权
  * @author zhouhao
  */
 public interface PasswordGranter extends AuthorizationService {

+ 0 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/request/definition/ResponseConvertForProviderDefinition.java

@@ -21,8 +21,6 @@ package org.hswebframework.web.authorization.oauth2.client.request.definition;
 import org.hswebframework.web.authorization.oauth2.client.request.ResponseConvertHandler;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public interface ResponseConvertForProviderDefinition extends ResponseConvertHandler {

+ 7 - 0
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/pom.xml

@@ -31,4 +31,11 @@
     <artifactId>hsweb-authorization-oauth2-core</artifactId>
 
 
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-authorization-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
 </project>

+ 40 - 0
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/scope/ScopeParser.java

@@ -0,0 +1,40 @@
+package org.hswebframework.web.oauth2.core.scope;
+
+import org.hswebframework.web.authorization.Permission;
+
+import java.util.Set;
+
+/**
+ * scope解析器
+ *
+ * @author zhouhao
+ */
+public interface ScopeParser {
+    /**
+     * 将文本解析为Set
+     * <pre>
+     *     user-info:get user-share:push
+     * </pre>
+     * <pre>
+     *     Set{"user-info:get","user-share:push"}
+     * </pre>
+     *
+     * @param scopeText socket文本
+     * @return socpe集合
+     */
+    Set<String> fromScopeText(String scopeText);
+
+    String toScopeText(Set<String> scopeText);
+
+    /**
+     * 将scope解析为Permission
+     *
+     * @param scope scope集合
+     * @return permission集合。如果参数为null或者空,则返回空集合
+     */
+    Set<Permission> parsePermission(Set<String> scope);
+
+    default Set<Permission> parsePermission(String scopeText) {
+        return parsePermission(fromScopeText(scopeText));
+    }
+}

+ 3 - 3
hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/AsyncJobException.java

@@ -6,12 +6,12 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 /**
- * TODO 完成注释
- *
+ * 异步任务执行异常
  * @author zhouhao
  */
 public class AsyncJobException extends RuntimeException {
-   private List<Exception> errors;
+    private static final long serialVersionUID = 4003904073250315538L;
+    private List<Exception> errors;
 
     public AsyncJobException(List<Exception> errors) {
        this(errors.size()>0?errors.get(0).getMessage():null,errors);

+ 4 - 1
hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/AsyncJobService.java

@@ -1,10 +1,13 @@
 package org.hswebframework.web.async;
 
 /**
- * TODO 完成注释
+ * 异步任务服务
  *
  * @author zhouhao
  */
 public interface AsyncJobService {
+    /**
+     * @return 创建一个异步任务容器
+     */
     BatchAsyncJobContainer batch();
 }

+ 0 - 2
hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/AsyncJobServiceAutoConfiguration.java

@@ -9,8 +9,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 @Configuration

+ 2 - 1
hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/SpringTransactionSupportJob.java

@@ -7,9 +7,10 @@ import org.springframework.transaction.support.TransactionTemplate;
 import java.util.concurrent.Callable;
 
 /**
- * TODO 完成注释
+ * 使用spring管理事务的异步任务
  *
  * @author zhouhao
+ * @see TransactionTemplate
  */
 public class SpringTransactionSupportJob<V> implements TransactionSupportJob<V> {
 

+ 7 - 2
hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/TransactionSupportJob.java

@@ -3,13 +3,18 @@ package org.hswebframework.web.async;
 import java.util.concurrent.Callable;
 
 /**
- * TODO 完成注释
- *
+ * 支持事务的异步任务
  * @author zhouhao
  */
 public interface TransactionSupportJob<V> extends Callable<V> {
 
+    /**
+     * 回滚
+     */
     void rollBackOnly();
 
+    /**
+     * 提交事务
+     */
     void commit();
 }

+ 8 - 1
hsweb-concurrent/hsweb-concurrent-async-job/src/main/java/org/hswebframework/web/async/TransactionSupportJobWrapper.java

@@ -3,10 +3,17 @@ package org.hswebframework.web.async;
 import java.util.concurrent.Callable;
 
 /**
- * TODO 完成注释
+ * 支持事务的任务包装器
  *
  * @author zhouhao
  */
 public interface TransactionSupportJobWrapper {
+    /**
+     * 将一个普通任务包装为支持事务的任务
+     *
+     * @param callable 普通任务
+     * @param <V>      任务返回值类型
+     * @return 支持事务的任务
+     */
     <V> TransactionSupportJob<V> wrapper(Callable<V> callable);
 }

+ 0 - 1
hsweb-concurrent/hsweb-concurrent-async-job/src/test/java/org/hswebframework/web/async/TransactionSupportAsyncJobServiceTest.java

@@ -21,7 +21,6 @@ import java.util.concurrent.Executors;
 import static org.junit.Assert.*;
 
 /**
- * TODO 完成注释
  *
  * @author zhouhao
  */

+ 1 - 2
hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-entity/src/main/java/org/hswebframework/web/authorization/oauth2/server/entity/AuthorizationCodeEntity.java

@@ -22,8 +22,7 @@ import org.hswebframework.web.authorization.oauth2.server.support.code.Authoriza
 import org.hswebframework.web.commons.entity.Entity;
 
 /**
- * TODO 完成注释
- *
+ * 授权码
  * @author zhouhao
  */
 public interface AuthorizationCodeEntity extends AuthorizationCode, Entity {