Subversion Repositories XServices

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
146 brianR 1
/*
2
 *   Copyright 2013 Brian Rosenberger (Brutex Network)
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
15
*/
16
 
17
 
18
package net.brutex.xservices.security;
19
 
197 brianR 20
import org.apache.logging.log4j.LogManager;
185 brianR 21
import org.apache.logging.log4j.Logger;
197 brianR 22
import org.apache.shiro.config.Ini;
23
import org.apache.shiro.realm.text.IniRealm;
24
import org.apache.shiro.util.Nameable;
146 brianR 25
 
185 brianR 26
import java.net.URI;
27
import java.net.URISyntaxException;
28
 
146 brianR 29
// TODO: Auto-generated Javadoc
30
/*
31
 * For later use. A Realm connects to a DS where Users/ Passes are defined
32
 * and allows Shiro to transparently work against different user/pass stores
33
 * (i.e. LDAP, Custom, etc.)
34
 *
35
 * @author Brian Rosenberger, bru(at)brutex.de
36
 *
37
 */
38
/**
39
 * The Class XServicesRealm.
40
 */
41
public class XServicesRealm extends IniRealm implements Nameable  {
42
 
43
	/** The logger. */
185 brianR 44
	private final Logger logger = LogManager.getLogger();
146 brianR 45
 
46
	/** The name. */
47
	private String name;
48
 
49
	/* (non-Javadoc)
50
	 * @see org.apache.shiro.realm.AuthorizingRealm#setName(java.lang.String)
51
	 */
52
	@Override
53
	public void setName(String name) {
54
		this.name = name;
55
	}
56
 
57
 
58
	/**
59
	 * Instantiates a new x services realm with default
60
	 * 'shiro.ini' in classpath and {@link net.brutex.xservices.security.PermissionResolver PermissionResolver}.
61
	 *
62
	 */
185 brianR 63
 
146 brianR 64
	public XServicesRealm() {
65
		super();
185 brianR 66
		/* needs review */
67
		URI classesRootDir;
68
		try {
69
			classesRootDir = getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
70
			String dir = classesRootDir.toString().replaceAll("%20", " ");
71
			dir = dir.substring(0,  dir.lastIndexOf("WEB-INF"));
72
		this.setIni(Ini.fromResourcePath(dir+"/WEB-INF/shiro.ini"));
73
		} catch (URISyntaxException e) {
74
			logger.error(e.getMessage(), e);
75
			e.printStackTrace();
76
		}
77
 
78
 
146 brianR 79
		this.setPermissionResolver(new net.brutex.xservices.security.PermissionResolver());
185 brianR 80
	}
81
 
82
 
83
 
146 brianR 84
}