1 16 package org.jmanage.core.auth; 17 18 import org.jmanage.core.util.Expression; 19 20 25 public class ACLContext { 26 27 private static final String WILDCARD = Expression.WILDCARD; 28 29 private String appName = WILDCARD; 30 31 private String mbeanName = WILDCARD; 32 33 private String targetName = WILDCARD; 34 35 public ACLContext(String aclContext){ 36 Expression expr = new Expression(aclContext); 37 if(expr.getAppName() != null){ 38 appName = expr.getAppName(); 39 } 40 if(expr.getMBeanName() != null){ 41 mbeanName = expr.getMBeanName(); 45 } 46 if(expr.getTargetName() != null){ 47 targetName = expr.getTargetName(); 48 } 49 } 50 51 public ACLContext(String appName, String mbeanName, String targetName) { 52 if(appName != null){ 53 this.appName = appName; 54 } 55 if(mbeanName != null){ 56 this.mbeanName = mbeanName; 57 } 58 if(targetName != null){ 59 this.targetName = targetName; 60 } 61 } 62 63 public boolean equals(Object obj){ 64 if(obj instanceof ACLContext){ 65 ACLContext context = (ACLContext)obj; 66 return compare(context.appName, this.appName) && 67 compare(context.mbeanName, this.mbeanName) && 68 compare(context.targetName, this.targetName); 69 } 70 return false; 71 } 72 73 private boolean compare(String a, String b){ 74 boolean equals = false; 75 if(a == null && b == null){ 76 77 equals = true; 78 }else if(a == null || b == null){ 79 80 equals = false; 81 }else if(a.equals(WILDCARD) || b.equals(WILDCARD)){ 82 83 equals = true; 84 }else if(a.equals(b)){ 85 86 equals = true; 87 } 88 return equals; 89 } 90 } 91 | Popular Tags |