mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-04 17:52:15 +00:00
Add support ResolvableTypeProvider to authorization events
Closes gh-16700 Signed-off-by: Max Batischev <mblancer@mail.ru>
This commit is contained in:
parent
6c9071211f
commit
ed79efc5fa
@ -19,6 +19,8 @@ package org.springframework.security.authorization.event;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.ResolvableTypeProvider;
|
||||
import org.springframework.security.authorization.AuthorizationDecision;
|
||||
import org.springframework.security.authorization.AuthorizationResult;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@ -31,7 +33,7 @@ import org.springframework.security.core.Authentication;
|
||||
* @since 5.7
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class AuthorizationDeniedEvent<T> extends AuthorizationEvent {
|
||||
public class AuthorizationDeniedEvent<T> extends AuthorizationEvent implements ResolvableTypeProvider {
|
||||
|
||||
/**
|
||||
* @deprecated Please use an {@link AuthorizationResult} constructor instead
|
||||
@ -59,4 +61,14 @@ public class AuthorizationDeniedEvent<T> extends AuthorizationEvent {
|
||||
return (T) getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get {@link ResolvableType} of this class.
|
||||
* @return {@link ResolvableType}
|
||||
* @since 6.5
|
||||
*/
|
||||
@Override
|
||||
public ResolvableType getResolvableType() {
|
||||
return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forInstance(getObject()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import java.io.Serial;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.ResolvableTypeProvider;
|
||||
import org.springframework.security.authorization.AuthorizationDecision;
|
||||
import org.springframework.security.authorization.AuthorizationResult;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@ -32,7 +34,7 @@ import org.springframework.security.core.Authentication;
|
||||
* @since 5.7
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class AuthorizationGrantedEvent<T> extends AuthorizationEvent {
|
||||
public class AuthorizationGrantedEvent<T> extends AuthorizationEvent implements ResolvableTypeProvider {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -8690818228055810339L;
|
||||
@ -65,4 +67,14 @@ public class AuthorizationGrantedEvent<T> extends AuthorizationEvent {
|
||||
return (T) getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get {@link ResolvableType} of this class.
|
||||
* @return {@link ResolvableType}
|
||||
* @since 6.5
|
||||
*/
|
||||
@Override
|
||||
public ResolvableType getResolvableType() {
|
||||
return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forInstance(getObject()));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user