// See if we have authentication
String ucItem = item.toUpperCase();
try {
Authentication auth = Authentication.valueOf(ucItem);
if (authentication != null && auth != authentication) {
throw new InvalidAccessValueException("Access attribute cannot specify both AUTHENTICATED and UNAUTHENTICATED");
}
authentication = auth;
return;
} catch (IllegalArgumentException e) {
// continue to try other possibilities
}
// See if it is one of the scope constants
try {
Access acc = Access.valueOf(item.toUpperCase());
if (access != null && access != acc) {
throw new InvalidAccessValueException("Access attribute can only specifiy one of GLOBAL, PUBLIC, or PRIVATE"); // or internal
}
access = acc;
return;
} catch (IllegalArgumentException e) {
// continue to try other possibilities
}
// Look for classname.methodname
int dotPos = item.lastIndexOf('.');
if (dotPos > 0) {
String className = item.substring(0, dotPos);
String methodName = item.substring(dotPos + 1);
try {
Class<?> clazz = Class.forName(className);
Method meth = clazz.getMethod(methodName, new Class[0]);
if (!Modifier.isStatic(meth.getModifiers())) {
throw new InvalidAccessValueException("\"" + item + "\" must be a static method");
}
Class<?> retType = meth.getReturnType();
if (! Access.class.equals(retType)) {
throw new InvalidAccessValueException("\"" + item + "\" must return a result of type " +
Access.class.getName());
}
if (this.accessMethod != null) {
throw new InvalidAccessValueException("Access attribute may not specify more than one static method");
}
this.accessMethod = meth;
return;
} catch (ClassNotFoundException e) {
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
}
throw new InvalidAccessValueException("\"" + item + "\" is not a valid public method reference");
}
throw new InvalidAccessValueException("Invalid access atttribute value \"" + item + "\"");
}