52 CredentialEntity entity =
em.find(CredentialEntity.class, cred.getId());
53 if (entity == null)
return;
54 entity.setAlgorithm(cred.getAlgorithm());
55 entity.setCounter(cred.getCounter());
56 entity.setCreatedDate(cred.getCreatedDate());
57 entity.setDevice(cred.getDevice());
58 entity.setDigits(cred.getDigits());
59 entity.setHashIterations(cred.getHashIterations());
60 entity.setPeriod(cred.getPeriod());
61 entity.setSalt(cred.getSalt());
62 entity.setType(cred.getType());
63 entity.setValue(cred.getValue());
64 if (entity.getCredentialAttributes().isEmpty() && (cred.getConfig() == null || cred.getConfig().isEmpty())) {
67 MultivaluedHashMap<String, String> attrs = cred.getConfig();
68 MultivaluedHashMap<String, String> config = cred.getConfig();
69 if (config == null) config =
new MultivaluedHashMap<>();
71 Iterator<CredentialAttributeEntity> it = entity.getCredentialAttributes().iterator();
72 while (it.hasNext()) {
73 CredentialAttributeEntity attr = it.next();
74 List<String> values = config.getList(attr.getName());
75 if (values == null || !values.contains(attr.getValue())) {
79 attrs.add(attr.getName(), attr.getValue());
83 for (String key : config.keySet()) {
84 List<String> values = config.getList(key);
85 List<String> attrValues = attrs.getList(key);
86 for (String val : values) {
87 if (attrValues == null || !attrValues.contains(val)) {
88 CredentialAttributeEntity attr =
new CredentialAttributeEntity();
89 attr.setId(KeycloakModelUtils.generateId());
92 attr.setCredential(entity);
94 entity.getCredentialAttributes().add(attr);
final EntityManager em
Definition: JpaUserCredentialStore.java:43