Spring Boot with Session/Redis Serialization Error with Bad Active Directory Ldap Credentials

前端 未结 3 1567
醉酒成梦
醉酒成梦 2020-12-11 18:40

Hi I am new to Spring and Java, I am trying to implement a Gateway authentication server as described in this tutorial https://spring.io/guides/tutorials/spring-security-and

3条回答
  •  借酒劲吻你
    2020-12-11 19:20

    This just worked fine for me after using classes of org.springframework.core.serializer.support.DeserializingConverter and org.springframework.core.serializer.support.SerializingConverter

    /**
     * @author Meron Abraha 12/18/17
     */
    
    public class CustomRedisSerializer implements RedisSerializer {
    
    private Converter serializer = new SerializingConverter();
    private Converter deserializer = new DeserializingConverter();
    
    static final byte[] EMPTY_ARRAY = new byte[0];
    
    public Object deserialize(byte[] bytes) {
        if (isEmpty(bytes)) {
            return null;
        }
    
        try {
            return deserializer.convert(bytes);
        } catch (Exception ex) {
            throw new SerializationException("Cannot deserialize", ex);
        }
    }
    
    public byte[] serialize(Object object) {
        if (object == null) {
            return EMPTY_ARRAY;
        }
    
        try {
            return serializer.convert(object);
        } catch (Exception ex) {
            return EMPTY_ARRAY;
    
        }
    }
    
    private boolean isEmpty(byte[] data) {
        return (data == null || data.length == 0);
    }
    }
    
        

    提交回复
    热议问题