Subversion Repositories XServices

Rev

Rev 198 | Details | Compare with Previous | 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
 
199 brianR 20
 
21
import lombok.extern.slf4j.Slf4j;
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
 */
199 brianR 41
@Slf4j
146 brianR 42
public class XServicesRealm extends IniRealm implements Nameable  {
43
 
44
 
45
	/** The name. */
46
	private String name;
47
 
48
	/* (non-Javadoc)
49
	 * @see org.apache.shiro.realm.AuthorizingRealm#setName(java.lang.String)
50
	 */
51
	@Override
52
	public void setName(String name) {
53
		this.name = name;
54
	}
55
 
56
 
57
	/**
58
	 * Instantiates a new x services realm with default
59
	 * 'shiro.ini' in classpath and {@link net.brutex.xservices.security.PermissionResolver PermissionResolver}.
60
	 *
61
	 */
185 brianR 62
 
146 brianR 63
	public XServicesRealm() {
64
		super();
185 brianR 65
		/* needs review */
66
		URI classesRootDir;
67
		try {
68
			classesRootDir = getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
69
			String dir = classesRootDir.toString().replaceAll("%20", " ");
70
			dir = dir.substring(0,  dir.lastIndexOf("WEB-INF"));
71
		this.setIni(Ini.fromResourcePath(dir+"/WEB-INF/shiro.ini"));
72
		} catch (URISyntaxException e) {
199 brianR 73
			log.error(e.getMessage(), e);
185 brianR 74
			e.printStackTrace();
75
		}
76
 
77
 
146 brianR 78
		this.setPermissionResolver(new net.brutex.xservices.security.PermissionResolver());
185 brianR 79
	}
80
 
81
 
82
 
146 brianR 83
}