Subversion Repositories XServices

Rev

Rev 146 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 146 Rev 185
Line 15... Line 15...
15
*/
15
*/
Line 16... Line 16...
16
 
16
 
Line 17... Line -...
17
 
-
 
18
package net.brutex.xservices.security;
17
 
19
 
-
 
Line -... Line 18...
-
 
18
package net.brutex.xservices.security;
-
 
19
 
-
 
20
import org.apache.logging.log4j.Logger;
-
 
21
 
-
 
22
import java.net.URI;
-
 
23
import java.net.URISyntaxException;
-
 
24
import java.net.URL;
20
import java.text.ParseException;
25
 
21
import java.util.Collection;
26
import javax.servlet.ServletContext;
22
import java.util.Map;
27
 
23
 
28
import org.apache.catalina.core.ApplicationContext;
24
import org.apache.log4j.Logger;
29
import org.apache.logging.log4j.LogManager;
25
import org.apache.shiro.authc.AuthenticationException;
30
import org.apache.shiro.authc.AuthenticationException;
26
import org.apache.shiro.authc.AuthenticationInfo;
-
 
27
import org.apache.shiro.authc.AuthenticationToken;
31
import org.apache.shiro.authc.AuthenticationInfo;
28
import org.apache.shiro.authz.AuthorizationInfo;
32
import org.apache.shiro.authc.AuthenticationToken;
29
import org.apache.shiro.authz.Permission;
33
import org.apache.shiro.authz.AuthorizationInfo;
30
import org.apache.shiro.authz.permission.PermissionResolver;
34
import org.apache.shiro.authz.SimpleAuthorizationInfo;
-
 
35
import org.apache.shiro.config.Ini;
31
import org.apache.shiro.config.Ini;
36
import org.apache.shiro.io.ResourceUtils;
32
import org.apache.shiro.io.ResourceUtils;
37
import org.apache.shiro.realm.AuthorizingRealm;
-
 
38
import org.apache.shiro.realm.text.IniRealm;
33
import org.apache.shiro.realm.AuthorizingRealm;
39
import org.apache.shiro.realm.text.TextConfigurationRealm;
Line 34... Line 40...
34
import org.apache.shiro.realm.text.IniRealm;
40
import org.apache.shiro.subject.PrincipalCollection;
35
import org.apache.shiro.subject.PrincipalCollection;
41
import org.apache.shiro.util.Nameable;
36
import org.apache.shiro.util.Nameable;
42
import org.apache.shiro.web.env.IniWebEnvironment;
37
import org.apache.shiro.util.PermissionUtils;
43
import org.apache.shiro.web.util.WebUtils;
Line 49... Line 55...
49
 * The Class XServicesRealm.
55
 * The Class XServicesRealm.
50
 */
56
 */
51
public class XServicesRealm extends IniRealm implements Nameable  {
57
public class XServicesRealm extends IniRealm implements Nameable  {
Line 52... Line 58...
52
 
58
 
53
	/** The logger. */
59
	/** The logger. */
Line 54... Line 60...
54
	private static Logger logger = Logger.getLogger(XServicesRealm.class);
60
	private final Logger logger = LogManager.getLogger();
55
	
61
	
Line 56... Line 62...
56
	/** The name. */
62
	/** The name. */
Line 68... Line 74...
68
	/**
74
	/**
69
	 * Instantiates a new x services realm with default
75
	 * Instantiates a new x services realm with default
70
	 * 'shiro.ini' in classpath and {@link net.brutex.xservices.security.PermissionResolver PermissionResolver}.
76
	 * 'shiro.ini' in classpath and {@link net.brutex.xservices.security.PermissionResolver PermissionResolver}.
71
	 * 
77
	 * 
72
	 */
78
	 */
-
 
79
	
73
	public XServicesRealm() {
80
	public XServicesRealm() {
74
		super();
81
		super();
-
 
82
		/* needs review */
-
 
83
		URI classesRootDir;
-
 
84
		try {
-
 
85
			classesRootDir = getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
-
 
86
			String dir = classesRootDir.toString().replaceAll("%20", " ");
-
 
87
			dir = dir.substring(0,  dir.lastIndexOf("WEB-INF"));
75
		this.setIni(Ini.fromResourcePath(ResourceUtils.CLASSPATH_PREFIX+"shiro.ini"));
88
		this.setIni(Ini.fromResourcePath(dir+"/WEB-INF/shiro.ini"));
-
 
89
		} catch (URISyntaxException e) {
-
 
90
			logger.error(e.getMessage(), e);
-
 
91
			e.printStackTrace();
-
 
92
		}
-
 
93
		
-
 
94
		
76
		this.setPermissionResolver(new net.brutex.xservices.security.PermissionResolver());
95
		this.setPermissionResolver(new net.brutex.xservices.security.PermissionResolver());
77
		//this.setRolePermissionResolver(new RolePermissionResolver());
-
 
78
		init();
-
 
79
	}	
96
	}
-
 
97
 
-
 
98
 
-
 
99
	
80
}
100
}