package io.core9.module.auth.standard;

import io.core9.plugin.database.repository.AbstractCrudEntity;
import io.core9.plugin.database.repository.Collection;
import io.core9.plugin.database.repository.CrudEntity;

import java.util.Set;

import org.apache.shiro.crypto.hash.Sha256Hash;

@Collection("core.users")
public class UserEntity extends AbstractCrudEntity implements CrudEntity {
	
	private String username;
	private String password;
	private String salt;
	private Set<String> roles;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public Set<String> getRoles() {
		return roles;
	}

	public void setRoles(Set<String> roles) {
		this.roles = roles;
	}
	
	public void hashPassword(String source) {
		this.password = new Sha256Hash(source, salt).toString();
	}

}

@@ -207,16 +207,80 @@
 ntity;%0A%0A
+import java.math.BigInteger;%0Aimport java.security.SecureRandom;%0A
 import j
@@ -1077,24 +1077,150 @@
 g source) %7B%0A
+%09%09if(source == null) %7B%0A%09%09%09SecureRandom random = new SecureRandom();%0A%09%09%09source = new BigInteger(130, random).toString(32);%0A%09%09%7D%0A
 %09%09this.passw

Create dummy password on null