1
0
mirror of synced 2026-08-04 09:17:02 +00:00

Simplify RequestMatcherDelegatingAuthorizationManager.Builder matcher registration

Closes gh-11624
This commit is contained in:
Evgeniy Cheban
2023-04-27 23:25:38 +03:00
committed by Marcus Hert Da Coregio
parent 8efdc5c926
commit 0cefb27928
3 changed files with 390 additions and 3 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -17,15 +17,23 @@
package org.springframework.security.authentication;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.PasswordEncodedUser;
import org.springframework.security.core.userdetails.UserDetails;
/**
* @author Rob Winch
* @author Evgeniy Cheban
* @since 5.0
*/
public class TestAuthentication extends PasswordEncodedUser {
private static final Authentication ANONYMOUS = new AnonymousAuthenticationToken("key", "anonymous",
AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
private static final RememberMeAuthenticationToken REMEMBER_ME = new RememberMeAuthenticationToken("key", "user",
AuthorityUtils.createAuthorityList("ROLE_USER"));
public static Authentication authenticatedAdmin() {
return autheticated(admin());
}
@@ -38,4 +46,12 @@ public class TestAuthentication extends PasswordEncodedUser {
return UsernamePasswordAuthenticationToken.authenticated(user, null, user.getAuthorities());
}
public static Authentication anonymousUser() {
return ANONYMOUS;
}
public static Authentication rememberMeUser() {
return REMEMBER_ME;
}
}