Support Serialization for LDAP Components

Issue gh-16276
This commit is contained in:
Josh Cummings 2025-01-23 16:55:30 -07:00
parent 36716d12ba
commit e1e5970a24
No known key found for this signature in database
GPG Key ID: 869B37A20E876129
5 changed files with 16 additions and 0 deletions

View File

@ -110,8 +110,10 @@ import org.springframework.security.core.session.ReactiveSessionInformation;
import org.springframework.security.core.session.SessionInformation;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.ldap.ppolicy.PasswordPolicyControl;
import org.springframework.security.ldap.ppolicy.PasswordPolicyErrorStatus;
import org.springframework.security.ldap.ppolicy.PasswordPolicyException;
import org.springframework.security.ldap.ppolicy.PasswordPolicyResponseControl;
import org.springframework.security.ldap.userdetails.LdapAuthority;
import org.springframework.security.oauth2.client.ClientAuthorizationException;
import org.springframework.security.oauth2.client.ClientAuthorizationRequiredException;
@ -470,6 +472,11 @@ class SpringSecurityCoreVersionSerializableTests {
(r) -> new LdapAuthority("USER", "username", Map.of("attribute", List.of("value1", "value2"))));
generatorByClassName.put(PasswordPolicyException.class,
(r) -> new PasswordPolicyException(PasswordPolicyErrorStatus.INSUFFICIENT_PASSWORD_QUALITY));
generatorByClassName.put(PasswordPolicyControl.class, (r) -> new PasswordPolicyControl(true));
generatorByClassName.put(PasswordPolicyResponseControl.class, (r) -> {
byte[] encodedResponse = { 0x30, 0x05, (byte) 0xA0, 0x03, (byte) 0xA0, 0x1, 0x21 };
return new PasswordPolicyResponseControl(encodedResponse);
});
// saml2-service-provider
generatorByClassName.put(Saml2AuthenticationException.class,

View File

@ -16,6 +16,8 @@
package org.springframework.security.ldap.ppolicy;
import java.io.Serial;
import javax.naming.ldap.Control;
/**
@ -37,6 +39,9 @@ public class PasswordPolicyControl implements Control {
*/
public static final String OID = "1.3.6.1.4.1.42.2.27.8.5.1";
@Serial
private static final long serialVersionUID = 2843242715616817932L;
private final boolean critical;
/**

View File

@ -19,6 +19,7 @@ package org.springframework.security.ldap.ppolicy;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serial;
import netscape.ldap.ber.stream.BERChoice;
import netscape.ldap.ber.stream.BERElement;
@ -53,6 +54,9 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
private static final Log logger = LogFactory.getLog(PasswordPolicyResponseControl.class);
@Serial
private static final long serialVersionUID = -4592657167939234499L;
private final byte[] encodedValue;
private PasswordPolicyErrorStatus errorStatus;