1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.shiro.samples;
20
21 import org.apache.shiro.realm.Realm;
22 import org.apache.shiro.realm.text.TextConfigurationRealm;
23 import org.springframework.boot.SpringApplication;
24 import org.springframework.boot.autoconfigure.SpringBootApplication;
25 import org.springframework.context.ConfigurableApplicationContext;
26 import org.springframework.context.annotation.Bean;
27 import org.springframework.context.annotation.Configuration;
28
29
30
31
32
33
34
35
36 @Configuration
37 @SpringBootApplication
38 public class CliApp {
39
40 public static void main(String[] args) {
41
42 ConfigurableApplicationContext context = SpringApplication.run(CliApp.class, args);
43
44
45 context.getBean(QuickStart.class).run();
46 }
47
48
49
50
51
52 @Bean
53 public Realm realm() {
54 TextConfigurationRealmonRealm.html#TextConfigurationRealm">TextConfigurationRealm realm = new TextConfigurationRealm();
55 realm.setUserDefinitions("joe.coder=password,user\n" +
56 "jill.coder=password,admin");
57
58 realm.setRoleDefinitions("admin=read,write\n" +
59 "user=read");
60 realm.setCachingEnabled(true);
61 return realm;
62 }
63
64 }