You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class HandleTests {
@Test
public void test() {
AuthorizationProxyFactory proxyFactory = AuthorizationAdvisorProxyFactory.withDefaults();
Account account = (Account) proxyFactory.proxy(new Account());
assertThat(account.getAccountNumber()).isNull();
}
public static class Account {
@PreAuthorize("denyAll")
@HandleAuthorizationDenied(handlerClass = NullMethodAuthorizationDeniedHandler.class)
public String getAccountNumber() {
return "123";
}
}
public class NullMethodAuthorizationDeniedHandler implements MethodAuthorizationDeniedHandler {
@Override
public Object handleDeniedInvocation(MethodInvocation methodInvocation, AuthorizationResult authorizationResult) {
return null;
}
}
}
fails because PreAuthorizeAuthenticiationManager -- and other related managers -- resolve handlerClass by looking it up as a @Bean. The main concern here is that it is failing silently to load the handlerClass.
It would be nice if, by default, it tried to construct the value. That behavior would be replaced if an ApplicationContext is specified.
The text was updated successfully, but these errors were encountered:
jzheaux
changed the title
Improve @DeniedHandler to not require an ApplicationContext to function
@DeniedHandler should not require an ApplicationContext to function
Aug 7, 2024
The given test:
fails because
PreAuthorizeAuthenticiationManager
-- and other related managers -- resolvehandlerClass
by looking it up as a@Bean
. The main concern here is that it is failing silently to load thehandlerClass
.It would be nice if, by default, it tried to construct the value. That behavior would be replaced if an
ApplicationContext
is specified.The text was updated successfully, but these errors were encountered: