Hi,
I’ve a specific workflow that is based on 2 steps:
- Check if supplier ID / Email exists against an external API [New]
- If yes send them an email containing a random string that they need to authent in another form
I had to revamp the whole JPA part (previously I had to check in a database), since the revamp I don’t manage to see the “Attributes” tab in Keycloak.
Here is my UserAdapter :
public class SupplierUserAdapter extends AbstractUserAdapterFederatedStorage {
private static final Logger logger = Logger.getLogger(SupplierUserAdapter.class);
protected final String username;
protected final Supplier supplier;
protected final SupplierContact contact;
public SupplierUserAdapter(KeycloakSession session, RealmModel realm, ComponentModel model, Supplier supplier, SupplierContact contact) {
super(session, realm, model);
this.supplier = supplier;
this.contact = contact;
if (supplier != null && contact != null) {
this.username = new SupplierDto(this.supplier.getSupplierId(), contact.getEmail()).toString();
this.storageId = new StorageId(model.getId(), username);
super.setEmail(contact.getEmail());
super.setCreatedTimestamp(System.currentTimeMillis());
super.setEmailVerified(true);
super.setLastName(String.format("[%s] %s", supplier.getName(), contact.getContact()));
}
else { username = null; }
}
@Override
public Map<String, List<String>> getAttributes() {
MultivaluedHashMap<String, String> attributes = new MultivaluedHashMap<>();
attributes.add(AbstractUserAdapterFederatedStorage.EMAIL_ATTRIBUTE, contact.getEmail());
attributes.add("providerId", supplier.getSupplierId());
attributes.add("socialReason", supplier.getName());
attributes.add("tvaNumber", supplier.getVatNumber());
attributes.add("fullName", contact.getContact());
// ...
return attributes;
}
@Override
public Stream<String> getAttributeStream(String name) {
Map<String, List<String>> attributes = getAttributes();
return (attributes.containsKey(name)) ? attributes.get(name).stream() : Stream.empty();
}
@Override
public String getUsername() {
return username;
}
@Override
public void setUsername(String username) {
throw new ReadOnlyException();
}
}
When looking in Keycloak I’m unable to see them :
1/ I do see my users and the setEmail and setting username works properly
2/ I do not see the attributes tab nor the email in the general info :
Did I miss something ?
Thanks,