Bläddra i källkod

修复包报错

zhouhao 7 år sedan
förälder
incheckning
12dc5801e1

+ 6 - 1
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/OAuth2ClientAutoConfiguration.java

@@ -2,8 +2,10 @@ package org.hswebframework.web.authorization.oauth2.client;
 
 import org.hswebframework.expands.request.RequestBuilder;
 import org.hswebframework.expands.request.SimpleRequestBuilder;
+import org.hswebframework.web.authorization.builder.AuthenticationBuilderFactory;
 import org.hswebframework.web.authorization.oauth2.client.request.DefaultResponseJudge;
 import org.hswebframework.web.authorization.oauth2.client.simple.*;
+import org.hswebframework.web.authorization.oauth2.client.simple.provider.HswebResponseConvertSupport;
 import org.hswebframework.web.authorization.oauth2.client.simple.request.builder.SimpleOAuth2RequestBuilderFactory;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -21,11 +23,14 @@ public class OAuth2ClientAutoConfiguration {
         return new SimpleRequestBuilder();
     }
 
+
     @Bean
     @ConditionalOnMissingBean(OAuth2RequestBuilderFactory.class)
-    public SimpleOAuth2RequestBuilderFactory simpleOAuth2RequestBuilderFactory(RequestBuilder requestBuilder) {
+    public SimpleOAuth2RequestBuilderFactory simpleOAuth2RequestBuilderFactory(RequestBuilder requestBuilder,
+                                                                               AuthenticationBuilderFactory authenticationBuilderFactory) {
         SimpleOAuth2RequestBuilderFactory builderFactory = new SimpleOAuth2RequestBuilderFactory();
         builderFactory.setRequestBuilder(requestBuilder);
+        builderFactory.setDefaultConvertHandler(new HswebResponseConvertSupport(authenticationBuilderFactory));
         builderFactory.setDefaultResponseJudge(new DefaultResponseJudge());
         return builderFactory;
     }

+ 0 - 70
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2UserTokenService.java

@@ -1,70 +0,0 @@
-/*
- *  Copyright 2016 http://www.hswebframework.org
- *  
- *  Licensed 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.hswebframework.web.authorization.oauth2.client.simple;
-
-import org.hswebframework.web.dao.oauth2.client.OAuth2UserTokenDao;
-import org.hswebframework.web.entity.oauth2.client.OAuth2UserTokenEntity;
-import org.hswebframework.web.id.IDGenerator;
-import org.hswebframework.web.service.GenericEntityService;
-import org.hswebframework.web.service.oauth2.client.OAuth2UserTokenService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Service;
-import org.springframework.util.Assert;
-
-import java.util.List;
-
-/**
- * 默认的服务实现
- *
- * @author hsweb-generator-online
- */
-@Service("oAuth2UserTokenService")
-public class SimpleOAuth2UserTokenService extends GenericEntityService<OAuth2UserTokenEntity, String>
-        implements OAuth2UserTokenService {
-    @Autowired
-    private OAuth2UserTokenDao oAuth2UserTokenDao;
-
-    @Override
-    protected IDGenerator<String> getIDGenerator() {
-        return IDGenerator.MD5;
-    }
-
-    @Override
-    public OAuth2UserTokenDao getDao() {
-        return oAuth2UserTokenDao;
-    }
-
-    @Override
-    @Cacheable(cacheNames = "oauth2-user-token", key = "'s-g-t:'+#serverId+':'+#grantType")
-    public List<OAuth2UserTokenEntity> selectByServerIdAndGrantType(String serverId, String grantType) {
-        Assert.notNull(serverId, "serverId can not be null!");
-        Assert.notNull(grantType, "grantType can not be null!");
-        return createQuery()
-                .where(OAuth2UserTokenEntity.serverId, serverId)
-                .is(OAuth2UserTokenEntity.grantType, grantType)
-                .listNoPaging();
-    }
-
-    @Override
-    @Cacheable(cacheNames = "oauth2-user-token", key = "'a-t:'+#serverId+':'+#grantType")
-    public OAuth2UserTokenEntity selectByAccessToken(String accessToken) {
-        Assert.notNull(accessToken, "token can not be null!");
-        return createQuery().where(OAuth2UserTokenEntity.accessToken, accessToken)
-                .single();
-    }
-}

+ 1 - 3
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupport.java

@@ -31,13 +31,11 @@ import java.util.List;
 /**
  * @author zhouhao
  */
-@Component
 public class HswebResponseConvertSupport implements ResponseConvertForProviderDefinition {
 
     private AuthenticationBuilderFactory authenticationBuilderFactory;
 
-    @Autowired(required = false)
-    public void setAuthenticationBuilderFactory(AuthenticationBuilderFactory authenticationBuilderFactory) {
+    public HswebResponseConvertSupport(AuthenticationBuilderFactory authenticationBuilderFactory) {
         this.authenticationBuilderFactory = authenticationBuilderFactory;
     }
 

+ 1 - 1
hsweb-examples/hsweb-examples-oauth2/hsweb-examples-oauth2-client/src/main/java/org/hswebframework/web/example/oauth2/OAuth2SSOAuthorizingListener.java

@@ -74,7 +74,7 @@ public class OAuth2SSOAuthorizingListener
                 .getHttpServletRequest()
                 .getSession();
 
-        userTokenManager.signIn(httpSession.getId(), authentication.getUser().getId(), 60 * 60 * 1000);
+        userTokenManager.signIn(httpSession.getId(), "sessionId",authentication.getUser().getId(), 60 * 60 * 1000);
 
 
     }

+ 1 - 1
hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseConvertSupport.java

@@ -19,8 +19,8 @@
 package org.hswebframework.web.starter.oauth2.client;
 
 import com.alibaba.fastjson.JSON;
+import org.hswebframework.web.authorization.oauth2.client.request.definition.ResponseConvertForProviderDefinition;
 import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response;
-import org.hswebframework.web.service.oauth2.client.request.definition.ResponseConvertForProviderDefinition;
 import org.springframework.stereotype.Component;
 
 import java.util.List;

+ 1 - 1
hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseJudgeSupport.java

@@ -20,9 +20,9 @@ package org.hswebframework.web.starter.oauth2.client;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import org.hswebframework.web.authorization.oauth2.client.request.definition.ResponseJudgeForProviderDefinition;
 import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response;
 import org.hswebframework.web.oauth2.core.ErrorType;
-import org.hswebframework.web.service.oauth2.client.request.definition.ResponseJudgeForProviderDefinition;
 import org.springframework.stereotype.Component;
 
 import java.util.HashMap;