1
0
mirror of synced 2026-08-05 17:57:15 +00:00

Polish LDAP serialization

Closes gh-9263
This commit is contained in:
Eleftheria Stein
2021-11-29 17:48:04 +01:00
parent 3c18278123
commit bbeca7cd65
10 changed files with 352 additions and 128 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2020 the original author or authors.
* Copyright 2015-2021 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.
@@ -21,19 +21,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.springframework.security.jackson2.SecurityJackson2Modules;
import org.springframework.security.ldap.userdetails.InetOrgPerson;
/**
* This is a Jackson mixin class helps in serialize/deserialize
* {@link org.springframework.security.ldap.userdetails.InetOrgPerson} class. To use this
* class you need to register it with {@link com.fasterxml.jackson.databind.ObjectMapper}.
*
* <pre>
* ObjectMapper mapper = new ObjectMapper();
* mapper.registerModule(new LdapJackson2Module());
* </pre>
*
* <i>Note: This class will save full class name into a property called @class</i>
* This Jackson mixin is used to serialize/deserialize {@link InetOrgPerson}.
*
* @since 5.7
* @see LdapJackson2Module
* @see SecurityJackson2Modules
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2020 the original author or authors.
* Copyright 2015-2021 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.
@@ -26,19 +26,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.springframework.security.jackson2.SecurityJackson2Modules;
import org.springframework.security.ldap.userdetails.LdapAuthority;
/**
* This is a Jackson mixin class helps in serialize/deserialize
* {@link org.springframework.security.ldap.userdetails.LdapAuthority} class. To use this
* class you need to register it with {@link com.fasterxml.jackson.databind.ObjectMapper}.
*
* <pre>
* ObjectMapper mapper = new ObjectMapper();
* mapper.registerModule(new LdapJackson2Module());
* </pre>
*
* <i>Note: This class will save full class name into a property called @class</i>
* This Jackson mixin is used to serialize/deserialize {@link LdapAuthority}.
*
* @since 5.7
* @see LdapJackson2Module
* @see SecurityJackson2Modules
*/
@@ -47,13 +40,6 @@ import org.springframework.security.jackson2.SecurityJackson2Modules;
@JsonIgnoreProperties(ignoreUnknown = true)
abstract class LdapAuthorityMixin {
/**
* Constructor used by Jackson to create object of
* {@link org.springframework.security.ldap.userdetails.LdapAuthority}.
* @param role
* @param dn
* @param attributes
*/
@JsonCreator
LdapAuthorityMixin(@JsonProperty("role") String role, @JsonProperty("dn") String dn,
@JsonProperty("attributes") Map<String, List<String>> attributes) {
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2020 the original author or authors.
* Copyright 2015-2021 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.
@@ -26,11 +26,13 @@ import org.springframework.security.ldap.userdetails.LdapUserDetailsImpl;
import org.springframework.security.ldap.userdetails.Person;
/**
* Jackson module for spring-security-ldap. This module registers
* Jackson module for {@code spring-security-ldap}. This module registers
* {@link LdapAuthorityMixin}, {@link LdapUserDetailsImplMixin}, {@link PersonMixin},
* {@link InetOrgPersonMixin}. If no default typing enabled by default then it'll enable
* it because typing info is needed to properly serialize/deserialize objects. In order to
* use this module just add this module into your ObjectMapper configuration.
* {@link InetOrgPersonMixin}.
*
* If not already enabled, default typing will be automatically enabled as type info is
* required to properly serialize/deserialize objects. In order to use this module just
* add it to your {@code ObjectMapper} configuration.
*
* <pre>
* ObjectMapper mapper = new ObjectMapper();
@@ -40,6 +42,7 @@ import org.springframework.security.ldap.userdetails.Person;
* <b>Note: use {@link SecurityJackson2Modules#getModules(ClassLoader)} to get list of all
* security modules.</b>
*
* @since 5.7
* @see SecurityJackson2Modules
*/
public class LdapJackson2Module extends SimpleModule {
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2020 the original author or authors.
* Copyright 2015-2021 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.
@@ -21,20 +21,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.springframework.security.jackson2.SecurityJackson2Modules;
import org.springframework.security.ldap.userdetails.LdapUserDetailsImpl;
/**
* This is a Jackson mixin class helps in serialize/deserialize
* {@link org.springframework.security.ldap.userdetails.LdapUserDetailsImpl} class. To use
* this class you need to register it with
* {@link com.fasterxml.jackson.databind.ObjectMapper}.
*
* <pre>
* ObjectMapper mapper = new ObjectMapper();
* mapper.registerModule(new LdapJackson2Module());
* </pre>
*
* <i>Note: This class will save full class name into a property called @class</i>
* This Jackson mixin is used to serialize/deserialize {@link LdapUserDetailsImpl}.
*
* @since 5.7
* @see LdapJackson2Module
* @see SecurityJackson2Modules
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2020 the original author or authors.
* Copyright 2015-2021 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.
@@ -21,19 +21,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.springframework.security.jackson2.SecurityJackson2Modules;
import org.springframework.security.ldap.userdetails.Person;
/**
* This is a Jackson mixin class helps in serialize/deserialize
* {@link org.springframework.security.ldap.userdetails.Person} class. To use this class
* you need to register it with {@link com.fasterxml.jackson.databind.ObjectMapper}.
*
* <pre>
* ObjectMapper mapper = new ObjectMapper();
* mapper.registerModule(new LdapJackson2Module());
* </pre>
*
* <i>Note: This class will save full class name into a property called @class</i>
* This Jackson mixin is used to serialize/deserialize {@link Person}.
*
* @since 5.7
* @see LdapJackson2Module
* @see SecurityJackson2Modules
*/