@Override public boolean isEmailVerified() { return delegate.isEmailVerified(); }
@Override public boolean isEmailVerified() { return delegate.isEmailVerified(); }
@Override public boolean isEmailVerified() { if (updated != null) return updated.isEmailVerified(); return cached.isEmailVerified(); }
@Override public boolean isEmailVerified() { if (updated != null) return updated.isEmailVerified(); return cached.isEmailVerified(); }
public CachedUser(Long revision, RealmModel realm, UserModel user, int notBefore) { super(revision, user.getId()); this.realm = realm.getId(); this.username = user.getUsername(); this.createdTimestamp = user.getCreatedTimestamp(); this.firstName = user.getFirstName(); this.lastName = user.getLastName(); this.email = user.getEmail(); this.emailVerified = user.isEmailVerified(); this.enabled = user.isEnabled(); this.federationLink = user.getFederationLink(); this.serviceAccountClientLink = user.getServiceAccountClientLink(); this.notBefore = notBefore; this.requiredActions = new DefaultLazyLoader<>(UserModel::getRequiredActions, Collections::emptySet); this.attributes = new DefaultLazyLoader<>(userModel -> new MultivaluedHashMap<>(userModel.getAttributes()), MultivaluedHashMap::new); this.roleMappings = new DefaultLazyLoader<>(userModel -> userModel.getRoleMappings().stream().map(RoleModel::getId).collect(Collectors.toSet()), Collections::emptySet); this.groups = new DefaultLazyLoader<>(userModel -> userModel.getGroups().stream().map(GroupModel::getId).collect(Collectors.toCollection(LinkedHashSet::new)), LinkedHashSet::new); }
@Override public void onEvent(Event event) { if (includedEvents.contains(event.getType())) { if (event.getRealmId() != null && event.getUserId() != null) { RealmModel realm = model.getRealm(event.getRealmId()); UserModel user = session.users().getUserById(event.getUserId(), realm); if (user != null && user.getEmail() != null && user.isEmailVerified()) { try { emailTemplateProvider.setRealm(realm).setUser(user).sendEvent(event); } catch (EmailException e) { log.error("Failed to send type mail", e); } } } } }
@Override public void onEvent(Event event) { if (includedEvents.contains(event.getEvent())) { if (event.getRealmId() != null && event.getUserId() != null) { RealmModel realm = model.getRealm(event.getRealmId()); UserModel user = session.users().getUserById(event.getUserId(), realm); if (user != null && user.getEmail() != null && user.isEmailVerified()) { try { emailProvider.setRealm(realm).setUser(user).sendEvent(event); } catch (EmailException e) { log.error("Failed to send event mail", e); } } } } }
public CachedUser(RealmModel realm, UserModel user) { this.id = user.getId(); this.realm = realm.getId(); this.username = user.getUsername(); this.createdTimestamp = user.getCreatedTimestamp(); this.firstName = user.getFirstName(); this.lastName = user.getLastName(); this.attributes.putAll(user.getAttributes()); this.email = user.getEmail(); this.emailVerified = user.isEmailVerified(); this.credentials.addAll(user.getCredentialsDirectly()); this.enabled = user.isEnabled(); this.totp = user.isOtpEnabled(); this.federationLink = user.getFederationLink(); this.serviceAccountClientLink = user.getServiceAccountClientLink(); this.requiredActions.addAll(user.getRequiredActions()); for (RoleModel role : user.getRoleMappings()) { roleMappings.add(role.getId()); } Set<GroupModel> groupMappings = user.getGroups(); if (groupMappings != null) { for (GroupModel group : groupMappings) { groups.add(group.getId()); } } }
public static UserRepresentation toRepresentation(UserModel user) { UserRepresentation rep = new UserRepresentation(); rep.setId(user.getId()); rep.setUsername(user.getUsername()); rep.setCreatedTimestamp(user.getCreatedTimestamp()); rep.setLastName(user.getLastName()); rep.setFirstName(user.getFirstName()); rep.setEmail(user.getEmail()); rep.setEnabled(user.isEnabled()); rep.setEmailVerified(user.isEmailVerified()); rep.setTotp(user.isOtpEnabled()); rep.setFederationLink(user.getFederationLink()); List<String> reqActions = new ArrayList<String>(); Set<String> requiredActions = user.getRequiredActions(); for (String ra : requiredActions){ reqActions.add(ra); } rep.setRequiredActions(reqActions); if (user.getAttributes() != null && !user.getAttributes().isEmpty()) { Map<String, Object> attrs = new HashMap<>(); attrs.putAll(user.getAttributes()); rep.setAttributes(attrs); } return rep; }