Polish JSON warnings / javadoc

Issue gh-3736
This commit is contained in:
Rob Winch 2016-09-01 14:50:42 -05:00
parent 6d2003722e
commit 6f2b24a62b
9 changed files with 20 additions and 23 deletions

View File

@ -34,7 +34,7 @@ import org.springframework.security.jackson2.SecurityJacksonModules;
* ObjectMapper mapper = new ObjectMapper();
* mapper.registerModule(new CasJackson2Module());
* </pre>
* <b>Note: use {@link SecurityJacksonModules#getModules()} to get list of all security modules.</b>
* <b>Note: use {@link SecurityJacksonModules#getModules(ClassLoader)} to get list of all security modules on the classpath.</b>
*
* @author Jitendra Singh.
* @see org.springframework.security.jackson2.SecurityJacksonModules

View File

@ -38,7 +38,7 @@ import java.util.Collections;
* ObjectMapper mapper = new ObjectMapper();
* mapper.registerModule(new CoreJackson2Module());
* </pre>
* <b>Note: use {@link SecurityJacksonModules#getModules()} to get list of all security modules.</b>
* <b>Note: use {@link SecurityJacksonModules#getModules(ClassLoader)} to get list of all security modules.</b>
*
* @author Jitendra Singh.
* @see SecurityJacksonModules
@ -56,7 +56,7 @@ public class CoreJackson2Module extends SimpleModule {
context.setMixInAnnotations(AnonymousAuthenticationToken.class, AnonymousAuthenticationTokenMixin.class);
context.setMixInAnnotations(RememberMeAuthenticationToken.class, RememberMeAuthenticationTokenMixin.class);
context.setMixInAnnotations(SimpleGrantedAuthority.class, SimpleGrantedAuthorityMixin.class);
context.setMixInAnnotations(Collections.unmodifiableSet(Collections.EMPTY_SET).getClass(), UnmodifiableSetMixin.class);
context.setMixInAnnotations(Collections.<Object>unmodifiableSet(Collections.emptySet()).getClass(), UnmodifiableSetMixin.class);
context.setMixInAnnotations(User.class, UserMixin.class);
context.setMixInAnnotations(UsernamePasswordAuthenticationToken.class, UsernamePasswordAuthenticationTokenMixin.class);
}

View File

@ -40,8 +40,8 @@ class UnmodifiableSetMixin {
/**
* Mixin Constructor
* @param s
* @param s the Set
*/
@JsonCreator
UnmodifiableSetMixin(Set s) {}
UnmodifiableSetMixin(Set<?> s) {}
}

View File

@ -46,11 +46,11 @@ class UserDeserializer extends JsonDeserializer<User> {
* serialized json, because credentials may be removed from the {@link User} by invoking {@link User#eraseCredentials()}.
* In that case there won't be any password key in serialized json.
*
* @param jp
* @param ctxt
* @return
* @throws IOException
* @throws JsonProcessingException
* @param jp the JsonParser
* @param ctxt the DeserializationContext
* @return the user
* @throws IOException if a exception during IO occurs
* @throws JsonProcessingException if an error during JSON processing occurs
*/
@Override
public User deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {

View File

@ -47,11 +47,11 @@ class UsernamePasswordAuthenticationTokenDeserializer extends JsonDeserializer<U
/**
* This method construct {@link UsernamePasswordAuthenticationToken} object from serialized json.
* @param jp
* @param ctxt
* @return
* @throws IOException
* @throws JsonProcessingException
* @param jp the JsonParser
* @param ctxt the DeserializationContext
* @return the user
* @throws IOException if a exception during IO occurs
* @throws JsonProcessingException if an error during JSON processing occurs
*/
@Override
public UsernamePasswordAuthenticationToken deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {

View File

@ -18,12 +18,8 @@ package org.springframework.security.jackson2;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

View File

@ -30,7 +30,7 @@ import java.io.IOException;
/**
* Jackson deserializer for {@link Cookie}. This is needed because in most cases we don't
* set {@link Cookie#domain} property. So when jackson deserialize that json {@link Cookie#setDomain(String)}
* set {@link Cookie#getDomain()} property. So when jackson deserialize that json {@link Cookie#setDomain(String)}
* throws {@link NullPointerException}. This is registered with {@link CookieMixin} but you can also use it with
* your own mixin.
*

View File

@ -43,9 +43,9 @@ class DefaultCsrfTokenMixin {
* JsonCreator constructor needed by Jackson to create {@link org.springframework.security.web.csrf.DefaultCsrfToken}
* object.
*
* @param headerName
* @param parameterName
* @param token
* @param headerName the name of the header
* @param parameterName the parameter name
* @param token the CSRF token value
*/
@JsonCreator
public DefaultCsrfTokenMixin(@JsonProperty("headerName") String headerName,

View File

@ -75,6 +75,7 @@ public class SavedCookieMixinTests extends AbstractMixinTests {
}
@Test
@SuppressWarnings("unchecked")
public void deserializeSavedCookieWithList() throws IOException, JSONException {
String expectedJson = String.format("[\"java.util.ArrayList\", [%s]]", expectedSavedCookieJson);
List<SavedCookie> savedCookies = (List<SavedCookie>)buildObjectMapper().readValue(expectedJson, Object.class);