Example usage for org.apache.shiro.realm.text TextConfigurationRealm setUserDefinitions

List of usage examples for org.apache.shiro.realm.text TextConfigurationRealm setUserDefinitions

Introduction

In this page you can find the example usage for org.apache.shiro.realm.text TextConfigurationRealm setUserDefinitions.

Prototype

public void setUserDefinitions(String userDefinitions) 

Source Link

Document

Sets a newline (\n) delimited String that defines user-to-password-and-role(s) key/value pairs according to the following format:

username = password, role1, role2,...

Here are some examples of what these lines might look like:

root = reallyHardToGuessPassword, administrator
jsmith = jsmithsPassword, manager, engineer, employee
abrown = abrownsPassword, qa, employee
djones = djonesPassword, qa, contractor
guest = guestPassword

Usage

From source file:com.stormpath.shiro.spring.boot.autoconfigure.ShiroAutoConfigurationTestApplication.java

License:Apache License

@Bean
@SuppressWarnings("Duplicates")
Realm getTextConfigurationRealm() {//from   w  w  w  . ja v  a2 s  . c om

    TextConfigurationRealm realm = new TextConfigurationRealm();
    realm.setUserDefinitions("joe.coder=password,user\n" + "jill.coder=password,admin");

    realm.setRoleDefinitions("admin=read,write\n" + "user=read");
    realm.setCachingEnabled(true);
    return realm;
}

From source file:com.stormpath.shiro.spring.config.RealmConfiguration.java

License:Apache License

@Bean
@DependsOn("lifecycleBeanPostProcessor")
@SuppressWarnings("Duplicates")
Realm getTextConfigurationRealm() {//from w w w. j  a  va  2 s .  c o m

    TextConfigurationRealm realm = new TextConfigurationRealm();
    realm.setUserDefinitions("joe.coder=password,user\n" + "jill.coder=password,admin");

    realm.setRoleDefinitions("admin=read,write\n" + "user=read");
    realm.setCachingEnabled(true);
    return realm;
}