[英]Jackson, hashed password not being mapped
I have the following collection "player" 我有以下收藏“ player”
{
"_id" : ObjectId("5426efb844ae829d1dcdaa6d"),
"username" : "Foobar",
"password" : "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
"gameIds" : [
"5426f10544ae8502f731d8a0"
]
}
It has a hashed password. 它具有哈希密码。 When I try to map til back to my Player object, everything except the password is being mapped.
当我尝试将til映射回我的Player对象时,除密码之外的所有内容都将被映射。 The password is null.
密码为空。
This is my Player with mappings 这是我的玩家与映射
@Data
@JsonRootName("player")
@NoArgsConstructor
public class Player {
@JsonIgnore
public static final String COL_NAME = "player";
@ObjectId
@Id
private String id;
/**Will use this token to authorize the user. This UUID should be cached once the user logs in */
@JsonIgnore
private UUID token = UUID.randomUUID();
@NotBlank
//Unique
private String username;
@Email
private String email;
@NotBlank
private String password;
/** Set of unique active games * */
private Set<String> gameIds = new HashSet<>();
}
I am saving the player like this: 我这样保存播放器:
Player player = new Player();
player.setUsername(username);
player.getGameIds().add(pbfId);
player.setPassword(DigestUtils.sha1Hex("foo"));
playerCollection.insert(player);
And reading like this: 像这样阅读:
DBCursor<Player> username = playerCollection.find(DBQuery.is("username", "Foobar"), new BasicDBObject());
Player player = username.next();
Here everything except the password is correctly mapped 此处,除密码外的所有内容均已正确映射
I don't know what happened, but seems like I queried the wrong database. 我不知道发生了什么,但是好像我查询了错误的数据库。 I have no idea how this happened.
我不知道这是怎么发生的。
After going against the correct database, it worked fine 经过正确的数据库后,它工作正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.