1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| // snipped...
public class ShiroLDAPTest {
private static Logger logger = LoggerFactory.getLogger(ShiroLDAPTest.class);
/**
* @param args
*/
public static void main(String[] args) {
// Using the IniSecurityManagerFactory, which will use the an INI file
// as the security file.
Factory<org.apache.shiro.mgt.SecurityManager> factory =
new IniSecurityManagerFactory("actived.ini");
// Setting up the SecurityManager...
org.apache.shiro.mgt.SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
Subject user = SecurityUtils.getSubject();
logger.info("User is authenticated: " + user.isAuthenticated());
UsernamePasswordToken token =
new UsernamePasswordToken(
"cn=Cornelius Buckley,ou=people,o=sevenSeas", "argh");
user.login(token);
logger.info("User is authenticated: " + user.isAuthenticated());
}
}
|