-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
145 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 0 additions & 73 deletions
73
...starter/src/main/java/com/fuhouyu/framework/security/core/AbstractApplicationManager.java
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
...r/src/main/java/com/fuhouyu/framework/security/core/GrantTypeAuthenticationTokenEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2024-2024 the original author or authors. | ||
* | ||
* 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 | ||
* | ||
* https://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 com.fuhouyu.framework.security.core; | ||
|
||
import com.fuhouyu.framework.security.core.authentication.wechat.WechatAppletsPlatformProvider; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.authentication.AbstractAuthenticationToken; | ||
|
||
/** | ||
* <p> | ||
* 默认的映射枚举类 | ||
* </p> | ||
* | ||
* @author fuhouyu | ||
* @since 2024/10/22 21:25 | ||
*/ | ||
@RequiredArgsConstructor | ||
@Getter | ||
@SuppressWarnings("unchecked") | ||
public enum GrantTypeAuthenticationTokenEnum implements GrantTypeAuthenticationTokenMapping { | ||
|
||
WECHAT_APPLETS("WECHAT_APPLETS") { | ||
@Override | ||
public <T extends AbstractAuthenticationToken> Class<T> getAuthenticationTokenClass() { | ||
return (Class<T>) WechatAppletsPlatformProvider.WechatAppletsAuthenticationToken.class; | ||
} | ||
}, | ||
; | ||
|
||
private final String grantType; | ||
|
||
/** | ||
* 安全获取枚举类 | ||
* | ||
* @param grantType 授权类型 | ||
* @return 枚举类 | ||
*/ | ||
public static GrantTypeAuthenticationTokenEnum safeEnumValueOf(String grantType) { | ||
try { | ||
return GrantTypeAuthenticationTokenEnum.valueOf(grantType); | ||
} catch (IllegalArgumentException | NullPointerException e) { | ||
throw new IllegalArgumentException("Invalid value for enum: " + grantType); | ||
} | ||
} | ||
|
||
@Override | ||
public abstract <T extends AbstractAuthenticationToken> Class<T> getAuthenticationTokenClass(); | ||
} |
58 changes: 58 additions & 0 deletions
58
...rc/main/java/com/fuhouyu/framework/security/core/GrantTypeAuthenticationTokenMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2024-2024 the original author or authors. | ||
* | ||
* 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 | ||
* | ||
* https://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 com.fuhouyu.framework.security.core; | ||
|
||
import com.fuhouyu.framework.utils.JacksonUtil; | ||
import org.springframework.security.authentication.AbstractAuthenticationToken; | ||
|
||
/** | ||
* <p> | ||
* 授权类型和AuthenticationToken映射 | ||
* </p> | ||
* | ||
* @author fuhouyu | ||
* @since 2024/10/22 21:18 | ||
*/ | ||
public interface GrantTypeAuthenticationTokenMapping { | ||
|
||
/** | ||
* 获取授权类型 | ||
* | ||
* @return 授权类型 | ||
*/ | ||
String getGrantType(); | ||
|
||
/** | ||
* 获取授权token类型 | ||
* | ||
* @param <T> 具体的子类 | ||
* @return 授权token类型 | ||
*/ | ||
<T extends AbstractAuthenticationToken> Class<T> getAuthenticationTokenClass(); | ||
|
||
/** | ||
* 加载该类 | ||
* | ||
* @param param 参数映射 | ||
* @return AbstractAuthenticationToken 子类 | ||
*/ | ||
default AbstractAuthenticationToken loadAuthenticationToken(Object param) { | ||
Class<AbstractAuthenticationToken> authenticationTokenClass = this.getAuthenticationTokenClass(); | ||
return JacksonUtil.tryParse(() -> | ||
JacksonUtil.getObjectMapper().convertValue(param, authenticationTokenClass)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
...src/main/java/com/fuhouyu/framework/security/core/filter/ApplicationBasicErrorFilter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.