model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java
// Detect if it is "plain-text" or "hashed" representation and update model according to it

Detect if it is "plain-text" or "hashed" representation and update model according to it
Detect if it is " plain - text " or " hashed " representation and update model according to it
private static void updateCredential(UserModel user, CredentialRepresentation cred) {
        if (cred.getValue() != null) {
            UserCredentialModel plainTextCred = convertCredential(cred);
            user.updateCredential(plainTextCred);
        } else {
            UserCredentialValueModel hashedCred = new UserCredentialValueModel();
            hashedCred.setType(cred.getType());
            hashedCred.setDevice(cred.getDevice());
            hashedCred.setHashIterations(cred.getHashIterations());
            try {
                if (cred.getSalt() != null) hashedCred.setSalt(Base64.decode(cred.getSalt()));
            } catch (IOException ioe) {
                throw new RuntimeException(ioe);
            }
            hashedCred.setValue(cred.getHashedSaltedValue());
            user.updateCredentialDirectly(hashedCred);
        }
    }
private static void updateCredential ( UserModel user , CredentialRepresentation cred ) { if ( cred . getValue ( ) != null ) { UserCredentialModel plainTextCred = convertCredential ( cred ) ; user . updateCredential ( plainTextCred ) ; } else { UserCredentialValueModel hashedCred = new UserCredentialValueModel ( ) ; hashedCred . setType ( cred . getType ( ) ) ; hashedCred . setDevice ( cred . getDevice ( ) ) ; hashedCred . setHashIterations ( cred . getHashIterations ( ) ) ; try { if ( cred . getSalt ( ) != null ) hashedCred . setSalt ( Base64 . decode ( cred . getSalt ( ) ) ) ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } hashedCred . setValue ( cred . getHashedSaltedValue ( ) ) ; user . updateCredentialDirectly ( hashedCred ) ; } }
Detect if it is "plain-text" or "hashed" representation and update model according to it
Detect if it is " plain - text " or " hashed " representation and update model according to it