net.yadaframework.security.components.YadaUserSetup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yadawebsecurity Show documentation
Show all versions of yadawebsecurity Show documentation
Yada Framework authentication and authorization component
package net.yadaframework.security.components;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import net.yadaframework.components.YadaSetup;
import net.yadaframework.core.YadaAppConfig;
import net.yadaframework.core.YadaConfiguration;
import net.yadaframework.security.persistence.entity.YadaUserProfile;
import net.yadaframework.security.persistence.repository.YadaUserCredentialsDao;
/**
* Convenience method to create configured application users.
* You should just create a @Component that extends this class and add a setup section to the configuration
* with any user attribute you have implemented in your YadaUserProfile subclass.
* For example:
*
* <setup>
<users>
<user>
<name>admin</name>
<email>[email protected]</email>
<password>25345352543154</password>
<language>en</language>
<country>US</country>
<timezone>PST</timezone>
<role>USER</role>
<role>ADMIN</role>
</user>
</users>
</setup>
*
* @param the application-specific extension of YadaUserProfile
*/
//Not a @Component
abstract public class YadaUserSetup extends YadaSetup {
private transient Logger log = LoggerFactory.getLogger(YadaUserSetup.class);
@Autowired private YadaUserCredentialsDao yadaUserCredentialsDao;
@Autowired private YadaConfiguration yadaConfiguration;
@Override
protected void setupApplication() {
// Default empty method
log.debug("setupApplication() does nothing");
}
@Override
protected void setupUsers(List