Remove Generic Typing From Authentication.Builder
It would be better to introduce parameter types for principal and credentials into Authentication.Builder at the same time as doing so for Authentication Issue gh-17861
This commit is contained in:
+6
-6
@@ -82,8 +82,7 @@ public class Saml2AssertionAuthentication extends Saml2Authentication {
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static class Builder<B extends Builder<B>>
|
||||
extends Saml2Authentication.Builder<Saml2ResponseAssertionAccessor, B> {
|
||||
public static class Builder<B extends Builder<B>> extends Saml2Authentication.Builder<B> {
|
||||
|
||||
private Saml2ResponseAssertionAccessor assertion;
|
||||
|
||||
@@ -96,10 +95,11 @@ public class Saml2AssertionAuthentication extends Saml2Authentication {
|
||||
}
|
||||
|
||||
@Override
|
||||
public B credentials(@Nullable Saml2ResponseAssertionAccessor credentials) {
|
||||
saml2Response(credentials.getResponseValue());
|
||||
Assert.notNull(credentials, "assertion cannot be null");
|
||||
this.assertion = credentials;
|
||||
public B credentials(@Nullable Object credentials) {
|
||||
Assert.isInstanceOf(Saml2ResponseAssertionAccessor.class, credentials,
|
||||
"credentials must be of type Saml2ResponseAssertionAccessor");
|
||||
saml2Response(((Saml2ResponseAssertionAccessor) credentials).getResponseValue());
|
||||
this.assertion = (Saml2ResponseAssertionAccessor) credentials;
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ public class Saml2Authentication extends AbstractAuthenticationToken {
|
||||
setAuthenticated(true);
|
||||
}
|
||||
|
||||
Saml2Authentication(Builder<?, ?> builder) {
|
||||
Saml2Authentication(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.principal = builder.principal;
|
||||
this.saml2Response = builder.saml2Response;
|
||||
@@ -95,7 +95,7 @@ public class Saml2Authentication extends AbstractAuthenticationToken {
|
||||
return getSaml2Response();
|
||||
}
|
||||
|
||||
abstract static class Builder<C, B extends Builder<C, B>> extends AbstractAuthenticationBuilder<Object, C, B> {
|
||||
abstract static class Builder<B extends Builder<B>> extends AbstractAuthenticationBuilder<B> {
|
||||
|
||||
private Object principal;
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class Saml2AssertionAuthenticationTests {
|
||||
Saml2AssertionAuthentication factorOne = new Saml2AssertionAuthentication("alice",
|
||||
prototype.nameId("alice").build(), AuthorityUtils.createAuthorityList("FACTOR_ONE"), "alice");
|
||||
Saml2AssertionAuthentication factorTwo = new Saml2AssertionAuthentication("bob",
|
||||
prototype.nameId("alice").build(), AuthorityUtils.createAuthorityList("FACTOR_TWO"), "bob");
|
||||
prototype.nameId("bob").build(), AuthorityUtils.createAuthorityList("FACTOR_TWO"), "bob");
|
||||
Saml2AssertionAuthentication result = factorOne.toBuilder()
|
||||
.authorities((a) -> a.addAll(factorTwo.getAuthorities()))
|
||||
.principal(factorTwo.getPrincipal())
|
||||
|
||||
Reference in New Issue
Block a user