Guest User

Untitled

a guest
Sep 27th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. @Entity
  2. @Table(name="user_account_entity")
  3. @JsonDeserialize(using = UserAccountDeserializer.class)
  4. @JsonSerialize(using = UserAccountSerializer.class)
  5. public class UserAccountEntity implements UserDetails {
  6.  
  7. @Id
  8. private String id;
  9.  
  10. private String username;
  11.  
  12. private String password;
  13.  
  14. public UserAccountEntity(final String username, final String password) {
  15. this.password = password.trim();
  16. this.username = username.trim();
  17. }
  18. //....
  19. }
  20.  
  21. public class UserAccountDeserializer extends JsonDeserializer<UserAccountEntity> {
  22.  
  23. @Override
  24. public UserAccountEntity deserialize(JsonParser jp,
  25. DeserializationContext ctxt) throws IOException,
  26. JsonProcessingException {
  27. JsonNode node = jp.getCodec().readTree(jp);
  28. final String username = node.get("username").asText();
  29. final String password = node.get("password").asText();
  30. return new UserAccountEntity(username, password);
  31. }
  32.  
  33. }
Add Comment
Please, Sign In to add comment