mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-01 18:35:37 +08:00
优化代码
This commit is contained in:
@@ -52,13 +52,11 @@ public final class AuthenticationHolder {
|
||||
private static Authentication get(Function<AuthenticationSupplier, Authentication> function) {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
Authentication authentication = suppliers.stream()
|
||||
return suppliers.stream()
|
||||
.map(function)
|
||||
.filter(Objects::nonNull)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
return authentication;
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
|
||||
@@ -31,11 +31,13 @@ import java.util.function.Function;
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class AbstractAuthorizationEvent extends ApplicationEvent implements AuthorizationEvent {
|
||||
private static final long serialVersionUID = -3027505108916079214L;
|
||||
|
||||
protected String username;
|
||||
|
||||
protected String password;
|
||||
|
||||
private Function<String, Object> parameterGetter;
|
||||
private transient Function<String, Object> parameterGetter;
|
||||
|
||||
/**
|
||||
* 带参构造方法,所有参数不能为null
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class AuthorizationBeforeEvent extends AbstractAuthorizationEvent {
|
||||
|
||||
private static final long serialVersionUID = 5948747533500518524L;
|
||||
|
||||
public AuthorizationBeforeEvent(String username, String password, Function<String, Object> parameterGetter) {
|
||||
super(username, password, parameterGetter);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class AuthorizationDecodeEvent extends AbstractAuthorizationEvent {
|
||||
|
||||
private static final long serialVersionUID = 5418501934490174251L;
|
||||
|
||||
public AuthorizationDecodeEvent(String username, String password, Function<String, Object> parameterGetter) {
|
||||
super(username, password, parameterGetter);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ import org.springframework.context.ApplicationEvent;
|
||||
* @author zhouhao
|
||||
*/
|
||||
public class AuthorizationExitEvent extends ApplicationEvent implements AuthorizationEvent {
|
||||
|
||||
private static final long serialVersionUID = -4590245933665047280L;
|
||||
|
||||
private Authentication authentication;
|
||||
|
||||
public AuthorizationExitEvent(Authentication authentication) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class AuthorizationFailedEvent extends AbstractAuthorizationEvent {
|
||||
|
||||
private static final long serialVersionUID = -101792832265740828L;
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
|
||||
@@ -34,9 +34,10 @@ import java.util.function.Function;
|
||||
* @since 3.0
|
||||
*/
|
||||
public class AuthorizationSuccessEvent extends ApplicationEvent implements AuthorizationEvent {
|
||||
private static final long serialVersionUID = -2452116314154155058L;
|
||||
private Authentication authentication;
|
||||
|
||||
private Function<String, Object> parameterGetter;
|
||||
private transient Function<String, Object> parameterGetter;
|
||||
|
||||
private Map<String, Object> result = new HashMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user