示例#1
0
  @Override
  public void updateCredentialDirectly(UserCredentialValueModel credModel) {
    CredentialEntity credentialEntity = getCredentialEntity(user, credModel.getType());

    if (credentialEntity == null) {
      credentialEntity = new CredentialEntity();
      credentialEntity.setId(KeycloakModelUtils.generateId());
      credentialEntity.setType(credModel.getType());
      credentialEntity.setCreatedDate(credModel.getCreatedDate());
      credentialEntity.setUser(user);
      em.persist(credentialEntity);
      user.getCredentials().add(credentialEntity);
    }

    credentialEntity.setValue(credModel.getValue());
    credentialEntity.setSalt(credModel.getSalt());
    credentialEntity.setDevice(credModel.getDevice());
    credentialEntity.setHashIterations(credModel.getHashIterations());
    credentialEntity.setCounter(credModel.getCounter());
    credentialEntity.setAlgorithm(credModel.getAlgorithm());
    credentialEntity.setDigits(credModel.getDigits());
    credentialEntity.setPeriod(credModel.getPeriod());

    em.flush();
  }
示例#2
0
  @Override
  public void updateCredentialDirectly(UserCredentialValueModel credModel) {
    CredentialEntity credentialEntity = getCredentialEntity(user, credModel.getType());

    if (credentialEntity == null) {
      credentialEntity = new CredentialEntity();
      //    credentialEntity.setId(KeycloakModelUtils.generateId());
      credentialEntity.setType(credModel.getType());
      //    credentialEntity.setUser(user);
      credModel.setCreatedDate(credModel.getCreatedDate());
      user.getCredentials().add(credentialEntity);
    }

    credentialEntity.setValue(credModel.getValue());
    credentialEntity.setSalt(credModel.getSalt());
    credentialEntity.setDevice(credModel.getDevice());
    credentialEntity.setHashIterations(credModel.getHashIterations());
  }
示例#3
0
  public static boolean isPasswordSet(UserModel user) {
    boolean passwordSet = false;

    if (user.getFederationLink() != null) {
      passwordSet = true;
    }

    for (UserCredentialValueModel c : user.getCredentialsDirectly()) {
      if (c.getType().equals(CredentialRepresentation.PASSWORD)) {
        passwordSet = true;
      }
    }
    return passwordSet;
  }
 @Override
 public Set<String> getSupportedCredentialTypes(UserModel local) {
   Set<String> supportedCredentialTypes = new HashSet<String>(this.supportedCredentialTypes);
   if (editMode == EditMode.UNSYNCED) {
     for (UserCredentialValueModel cred : local.getCredentialsDirectly()) {
       if (cred.getType().equals(UserCredentialModel.PASSWORD)) {
         // User has changed password in KC local database. Use KC password instead of LDAP
         // password
         supportedCredentialTypes.remove(UserCredentialModel.PASSWORD);
       }
     }
   }
   return supportedCredentialTypes;
 }