Subversion Repositories XServices

Rev

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

Rev 146 Rev 177
Line 14... Line 14...
14
 *   limitations under the License.
14
 *   limitations under the License.
15
*/
15
*/
Line 16... Line 16...
16
 
16
 
Line -... Line 17...
-
 
17
package net.brutex.xservices.security;
-
 
18
 
-
 
19
import net.brutex.xservices.ws.XmlService;
17
package net.brutex.xservices.security;
20
import net.brutex.xservices.ws.rs.FileInfo;
18
 
21
 
-
 
22
import org.apache.log4j.Logger;
Line 19... Line 23...
19
import org.apache.log4j.Logger;
23
import org.apache.shiro.authz.Permission;
20
import org.apache.shiro.authz.Permission;
24
import org.apache.shiro.authz.permission.InvalidPermissionStringException;
21
 
25
 
22
/**
26
/**
23
 * @author Brian Rosenberger, bru(at)brutex.de
27
 * @author Brian Rosenberger, bru(at)brutex.de
Line 24... Line 28...
24
 *
28
 *
-
 
29
 */
Line 25... Line 30...
25
 */
30
public class PermissionResolver implements org.apache.shiro.authz.permission.PermissionResolver {
26
public class PermissionResolver implements org.apache.shiro.authz.permission.PermissionResolver {
31
	
27
	
32
	final Logger logger = Logger.getLogger(PermissionResolver.class);
-
 
33
	private final String DELIMITER = "||";
-
 
34
 
-
 
35
	@Override
-
 
36
	public Permission resolvePermission(String permissionString) {
-
 
37
		logger.debug(String.format("Trying to examine new Permission '%s'", permissionString));
-
 
38
		if(! permissionString.contains(DELIMITER)) {
-
 
39
			logger.error(String.format("Permission '%s' is missing permission class.", permissionString));
-
 
40
			throw new InvalidPermissionStringException(String.format("Permission '%s' is missing permission class.", permissionString), permissionString);
-
 
41
		}
-
 
42
		int delimiterIndex = permissionString.indexOf(DELIMITER);
-
 
43
		String value = permissionString.substring(0, delimiterIndex);
-
 
44
		delimiterIndex = delimiterIndex + DELIMITER.length();
-
 
45
		switch (value) {
-
 
46
		case XmlService.SERVICE_NAME:
28
	final Logger logger = Logger.getLogger(PermissionResolver.class);
47
			logger.debug(String.format("Found '%s' as permission class.", value));
-
 
48
			return new XmlServicePermission(permissionString.substring( delimiterIndex ));
-
 
49
		
-
 
50
		case FileInfo.SERVICE_NAME:
-
 
51
			logger.debug(String.format("Found '%s' as permission class.", value));
-
 
52
			return new DirectoryPermission(permissionString.substring( delimiterIndex ));
-
 
53
 
29
 
54
 
30
	@Override
55
		default: