PolicyContext
class.
* The PolicyContext
class provides methods for containers to
* register and activate container-specific PolicyContext
handlers.
* Policy
providers use the PolicyContext
class to
* activate handlers to obtain (from the container) additional policy relevant
* context to apply in their access decisions. All handlers registered and
* activated via the PolicyContext
class must implement the
* PolicyContextHandler
interface.
*
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public interface PolicyContextHandler {
/**
* This public method returns a boolean result indicating whether or not
* the handler supports the context object identified by the
* (case-sensitive) key value.
* @param key a String
PolicyContext/ class to
* activate the handler and obtain from it the the context object
* identified by the (case-sensitive) key. In addition to the key, the
* handler will be activated with the handler data value associated within
* the PolicyContext
class with the thread on which the call
* to this method is made.
*
* Note that the policy context identifier associated with a thread is
* available to the handler by calling PolicyContext.getContextID().
* @param key a String that identifies the context object to be returned by
* the handler. The value of this paramter must not be null.
* @param data the handler data Object
associated with the
* thread on which the call to this method has been made. Note that the
* value passed through this parameter may be null.
* @return The container and handler specific Object
* containing the desired context. A null value may be returned if the
* value of the corresponding context is null.
* @throws PolicyContextException if the implementation throws a checked
* exception that has not been accounted for by the method signature. The
* exception thrown by the implementation class will be encapsulated
* (during construction) in the thrown PolicyContextException
*/
public Object getContext(String key, Object data) throws PolicyContextException;
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/HTTPMethodSpec.java 0000644 0000000 0000000 00000025730 10533674527 026106 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.regex.Pattern;
/**
* @version $Rev: 481119 $ $Date: 2006-12-01 01:37:43 +0100 (ven. 01 déc. 2006) $
*/
final class HTTPMethodSpec {
private final static String[] HTTP_METHODS = {"GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE"};
private final static int[] HTTP_MASKS = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40};
final static int NA = 0x00;
final static int INTEGRAL = 0x01;
final static int CONFIDENTIAL = 0x02;
final static int NONE = INTEGRAL | CONFIDENTIAL;
private final int mask;
private final String[] extensionMethods;
private final boolean isExcluded;
private final int transport;
private String actions;
private static final String[] NO_METHODS = new String[0];
private static final Pattern TOKEN_PATTERN = Pattern.compile("[!-~&&[^\\(\\)\\<\\>@,;:\\\\\"/\\[\\]\\?=\\{\\}]]*");
public HTTPMethodSpec(String[] HTTPMethods) {
this(HTTPMethods, null);
}
public HTTPMethodSpec(String name, boolean parseTransportType) {
if (parseTransportType) {
if (name == null || name.length() == 0) {
this.transport = NONE;
} else {
String[] tokens = name.split(":", 2);
if (tokens.length == 2) {
if (tokens[1].equals("NONE")) {
this.transport = NONE;
} else if (tokens[1].equals("INTEGRAL")) {
this.transport = INTEGRAL;
} else if (tokens[1].equals("CONFIDENTIAL")) {
this.transport = CONFIDENTIAL;
} else {
throw new IllegalArgumentException("Invalid transportType: " + tokens[1]);
}
} else {
this.transport = NONE;
}
name = tokens[0];
}
} else {
this.transport = NA;
}
if (name == null || name.length() == 0) {
this.mask = 0x00;
this.extensionMethods = NO_METHODS;
this.isExcluded = true;
} else {
ArrayList extensions = null;
if (isExcluded = name.charAt(0) == '!') {
name = name.substring(1);
}
String[] methods = name.split(",", -1);
int tmpMask = 0;
for (int i = 0; i < methods.length; i++) {
boolean found = false;
for (int j = 0; j < HTTP_METHODS.length; j++) {
if (methods[i].equals(HTTP_METHODS[j])) {
tmpMask |= HTTP_MASKS[j];
found = true;
break;
}
}
if (!found) {
checkToken(methods[i]);
if (extensions == null) {
extensions = new ArrayList(methods.length);
}
add(extensions, methods[i]);
}
}
this.mask = tmpMask;
if (extensions == null) {
extensionMethods = NO_METHODS;
} else {
extensionMethods = extensions.toArray(new String[extensions.size()]);
}
}
}
public HTTPMethodSpec(String[] HTTPMethods, String transport) {
boolean parseTransportType = transport != null;
if (HTTPMethods == null || HTTPMethods.length == 0) {
this.mask = 0x00;
this.extensionMethods = NO_METHODS;
this.isExcluded = true;
} else {
int tmpMask = 0;
this.isExcluded = false;
ArrayList extensions = null;
for (int i = 0; i < HTTPMethods.length; i++) {
boolean found = false;
for (int j = 0; j < HTTP_METHODS.length; j++) {
if (HTTPMethods[i].equals(HTTP_METHODS[j])) {
tmpMask |= HTTP_MASKS[j];
found = true;
break;
}
}
if (!found) {
checkToken(HTTPMethods[i]);
if (extensions == null) {
extensions = new ArrayList(HTTPMethods.length);
}
add(extensions, HTTPMethods[i]);
}
}
this.mask = tmpMask;
if (extensions == null) {
extensionMethods = NO_METHODS;
} else {
extensionMethods = extensions.toArray(new String[extensions.size()]);
}
}
if (parseTransportType) {
if (transport.length() == 0 || transport.equals("NONE")) {
this.transport = NONE;
} else if (transport.equals("INTEGRAL")) {
this.transport = INTEGRAL;
} else if (transport.equals("CONFIDENTIAL")) {
this.transport = CONFIDENTIAL;
} else {
throw new IllegalArgumentException("Invalid transport");
}
} else {
this.transport = NA;
}
}
public HTTPMethodSpec(String singleMethod, int transport) {
int tmpMask = 0;
for (int j = 0; j < HTTP_METHODS.length; j++) {
if (HTTP_METHODS[j].equals(singleMethod)) {
tmpMask = HTTP_MASKS[j];
break;
}
}
if (tmpMask == 0) {
checkToken(singleMethod);
this.extensionMethods = new String[]{singleMethod};
} else {
this.extensionMethods = NO_METHODS;
}
this.mask = tmpMask;
this.isExcluded = false;
this.transport = transport;
}
private void checkToken(String method) {
if (!TOKEN_PATTERN.matcher(method).matches()) {
throw new IllegalArgumentException("Invalid HTTPMethodSpec");
}
}
private void add(ArrayList extensions, String httpMethod) {
for (int i = 0; i < extensions.size(); i++) {
String existingMethod = extensions.get(i);
int compare = existingMethod.compareTo(httpMethod);
if (compare == 0) {
return;
}
if (compare > 0) {
extensions.add(i, httpMethod);
return;
}
}
extensions.add(httpMethod);
}
public boolean equals(HTTPMethodSpec o) {
return mask == o.mask && transport == o.transport;
}
public String getActions() {
if (actions == null) {
if (isAll()) {
actions = "";
} else {
boolean first = true;
StringBuffer buffer = new StringBuffer();
if (isExcluded) {
buffer.append("!");
}
for (int i = 0; i < HTTP_MASKS.length; i++) {
if ((mask & HTTP_MASKS[i]) > 0) {
if (first) {
first = false;
} else {
buffer.append(",");
}
buffer.append(HTTP_METHODS[i]);
}
}
for (int i = 0; i < extensionMethods.length; i++) {
String method = extensionMethods[i];
if (first) {
first = false;
} else {
buffer.append(",");
}
buffer.append(method);
}
if (transport == INTEGRAL) {
buffer.append(":INTEGRAL");
} else if (transport == CONFIDENTIAL) {
buffer.append(":CONFIDENTIAL");
}
actions = buffer.toString();
}
}
return actions;
}
private boolean isAll() {
return isExcluded && mask == 0x00;
}
public int hashCode() {
return mask ^ transport;
}
public boolean implies(HTTPMethodSpec p) {
if ((transport & p.transport) != p.transport) {
return false;
}
if (isExcluded) {
if (p.isExcluded) {
return ((mask & p.mask) == mask) && contains(p.extensionMethods, extensionMethods);
} else {
return ((mask & p.mask) == 0x00) && isDisjoint(extensionMethods, p.extensionMethods);
}
} else {
if (p.isExcluded) {
return false;
} else {
return ((mask & p.mask) == p.mask) && contains(extensionMethods, p.extensionMethods);
}
}
}
private boolean isDisjoint(String[] a, String[] b) {
int start = 0;
for (int i = 0; i < a.length; i++) {
String s = a[i];
for (int j = start; j < b.length; j++) {
String s1 = b[j];
int compare = s.compareTo(s1);
if (compare == 0) {
return false;
}
if (compare < 0) {
start = j;
break;
}
}
}
return true;
}
private boolean contains(String[] set, String[] subset) {
int start = 0;
for (int i = 0; i < subset.length; i++) {
boolean found = false;
String s = subset[i];
for (int j = start; j < set.length; j++) {
String s1 = set[j];
int compare = s.compareTo(s1);
if (compare == 0) {
found = true;
start = j + 1;
break;
}
if (compare < 0) {
return false;
}
}
if (!found) {
return false;
}
}
return true;
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/EJBRoleRefPermission.java 0000644 0000000 0000000 00000012577 10517560657 027310 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.io.Serializable;
import java.security.Permission;
/**
* Class for EJB isCallerInRole(String reference)
permissions. An
* EJBRoleRefPermission is a named permission and has actions.
*
* The name of an EJBRoleRefPermission contains the value of the ejb-name
* element in the application's deployment descriptor that identifies the EJB
* in whose context the permission is being evalutated.
*
* The actions of an EJBRoleRefPermission identifies the role reference to
* which the permission applies. An EJBRoleRefPermission is checked to
* determine if the subject is a member of the role identified by the reference.
*
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public final class EJBRoleRefPermission extends Permission implements Serializable {
private transient int cachedHashCode = 0;
private String actions;
/**
* Creates a new EJBRoleRefPermission with the specified name and actions.
* @param name the ejb-name that identifies the EJB in whose context the
* role references are to be evaluated.
* @param role identifies the role reference to which the permission
* pertains. The role reference is scoped to the EJB identified in the
* name parameter. The value of the role reference must not be null or
* the empty string.
*/
public EJBRoleRefPermission(String name, String role) {
super(name);
if (role == null || role.length() == 0)
throw new IllegalArgumentException("Role reference must not be null or the empty string");
actions = role;
}
/**
* Checks two EJBRoleRefPermission objects for equality. EJBRoleRefPermission
* objects are equivalent if they have case equivalent name and actions values.
*
* Two Permission objects, P1 and P2, are equivalent if and only if P1.implies(P2) && P2.implies(P1).
* @param o the EJBRoleRefPermission object being tested for equality with this EJBRoleRefPermission.
* @return true if the argument EJBRoleRefPermission object is equivalent to this EJBRoleRefPermission.
*/
public boolean equals(Object o) {
if (o == null || !(o instanceof EJBRoleRefPermission)) return false;
EJBRoleRefPermission other = (EJBRoleRefPermission)o;
return getName().equals(other.getName()) && actions.equals(other.actions);
}
/**
* Returns a canonical String representation of the actions of this EJBRoleRefPermission.
* @return a String containing the canonicalized actions of this EJBRoleRefPermission.
*/
public String getActions() {
return actions;
}
/**
* Returns the hash code value for this EJBRoleRefPermission. The properties
* of the returned hash code must be as follows:
*
* - During the lifetime of a Java application, the hashCode method must
* return the same integer value, every time it is called on a EJBRoleRefPermission
* object. The value returned by hashCode for a particular EJBRoleRefPermission
* need not remain consistent from one execution of an application to another.
* - If two EJBRoleRefPermission objects are equal according to the equals
* method, then calling the hashCode method on each of the two Permission
* objects must produce the same integer result (within an application).
*
* @return the integer hash code value for this object.
*/
public int hashCode() {
if (cachedHashCode == 0) {
cachedHashCode = getName().hashCode() ^ actions.hashCode();
}
return cachedHashCode;
}
/**
* Determines if the argument Permission is "implied by" this
* EJBRoleRefPermission. For this to be the case,
*
*
* - The argument must be an instanceof EJBRoleRefPermission
* - with name equivalent to that of this EJBRoleRefPermission, and
* - with the role reference equivalent to that of this EJBRoleRefPermission applies.
*
* The name and actions comparisons described above are case sensitive.
* @param permission "this" EJBRoleRefPermission is checked to see if it implies the argument permission.
* @return true if the specified permission is implied by this object, false if not.
*/
public boolean implies(Permission permission) {
return equals(permission);
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/EJBMethodPermission.java 0000644 0000000 0000000 00000041374 10600715556 027160 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.PrivilegedAction;
import java.util.LinkedList;
import java.util.HashMap;
import java.util.Enumeration;
import java.util.Collections;
/**
* @version $Rev: 521639 $ $Date: 2007-03-23 10:18:38 +0100 (ven. 23 mars 2007) $
*/
public final class EJBMethodPermission extends Permission implements Serializable {
private final static String NEW_METHOD_INTERFACES = "org.apache.security.jacc.EJBMethodPermission.methodInterfaces";
private static String[] methodInterfaces;
static {
String newMethodInterfaces = (String) AccessController.doPrivileged(new
PrivilegedAction() {
public Object run() {
return System.getProperty(NEW_METHOD_INTERFACES);
}
});
if (newMethodInterfaces != null) {
newMethodInterfaces = newMethodInterfaces + ",Home,LocalHome,Remote,Local,ServiceEndpoint";
} else {
newMethodInterfaces = "Home,LocalHome,Remote,Local,ServiceEndpoint";
}
methodInterfaces = newMethodInterfaces.split(",", -1);
}
private transient int cachedHashCode;
private transient MethodSpec methodSpec;
public EJBMethodPermission(String name, String spec) {
super(name);
methodSpec = new MethodSpec(spec);
}
public EJBMethodPermission(String EJBName, String methodName, String methodInterface, String[] methodParams) {
super(EJBName);
methodSpec = new MethodSpec(methodName, methodInterface, methodParams);
}
public EJBMethodPermission(String EJBName, String methodInterface, Method method) {
super(EJBName);
if (method == null) throw new IllegalArgumentException("Parameter method must not be null");
methodSpec = new MethodSpec(methodInterface, method);
}
public boolean equals(Object o) {
if (o == null || !(o instanceof EJBMethodPermission)) return false;
EJBMethodPermission other = (EJBMethodPermission) o;
return getName().equals(other.getName()) && methodSpec.equals(other.methodSpec);
}
public String getActions() {
return methodSpec.getActions();
}
public int hashCode() {
if (cachedHashCode == 0) {
cachedHashCode = getName().hashCode() ^ methodSpec.hashCode();
}
return cachedHashCode;
}
public boolean implies(Permission permission) {
if (permission == null || !(permission instanceof EJBMethodPermission)) return false;
EJBMethodPermission other = (EJBMethodPermission) permission;
return getName().equals(other.getName()) && methodSpec.implies(other.methodSpec);
}
public PermissionCollection newPermissionCollection() {
return new EJBMethodPermissionCollection();
}
private synchronized void readObject(ObjectInputStream in) throws IOException {
methodSpec = new MethodSpec(in.readUTF());
}
private synchronized void writeObject(ObjectOutputStream out) throws IOException {
out.writeUTF(methodSpec.getActions());
}
private static class MethodSpec {
protected String methodName;
protected String methodInterface;
protected String methodParams;
protected String actions;
public MethodSpec(String actionString) {
if (actionString == null || actionString.length() == 0) {
methodName = null;
methodInterface = null;
methodParams = null;
actions = "";
} else {
String[] tokens = actionString.split(",", 3);
switch (tokens.length) {
case 1:
{
methodName = emptyNullCheck(tokens[0]);
methodInterface = null;
methodParams = null;
break;
}
case 2:
{
if (tokens[1].length() == 0) throw new IllegalArgumentException("This format of actions requires a method interface");
checkMethodInterface(tokens[1]);
methodName = emptyNullCheck(tokens[0]);
methodInterface = emptyNullCheck(tokens[1]);
methodParams = null;
break;
}
case 3:
{
checkMethodInterface(tokens[1]);
if (tokens[2].indexOf(',') > -1) {
String[] test = tokens[2].split(",", -1);
for (int i = 0; i < test.length; i++) {
if (test[i].length() == 0) throw new IllegalArgumentException("Invalid type name");
}
}
methodName = emptyNullCheck(tokens[0]);
methodInterface = emptyNullCheck(tokens[1]);
methodParams = tokens[2];
}
}
actions = actionString;
}
}
public MethodSpec(String mthdName, String mthdInterface, String[] methodParamsArray) {
checkMethodInterface(mthdInterface);
methodName = emptyNullCheck(mthdName);
methodInterface = emptyNullCheck(mthdInterface);
if (methodParamsArray == null) {
methodParams = null;
} else if (methodParamsArray.length == 0) {
methodParams = "";
} else {
if (methodParamsArray[0] == null || methodParamsArray[0].length() == 0) throw new IllegalArgumentException("Invalid type name");
StringBuffer buffer = new StringBuffer(methodParamsArray[0]);
for (int i = 1; i < methodParamsArray.length; i++) {
if (methodParamsArray[i] == null || methodParamsArray[i].length() == 0) throw new IllegalArgumentException("Invalid type name");
buffer.append(",");
buffer.append(methodParamsArray[i]);
}
methodParams = buffer.toString();
}
initActions();
}
public MethodSpec(String mthdInterface, Method method) {
checkMethodInterface(mthdInterface);
methodName = method.getName();
methodInterface = emptyNullCheck(mthdInterface);
Class[] paramTypes = method.getParameterTypes();
if (paramTypes.length == 0) {
methodParams = "";
} else {
StringBuffer buffer = new StringBuffer(paramTypes[0].getName());
for (int i = 1; i < paramTypes.length; i++) {
buffer.append(",");
buffer.append(paramTypes[i].getName());
}
methodParams = buffer.toString();
}
initActions();
}
public boolean equals(MethodSpec spec) {
return implies(spec) && spec.implies(this);
}
public String getActions() {
return actions;
}
public int hashCode() {
return actions.hashCode();
}
public boolean implies(MethodSpec methodSpec) {
if (methodName == null || methodName.equals(methodSpec.methodName)) {
if (methodInterface == null || methodInterface.equals(methodSpec.methodInterface)) {
if (methodParams == null || methodParams.equals(methodSpec.methodParams)) {
return true;
} else
return false;
} else
return false;
} else
return false;
}
private void initActions() {
if (methodParams == null) {
if (methodInterface == null) {
if (methodName == null) {
actions = "";
} else {
actions = methodName;
}
} else {
if (methodName == null) {
actions = "," + methodInterface;
} else {
actions = methodName + "," + methodInterface;
}
}
} else {
if (methodInterface == null) {
if (methodName == null) {
actions = ",," + methodParams;
} else {
actions = methodName + ",," + methodParams;
}
} else {
if (methodName == null) {
actions = "," + methodInterface + "," + methodParams;
} else {
actions = methodName + "," + methodInterface + "," + methodParams;
}
}
}
}
private void checkMethodInterface(String methodInterface) {
if (methodInterface == null || methodInterface.length() == 0) return;
for (int i = 0; i < methodInterfaces.length; i++) {
if (methodInterfaces[i].equals(methodInterface)) return;
}
throw new IllegalArgumentException("Invalid method interface: " + methodInterface);
}
/**
* For the method name, method interface, and method parameters, a
* value of null
indicates a wildcard value. This
* function is used to check if we are passed a null
* or empty string, which indicates a wildcard.
*
* @param name The name to be checked.
* @return null
if we are passed a null
or empty string else
* we return the name.
*/
private String emptyNullCheck(String name) {
if (name != null && name.length() == 0) {
return null;
} else {
return name;
}
}
}
private static final class EJBMethodPermissionCollection extends PermissionCollection {
private LinkedList collection = new LinkedList();
private HashMap permissions = new HashMap();
private static final String WILDCARD = new String("$WILDCARD");
/**
* Adds a permission object to the current collection of permission objects.
*
* @param permission the Permission object to add.
*
* @exception SecurityException - if this PermissionCollection object
* has been marked readonly
*/
public void add(Permission permission) {
if (isReadOnly()) throw new IllegalArgumentException("Read only collection");
if (!(permission instanceof EJBMethodPermission)) throw new IllegalArgumentException("Wrong permission type");
if (collection.contains(permission)) return;
else collection.add(permission);
EJBMethodPermission p = (EJBMethodPermission)permission;
EJBMethodPermission.MethodSpec spec = p.methodSpec;
Object test = permissions.get(p.getName());
if (test instanceof Boolean) return;
if (spec.methodName == null && spec.methodInterface == null && spec.methodParams == null) {
permissions.put(p.getName(), new Boolean(true));
return;
}
HashMap methods = (HashMap)test;
if (methods == null) {
methods = new HashMap();
permissions.put(p.getName(), methods);
}
Object methodKey = (spec.methodName == null || spec.methodName.length() == 0? WILDCARD:spec.methodName);
HashMap interfaces = (HashMap)methods.get(methodKey);
if (interfaces == null) {
interfaces = new HashMap();
methods.put(methodKey, interfaces);
}
Object interfaceKey = (spec.methodInterface == null || spec.methodInterface.length() == 0? WILDCARD:spec.methodInterface);
HashMap parameters = (HashMap)interfaces.get(interfaceKey);
if (parameters == null) {
parameters = new HashMap();
interfaces.put(interfaceKey, parameters);
}
// an empty string for a parameter spec indicates a method w/ no parameters
Object parametersKey = (spec.methodParams == null? WILDCARD:spec.methodParams);
Object parameter = parameters.get(parametersKey);
if (parameter == null) {
parameter = new Boolean(true);
parameters.put(parametersKey, parameter);
}
}
/**
* Checks to see if the specified permission is implied by
* the collection of Permission objects held in this PermissionCollection.
*
* @param permission the Permission object to compare.
*
* @return true if "permission" is implied by the permissions in
* the collection, false if not.
*/
public boolean implies(Permission permission) {
if (!(permission instanceof EJBMethodPermission)) return false;
EJBMethodPermission p = (EJBMethodPermission)permission;
EJBMethodPermission.MethodSpec spec = p.methodSpec;
Object test = permissions.get(p.getName());
if (test == null) return false;
if (test instanceof Boolean) return true;
HashMap methods = (HashMap)test;
Object methodKey = (spec.methodName == null || spec.methodName.length() == 0? WILDCARD:spec.methodName);
HashMap interfaces = (HashMap)methods.get(methodKey);
if (methodImplies(interfaces, spec)) return true;
if (methodKey != WILDCARD) {
return methodImplies((HashMap)methods.get(WILDCARD), spec);
}
return false;
}
protected boolean methodImplies(HashMap interfaces, EJBMethodPermission.MethodSpec spec) {
if (interfaces == null) return false;
Object interfaceKey = (spec.methodInterface == null || spec.methodInterface.length() == 0? WILDCARD:spec.methodInterface);
HashMap parameters = (HashMap)interfaces.get(interfaceKey);
if (interfaceImplies(parameters, spec)) return true;
if (interfaceKey != WILDCARD) {
return interfaceImplies((HashMap)interfaces.get(WILDCARD), spec);
}
return false;
}
protected boolean interfaceImplies(HashMap parameters, EJBMethodPermission.MethodSpec spec) {
if (parameters == null) return false;
// An empty string for a parameter spec indicates a method w/ no parameters
// so we won't convert an empty string to a wildcard.
Object parametersKey = (spec.methodParams == null? WILDCARD:spec.methodParams);
Object parameter = parameters.get(parametersKey);
if (parameter != null) return true;
if (parametersKey != WILDCARD) {
return parameters.containsKey(WILDCARD);
}
return false;
}
/**
* Returns an enumeration of all the Permission objects in the collection.
*
* @return an enumeration of all the Permissions.
*/
public Enumeration elements() {
return Collections.enumeration(collection);
}
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/PolicyConfigurationFactory.java 0000644 0000000 0000000 00000020225 10517560657 030664 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.SecurityPermission;
/**
* Abstract factory and finder class for obtaining the instance of the class
* that implements the PolicyConfigurationFactory of a provider. The factory
* will be used to instantiate PolicyConfiguration objects that will be used
* by the deployment tools of the container to create and manage policy
* contexts within the Policy Provider.
*
* Implementation classes must have a public no argument constructor that may
* be used to create an operational instance of the factory implementation class.
* @see java.security.Permission
* @see PolicyConfiguration
* @see PolicyContextException
*
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public abstract class PolicyConfigurationFactory {
private final static String FACTORY_NAME = "javax.security.jacc.PolicyConfigurationFactory.provider";
private static PolicyConfigurationFactory policyConfigurationFactory;
/**
* This static method uses a system property to find and instantiate (via a
* public constructor) a provider specific factory implementation class.
* The name of the provider specific factory implementation class is
* obtained from the value of the system property,
* javax.security.jacc.PolicyConfigurationFactory.provider
.
* @return the singleton instance of the provider specific
* PolicyConfigurationFactory implementation class.
* @throws ClassNotFoundException when the class named by the system
* property could not be found including because the value of the system
* property has not be set.
* @throws PolicyContextException if the implementation throws a checked
* exception that has not been accounted for by the
* getPolicyConfigurationFactory method signature. The exception thrown by
* the implementation class will be encapsulated (during construction) in
* the thrown PolicyContextException
*/
public static PolicyConfigurationFactory getPolicyConfigurationFactory() throws ClassNotFoundException, PolicyContextException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(new SecurityPermission("setPolicy"));
if (policyConfigurationFactory != null) return policyConfigurationFactory;
final String[] factoryClassName = { null };
try {
policyConfigurationFactory = (PolicyConfigurationFactory)AccessController.doPrivileged(new
PrivilegedExceptionAction() {
public Object run() throws Exception
{
factoryClassName[0] = System.getProperty(FACTORY_NAME);
if (factoryClassName[0] == null) throw new ClassNotFoundException("Property " + FACTORY_NAME + " not set");
Thread currentThread = Thread.currentThread();
ClassLoader tccl = currentThread.getContextClassLoader();
return Class.forName(factoryClassName[0], true, tccl).newInstance();
}
});
} catch(PrivilegedActionException pae) {
if (pae.getException() instanceof ClassNotFoundException) {
throw (ClassNotFoundException)pae.getException();
} else if (pae.getException() instanceof InstantiationException) {
throw new ClassNotFoundException(factoryClassName[0] + " could not be instantiated");
} else if (pae.getException() instanceof IllegalAccessException) {
throw new ClassNotFoundException("Illegal access to " + factoryClassName);
}
throw new PolicyContextException(pae.getException());
}
return policyConfigurationFactory;
}
/**
* This method is used to obtain an instance of the provider specific class
* that implements the PolicyConfiguration interface that corresponds to
* the identified policy context within the provider. The methods of the
* PolicyConfiguration interface are used to define the policy statements
* of the identified policy context.
*
* If at the time of the call, the identified policy context does not exist
* in the provider, then the policy context will be created in the provider
* and the Object that implements the context's PolicyConfiguration
* Interface will be returned. If the state of the identified context is
* "deleted" or "inService" it will be transitioned to the "open" state as
* a result of the call. The states in the lifecycle of a policy context
* are defined by the PolicyConfiguration interface.
*
* For a given value of policy context identifier, this method must always
* return the same instance of PolicyConfiguration and there must be at
* most one actual instance of a PolicyConfiguration with a given policy
* context identifier (during a process context).
*
* To preserve the invariant that there be at most one PolicyConfiguration
* object for a given policy context, it may be necessary for this method
* to be thread safe.
* @param contextID A String identifying the policy context whose
* PolicyConfiguration interface is to be returned. The value passed to
* this parameter must not be null.
* @param remove A boolean value that establishes whether or not the policy
* statements of an existing policy context are to be removed before its
* PolicyConfiguration object is returned. If the value passed to this
* parameter is true, the policy statements of an existing policy context
* will be removed. If the value is false, they will not be removed.
* @return an Object that implements the PolicyConfiguration Interface
* matched to the Policy provider and corresponding to the identified
* policy context.
* @throws PolicyContextException if the implementation throws a checked
* exception that has not been accounted for by the getPolicyConfiguration
* method signature. The exception thrown by the implementation class will
* be encapsulated (during construction) in the thrown PolicyContextException.
*/
public abstract javax.security.jacc.PolicyConfiguration getPolicyConfiguration(String contextID, boolean remove) throws PolicyContextException;
/**
* This method determines if the identified policy context exists with
* state "inService" in the Policy provider associated with the factory.
* @param contextID A string identifying a policy context
* @return true if the identified policy context exists within the provider
* and its state is "inService", false otherwise.
* @throws PolicyContextException if the implementation throws a checked
* exception that has not been accounted for by the inService method
* signature. The exception thrown by the implementation class will be
* encapsulated (during construction) in the thrown PolicyContextException.
*/
public abstract boolean inService(String contextID) throws PolicyContextException;
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/PolicyContext.java 0000644 0000000 0000000 00000006634 10517560657 026161 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.security.SecurityPermission;
import java.util.Hashtable;
import java.util.Set;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public final class PolicyContext {
private static ThreadLocal contextId = new ThreadLocal();
private static ThreadLocal handlerData = new ThreadLocal();
private static Hashtable handlers = new Hashtable();
private final static SecurityPermission SET_POLICY = new SecurityPermission("setPolicy");
private PolicyContext() {
}
public static void setContextID(String contextID) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(SET_POLICY);
contextId.set(contextID);
}
public static String getContextID() {
return (String) contextId.get();
}
public static void setHandlerData(Object data) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(SET_POLICY);
handlerData.set(data);
}
public static void registerHandler(String key, PolicyContextHandler handler, boolean replace) throws PolicyContextException {
if (key == null) throw new IllegalArgumentException("Key must not be null");
if (handler == null) throw new IllegalArgumentException("Handler must not be null");
if (!replace && handlers.containsKey(key)) throw new IllegalArgumentException("A handler has already been registered under '" + key + "' and replace is false.");
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(SET_POLICY);
handlers.put(key, handler);
}
public static Set getHandlerKeys() {
return handlers.keySet();
}
public static Object getContext(String key) throws PolicyContextException {
if (key == null) throw new IllegalArgumentException("Key must not be null");
PolicyContextHandler handler = (PolicyContextHandler) handlers.get(key);
if (handler == null) throw new IllegalArgumentException("No handler can be found for the key '" + key + "'");
if (!handler.supports(key)) throw new IllegalArgumentException("Registered handler no longer supports the key '" + key + "'");
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(SET_POLICY);
return handler.getContext(key, handlerData.get());
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/PolicyContextException.java 0000644 0000000 0000000 00000002756 10517560657 030041 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public class PolicyContextException extends Exception {
public PolicyContextException() {
super();
}
public PolicyContextException(String msg) {
super(msg);
}
public PolicyContextException(String msg, Throwable cause) {
super(msg, cause);
}
public PolicyContextException(Throwable cause) {
super(cause);
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/URLPatternSpec.java 0000644 0000000 0000000 00000023321 10554466622 026156 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.util.Iterator;
import java.util.LinkedList;
import javax.servlet.http.HttpServletRequest;
/**
* @version $Rev: 498156 $ $Date: 2007-01-20 20:29:22 +0100 (sam. 20 janv. 2007) $
*/
final class URLPatternSpec {
private final String pattern;
private final URLPattern first;
private final LinkedList qualifiers = new LinkedList();
public URLPatternSpec(String name) {
if (name == null) throw new java.lang.IllegalArgumentException("URLPatternSpec cannot be null");
if (name.length() == 0) name = "/";
pattern = name;
String[] tokens = pattern.split(":", -1);
first = new URLPattern(tokens[0]);
URLPattern candidate;
for (int i = 1; i < tokens.length; i++) {
candidate = new URLPattern(tokens[i]);
// No pattern may exist in the URLPatternList that matches the first pattern.
if (candidate.matches(first)) {
throw new java.lang.IllegalArgumentException("Qualifier patterns in the URLPatternSpec cannot match the first URLPattern");
}
if (first.type == URLPattern.PATH_PREFIX) {
// If the first pattern is a path-prefix pattern, only exact patterns
// matched by the first pattern and path-prefix patterns matched by,
// but different from, the first pattern may occur in the URLPatternList.
if (candidate.type == URLPattern.EXACT && !first.matches(candidate)) {
throw new java.lang.IllegalArgumentException("Exact qualifier patterns in the URLPatternSpec must be matched by the first URLPattern");
} else if (candidate.type == URLPattern.PATH_PREFIX
&& !(first.matches(candidate)
&& first.pattern.length() < candidate.pattern.length())) {
throw new java.lang.IllegalArgumentException("path-prefix qualifier patterns in the URLPatternSpec must be matched by, but different from, the first URLPattern");
} else if (candidate.type == URLPattern.EXTENSION) {
throw new java.lang.IllegalArgumentException("extension qualifier patterns in the URLPatternSpec are not allowed when the first URLPattern is path-prefix");
}
} else if (first.type == URLPattern.EXTENSION) {
// If the first pattern is an extension pattern, only exact patterns
// that are matched by the first pattern and path-prefix patterns may
// occur in the URLPatternList.
if (candidate.type == URLPattern.EXACT) {
if (!first.matches(candidate)) {
throw new java.lang.IllegalArgumentException("Exact qualifier patterns in the URLPatternSpec must be matched when first URLPattern is an extension pattern");
}
} else if (candidate.type != URLPattern.PATH_PREFIX) {
throw new java.lang.IllegalArgumentException("Only exact and path-prefix qualifiers in the URLPatternSpec are allowed when first URLPattern is an extension pattern");
}
} else if (first.type == URLPattern.DEFAULT) {
// If the first pattern is the default pattern, "/", any pattern
// except the default pattern may occur in the URLPatternList.
if (candidate.type == URLPattern.DEFAULT) {
//This is actually tested for by the "qualifier must not match first" rule
throw new java.lang.IllegalArgumentException("Qualifier patterns must not be default when first URLPattern is a default pattern");
}
} else if (first.type == URLPattern.EXACT) {
// If the first pattern is an exact pattern a URLPatternList
// must not be present in the URLPatternSpec
throw new java.lang.IllegalArgumentException("Qualifier patterns must not be present when first URLPattern is an exact pattern");
}
qualifiers.add(candidate);
}
}
public boolean equals(URLPatternSpec o) {
return implies(o) && o.implies(this);
}
public int hashCode() {
return pattern.hashCode();
}
public String getPatternSpec() {
return pattern;
}
public boolean implies(URLPatternSpec p) {
// The first URLPattern in the name of the argument permission is
// matched by the first URLPattern in the name of this permission.
if (!first.matches(p.first)) return false;
// The first URLPattern in the name of the argument permission is NOT
// matched by any URLPattern in the URLPatternList of the URLPatternSpec
// of this permission.
Iterator iter1 = qualifiers.iterator();
while (iter1.hasNext()) {
if (((URLPattern) iter1.next()).matches(p.first)) return false;
}
// If the first URLPattern in the name of the argument permission
// matches the first URLPattern in the URLPatternSpec of this
// permission, then every URLPattern in the URLPatternList of the
// URLPatternSpec of this permission is matched by a URLPattern in
// the URLPatternList of the argument permission.
if (p.first.matches(first)) {
Iterator iter2 = p.qualifiers.iterator();
while (iter2.hasNext()) {
Iterator iter3 = qualifiers.iterator();
URLPattern test = (URLPattern) iter2.next();
boolean found = false;
while (iter3.hasNext()) {
if (test.matches((URLPattern) iter3.next())) {
found = true;
break;
}
}
if (!found) return false;
}
}
return true;
}
static String encodeColons(HttpServletRequest request) {
String result = request.getServletPath() + (request.getPathInfo() == null ? "" : request.getPathInfo());
if (result.indexOf("%3A") > -1) result = result.replaceAll("%3A", "%3A%3A");
if (result.indexOf(":") > -1) result = result.replaceAll(":", "%3A");
return result;
}
private class URLPattern {
public final static int EXACT = 0x0;
public final static int PATH_PREFIX = 0x1;
public final static int EXTENSION = 0x2;
public final static int DEFAULT = 0x4;
public int type;
public String pattern;
public URLPattern(String pat) {
if (pat == null) throw new java.lang.IllegalArgumentException("URLPattern cannot be null");
if (pat.length() == 0) throw new java.lang.IllegalArgumentException("URLPattern cannot be empty");
if (pat.equals("/") || pat.equals("/*")) {
type = DEFAULT;
} else if (pat.charAt(0) == '/' && pat.endsWith("/*")) {
type = PATH_PREFIX;
} else if (pat.charAt(0) == '*') {
type = EXTENSION;
} else {
type = EXACT;
}
pattern = pat;
}
public boolean matches(URLPattern p) {
String test = p.pattern;
// their pattern values are String equivalent
if (pattern.equals(test)) return true;
switch (type) {
// this pattern is a path-prefix pattern (that is, it starts
// with "/" and ends with "/*") and the argument pattern
// starts with the substring of this pattern, minus its last
// 2 characters, and the next character of the argument pattern,
// if there is one, is "/"
case PATH_PREFIX: {
int length = pattern.length() - 2;
if (length > test.length()) return false;
for (int i = 0; i < length; i++) {
if (pattern.charAt(i) != test.charAt(i)) return false;
}
if (test.length() == length) return true;
else if (test.charAt(length) != '/') return false;
return true;
}
// this pattern is an extension pattern (that is, it starts
// with "*.") and the argument pattern ends with this pattern
case EXTENSION: {
return test.endsWith(pattern.substring(1));
}
// this pattern is the path-prefix pattern "/*" or
// the reference pattern is the special default pattern,
// "/", which matches all argument patterns
case DEFAULT: {
return true;
}
}
return false;
}
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/WebRoleRefPermission.java 0000644 0000000 0000000 00000004034 10517560657 027412 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.io.Serializable;
import java.security.Permission;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public final class WebRoleRefPermission extends Permission implements Serializable {
private transient int cachedHashCode = 0;
private String actions;
public WebRoleRefPermission(String name, String role) {
super(name);
actions = role;
}
public boolean equals(Object o) {
if (o == null || !(o instanceof WebRoleRefPermission)) return false;
WebRoleRefPermission other = (WebRoleRefPermission)o;
return getName().equals(other.getName()) && actions.equals(other.actions);
}
public String getActions() {
return actions;
}
public int hashCode() {
if (cachedHashCode == 0) {
cachedHashCode = getName().hashCode() ^ actions.hashCode();
}
return cachedHashCode;
}
public boolean implies(Permission permission) {
return equals(permission);
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/PolicyConfiguration.java 0000644 0000000 0000000 00000004617 10517560657 027343 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.security.Permission;
import java.security.PermissionCollection;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public interface PolicyConfiguration {
public String getContextID() throws PolicyContextException;
public void addToRole(String roleName, PermissionCollection permissions) throws PolicyContextException;
public void addToRole(String roleName, Permission permission) throws PolicyContextException;
public void addToUncheckedPolicy(PermissionCollection permissions) throws PolicyContextException;
public void addToUncheckedPolicy(Permission permission) throws PolicyContextException;
public void addToExcludedPolicy(PermissionCollection permissions) throws PolicyContextException;
public void addToExcludedPolicy(Permission permission) throws PolicyContextException;
public void removeRole(String roleName) throws PolicyContextException;
public void removeUncheckedPolicy() throws PolicyContextException;
public void removeExcludedPolicy() throws PolicyContextException;
public void linkConfiguration(PolicyConfiguration link) throws PolicyContextException;
public void delete() throws PolicyContextException;
public void commit() throws PolicyContextException;
public boolean inService() throws PolicyContextException;
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/WebResourcePermission.java 0000644 0000000 0000000 00000013241 10745577260 027644 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Hashtable;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
/**
* @version $Rev: 614454 $ $Date: 2008-01-23 09:45:36 +0100 (mer. 23 janv. 2008) $
*/
public final class WebResourcePermission extends Permission implements Serializable {
private transient int cachedHashCode = 0;
private transient URLPatternSpec urlPatternSpec;
private transient HTTPMethodSpec httpMethodSpec;
public WebResourcePermission(HttpServletRequest request) {
super(URLPatternSpec.encodeColons(request));
urlPatternSpec = new URLPatternSpec(getName());
httpMethodSpec = new HTTPMethodSpec(request.getMethod(), HTTPMethodSpec.NA);
}
public WebResourcePermission(String name, String actions) {
super(name);
urlPatternSpec = new URLPatternSpec(name);
httpMethodSpec = new HTTPMethodSpec(actions, false);
}
public WebResourcePermission(String urlPattern, String[] HTTPMethods) {
super(urlPattern);
urlPatternSpec = new URLPatternSpec(urlPattern);
httpMethodSpec = new HTTPMethodSpec(HTTPMethods);
}
public boolean equals(Object o) {
if (o == null || !(o instanceof WebResourcePermission)) return false;
WebResourcePermission other = (WebResourcePermission) o;
return urlPatternSpec.equals(other.urlPatternSpec) && httpMethodSpec.equals(other.httpMethodSpec);
}
public String getActions() {
return httpMethodSpec.getActions();
}
public int hashCode() {
if (cachedHashCode == 0) {
cachedHashCode = urlPatternSpec.hashCode() ^ httpMethodSpec.hashCode();
}
return cachedHashCode;
}
public boolean implies(Permission permission) {
if (permission == null || !(permission instanceof WebResourcePermission)) return false;
WebResourcePermission other = (WebResourcePermission) permission;
return urlPatternSpec.implies(other.urlPatternSpec) && httpMethodSpec.implies(other.httpMethodSpec);
}
public PermissionCollection newPermissionCollection() {
return new WebResourcePermissionCollection();
}
private synchronized void readObject(ObjectInputStream in) throws IOException {
urlPatternSpec = new URLPatternSpec(in.readUTF());
httpMethodSpec = new HTTPMethodSpec(in.readUTF(), false);
}
private synchronized void writeObject(ObjectOutputStream out) throws IOException {
out.writeUTF(urlPatternSpec.getPatternSpec());
out.writeUTF(httpMethodSpec.getActions());
}
private static final class WebResourcePermissionCollection extends PermissionCollection {
private Hashtable permissions = new Hashtable();
/**
* Adds a permission object to the current collection of permission objects.
*
* @param permission the Permission object to add.
*
* @exception SecurityException - if this PermissionCollection object
* has been marked readonly
*/
public void add(Permission permission) {
if (isReadOnly()) throw new IllegalArgumentException("Read only collection");
if (!(permission instanceof WebResourcePermission)) throw new IllegalArgumentException("Wrong permission type");
WebResourcePermission p = (WebResourcePermission)permission;
permissions.put(p, p);
}
/**
* Checks to see if the specified permission is implied by
* the collection of Permission objects held in this PermissionCollection.
*
* @param permission the Permission object to compare.
*
* @return true if "permission" is implied by the permissions in
* the collection, false if not.
*/
public boolean implies(Permission permission) {
if (!(permission instanceof WebResourcePermission)) return false;
WebResourcePermission p = (WebResourcePermission)permission;
Enumeration e = permissions.elements();
while (e.hasMoreElements()) {
if (((WebResourcePermission)e.nextElement()).implies(p)) return true;
}
return false;
}
/**
* Returns an enumeration of all the Permission objects in the collection.
*
* @return an enumeration of all the Permissions.
*/
public Enumeration elements() {
return permissions.elements();
}
}
}
geronimo-jacc-1.1-spec-1.0.1/src/main/java/javax/security/jacc/WebUserDataPermission.java 0000644 0000000 0000000 00000015742 10745577260 027575 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Hashtable;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
/**
* Class for Servlet Web user data permissions. A WebUserDataPermission is a
* named permission and has actions.
*
* The name of a WebUserDataPermission (also referred to as the target name)
* identifies a Web resource by its context path relative URL pattern.
*
* @version $Rev: 614454 $ $Date: 2008-01-23 09:45:36 +0100 (mer. 23 janv. 2008) $
*
* @see java.security.Permission
*/
public final class WebUserDataPermission extends Permission implements Serializable {
private transient int cachedHashCode = 0;
private transient URLPatternSpec urlPatternSpec;
private transient HTTPMethodSpec httpMethodSpec;
/**
* Creates a new WebUserDataPermission from the HttpServletRequest object.
*
* @param request the HttpServletRequest object corresponding to the
* Servlet operation to which the permission pertains. The permission
* name is the substring of the requestURI (HttpServletRequest.getRequestURI())
* that begins after the contextPath (HttpServletRequest.getContextPath()).
* When the substring operation yields the string �/�, the permission is
* constructed with the empty string as its name. The HTTP method component
* of the permission�s actions is as obtained from HttpServletRequest.getMethod().
* The TransportType component of the permission�s actions is determined
* by calling HttpServletRequest.isSecure().
*/
public WebUserDataPermission(HttpServletRequest request) {
super(URLPatternSpec.encodeColons(request));
urlPatternSpec = new URLPatternSpec(getName());
httpMethodSpec = new HTTPMethodSpec(request.getMethod(), request.isSecure()? HTTPMethodSpec.CONFIDENTIAL: HTTPMethodSpec.NONE);
}
public WebUserDataPermission(String name, String actions) {
super(name);
urlPatternSpec = new URLPatternSpec(name);
httpMethodSpec = new HTTPMethodSpec(actions, true);
}
public WebUserDataPermission(String urlPattern, String[] HTTPMethods, String transportType) {
super(urlPattern);
urlPatternSpec = new URLPatternSpec(urlPattern);
httpMethodSpec = new HTTPMethodSpec(HTTPMethods, transportType == null? "NONE": transportType);
}
public boolean equals(Object o) {
if (o == null || !(o instanceof WebUserDataPermission)) return false;
WebUserDataPermission other = (WebUserDataPermission) o;
return urlPatternSpec.equals(other.urlPatternSpec) && httpMethodSpec.equals(other.httpMethodSpec);
}
public String getActions() {
return httpMethodSpec.getActions();
}
public int hashCode() {
if (cachedHashCode == 0) {
cachedHashCode = urlPatternSpec.hashCode() ^ httpMethodSpec.hashCode();
}
return cachedHashCode;
}
public boolean implies(Permission permission) {
if (permission == null || !(permission instanceof WebUserDataPermission)) return false;
WebUserDataPermission other = (WebUserDataPermission) permission;
return urlPatternSpec.implies(other.urlPatternSpec) && httpMethodSpec.implies(other.httpMethodSpec);
}
public PermissionCollection newPermissionCollection() {
return new WebUserDataPermissionCollection();
}
private synchronized void readObject(ObjectInputStream in) throws IOException {
urlPatternSpec = new URLPatternSpec(in.readUTF());
httpMethodSpec = new HTTPMethodSpec(in.readUTF(), true);
}
private synchronized void writeObject(ObjectOutputStream out) throws IOException {
out.writeUTF(urlPatternSpec.getPatternSpec());
out.writeUTF(httpMethodSpec.getActions());
}
private static final class WebUserDataPermissionCollection extends PermissionCollection {
private Hashtable permissions = new Hashtable();
/**
* Adds a permission object to the current collection of permission objects.
*
* @param permission the Permission object to add.
*
* @exception SecurityException - if this PermissionCollection object
* has been marked readonly
*/
public void add(Permission permission) {
if (isReadOnly()) throw new IllegalArgumentException("Read only collection");
if (!(permission instanceof WebUserDataPermission)) throw new IllegalArgumentException("Wrong permission type");
WebUserDataPermission p = (WebUserDataPermission)permission;
permissions.put(p, p);
}
/**
* Checks to see if the specified permission is implied by
* the collection of Permission objects held in this PermissionCollection.
*
* @param permission the Permission object to compare.
*
* @return true if "permission" is implied by the permissions in
* the collection, false if not.
*/
public boolean implies(Permission permission) {
if (!(permission instanceof WebUserDataPermission)) return false;
WebUserDataPermission p = (WebUserDataPermission)permission;
Enumeration e = permissions.elements();
while (e.hasMoreElements()) {
if (((WebUserDataPermission)e.nextElement()).implies(p)) return true;
}
return false;
}
/**
* Returns an enumeration of all the Permission objects in the collection.
*
* @return an enumeration of all the Permissions.
*/
public Enumeration elements() {
return permissions.elements();
}
}
}
geronimo-jacc-1.1-spec-1.0.1/src/test/ 0000755 0000000 0000000 00000000000 11227105256 015720 5 ustar root root geronimo-jacc-1.1-spec-1.0.1/src/test/java/ 0000755 0000000 0000000 00000000000 11227105256 016641 5 ustar root root geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/ 0000755 0000000 0000000 00000000000 11227105256 017752 5 ustar root root geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/ 0000755 0000000 0000000 00000000000 11227105256 021621 5 ustar root root geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/ 0000755 0000000 0000000 00000000000 11227105256 022521 5 ustar root root ././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/EJBMethodPermissionCollectionTest.java geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/EJBMethodPermissionCollectionTest.jav0000644 0000000 0000000 00000042445 10517560657 031735 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import junit.framework.TestCase;
import java.security.PermissionCollection;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public class EJBMethodPermissionCollectionTest extends TestCase {
public void testWildCards() {
PermissionCollection collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", ""));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", "")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", ",,a,b,c"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", ",,a,b,c")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", ",,"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", ",,")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", ",Local"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", ",Local")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", ",Local,a,b,c"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", ",Local,a,b,c")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", ",Local,"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", ",Local,")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", "hello"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", "hello")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", "hello,,a,b,c"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", "hello,,a,b,c")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", "hello,,"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", "hello,,")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", "hello,Local"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", "hello,Local")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", "hello,Local,a,b,c")));
collection = new EJBMethodPermission("HelloWorld", "").newPermissionCollection();
collection.add(new EJBMethodPermission("HelloWorld", "hello,Local,"));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", ",Local,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,a,b,c")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,,")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local")));
assertFalse(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,a,b,c")));
assertTrue(collection.implies(new EJBMethodPermission("HelloWorld", "hello,Local,")));
assertFalse(collection.implies(new EJBMethodPermission("GoodbyeWorld", "hello,Local,")));
}
}
geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/WebResourcePermissionTest.java 0000644 0000000 0000000 00000037363 10745577260 030552 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.security.Permission;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import javax.servlet.http.HttpServletRequest;
import junit.framework.TestCase;
/**
* @version $Rev: 614454 $ $Date: 2008-01-23 09:45:36 +0100 (mer. 23 janv. 2008) $
*/
public class WebResourcePermissionTest extends TestCase {
public void testSerialization() throws Exception {
WebResourcePermission permission = new WebResourcePermission("/bar/*:/bar/stool", "GET,POST");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(permission);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Object o = ois.readObject();
assertEquals(permission, o);
}
/*
* Testing WebResourcePermission(java.lang.String, java.lang.String)
*/
public void testConstructorStringString() {
// null URLPatternSpec for a WebResourcePermission
try {
new WebResourcePermission(null, "GET,POST");
fail("null URLPatternSpec for a WebResourcePermission");
} catch (IllegalArgumentException iae) {
}
//Default pattern
checkPermission(new WebResourcePermission("/", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("/:/foo", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("/:*.asp", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("/:/foo:*.asp", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("/*", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("/*:/bar/stool", "GET,POST"), "GET,POST");
//default pattern as qualifier
try {
new WebResourcePermission("/bar/*:/*", "GET,POST");
fail("/*:/");
} catch (IllegalArgumentException iae) {
}
try {
new WebResourcePermission("/bar/*:/*", "GET,POST");
fail("/*:/*");
} catch (IllegalArgumentException iae) {
}
try {
new WebResourcePermission("/bar/*:/*", "GET,POST");
fail("/:/");
} catch (IllegalArgumentException iae) {
}
try {
new WebResourcePermission("/bar/*:/*", "GET,POST");
fail("/:/*");
} catch (IllegalArgumentException iae) {
}
//Exact pattern
checkPermission(new WebResourcePermission("/foo", "GET,POST"), "GET,POST");
// missing qualifiers
try {
new WebResourcePermission("/foo:", "GET,POST");
fail("/foo:");
} catch (IllegalArgumentException iae) {
}
// qualifer provided when first pattern is exact
try {
new WebResourcePermission("/foo:/foo/bar", "GET,POST");
fail("/foo:/foo/bar");
} catch (IllegalArgumentException iae) {
}
//default pattern as a qualifier
try {
new WebResourcePermission("/foo:/", "GET,POST");
fail("/foo:/");
} catch (IllegalArgumentException iae) {
}
//Path prefix pattern
checkPermission(new WebResourcePermission("/bar/*", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("/bar/*:/bar/stool", "GET,POST"), "GET,POST");
try {
new WebResourcePermission("/foo/*:*.asp", "GET,POST");
fail("/foo/*:*.asp");
} catch (IllegalArgumentException iae) {
}
//first pattern doesn't match qualifier
try {
new WebResourcePermission("/bar/*:/cat/stool/*", "GET,POST");
fail("/bar/*:/cat/stool/*");
} catch (IllegalArgumentException iae) {
}
try {
new WebResourcePermission("/bar/stool/*:/bar", "GET,POST");
fail("/bar/stool/*:/bar");
} catch (IllegalArgumentException iae) {
}
try {
new WebResourcePermission("/bar/stool/*:/bar/*", "GET,POST");
fail("/bar/stool/*:/bar/stool/*");
} catch (IllegalArgumentException iae) {
}
//qualifier is same as first pattern
try {
new WebResourcePermission("/bar/stool/*:/bar/stool/*", "GET,POST");
fail("/bar/stool/*:/bar/stool/*");
} catch (IllegalArgumentException iae) {
}
//default pattern as qualifier
try {
new WebResourcePermission("/bar/*:/*", "GET,POST");
fail("/bar/*:/");
} catch (IllegalArgumentException iae) {
}
//Extension pattern
checkPermission(new WebResourcePermission("*.do", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("*.do:/login.do", "GET,POST"), "GET,POST");
checkPermission(new WebResourcePermission("*.do:/foo/*", "GET,POST"), "GET,POST");
//default pattern as qualifier
try {
new WebResourcePermission("*.do:/*", "GET,POST");
fail("*.do:/*");
} catch (IllegalArgumentException iae) {
}
//qualifier is extension pattern
try {
new WebResourcePermission("*.do:*.jsp", "GET,POST");
fail("*.do:/*");
} catch (IllegalArgumentException iae) {
}
//qualifier is exact and does not match first pattern
try {
new WebResourcePermission("*.do:/login", "GET,POST");
fail("*.do:/*");
} catch (IllegalArgumentException iae) {
}
//HTTP method
checkPermission(new WebResourcePermission("/foo", "GET,POST,POST,GET"), "GET,POST");
checkPermission(new WebResourcePermission("/foo", "GET,POST,BAR"), "GET,POST,BAR");
try {
new WebResourcePermission("/foo", "GET,POST,B A R");
fail("Bad HTTP method");
} catch (IllegalArgumentException iae) {
}
// bad HTTP method for a WebResourcePermission
try {
new WebResourcePermission("/foo", "GET,POST:INTEGRAL");
fail("integrity constraint in a WebResourcePermission accepted");
} catch (IllegalArgumentException iae) {
}
}
private void checkPermission(Permission permission, String actions) {
assertTrue(permission.equals(permission));
assertEquals(actions, permission.getActions());
}
public void testExcluded() {
WebResourcePermission permission = new WebResourcePermission("/foo", "!GET,POST");
assertTrue(permission.equals(permission));
assertEquals(permission.getName(), "/foo");
assertEquals(permission.getActions(), "!GET,POST");
permission = new WebResourcePermission("/foo", "!GET,POST,POST,GET");
assertEquals(permission.getActions(), "!GET,POST");
permission = new WebResourcePermission("/foo", "!GET,POST,BAR");
// bad HTTP method
try {
permission = new WebResourcePermission("/foo", "!GET,POST,B A R");
fail("Bad HTTP method");
} catch (IllegalArgumentException iae) {
}
// bad HTTP method for a WebResourcePermission
try {
permission = new WebResourcePermission("/foo", "!GET,POST:INTEGRAL");
} catch (IllegalArgumentException iae) {
}
// null URLPatternSpec for a WebResourcePermission
try {
permission = new WebResourcePermission(null, "!GET,POST");
fail("null URLPatternSpec for a WebResourcePermission");
} catch (IllegalArgumentException iae) {
}
}
public void testImpliesStringString() {
// The argument is an instanceof WebResourcePermission
Permission pA = new WebResourcePermission("/foo", "");
Permission pB = new WebUserDataPermission("/foo", "");
assertFalse(pA.implies(pB));
assertFalse(pB.implies(pA));
pA = new WebResourcePermission("/foo", "");
pB = new WebResourcePermission("/foo", "GET,POST");
assertTrue(pA.implies(pB));
assertFalse(pB.implies(pA));
pA = new WebResourcePermission("/foo/*:/foo/bar", "");
pB = new WebResourcePermission("/foo/bar", "");
assertFalse(pA.implies(pB));
assertFalse(pB.implies(pA));
pA = new WebResourcePermission("/foo/bar/*:/foo/bar/cat/dog", "");
pB = new WebResourcePermission("/foo/bar/*:/foo/bar/cat/*", "");
assertTrue(pA.implies(pB));
assertFalse(pB.implies(pA));
pA = new WebResourcePermission("/:/a.jsp:/b.jsp:/c.jsp", "GET,POST,PUT,DELETE,HEAD,OPTIONS,TRACE");
pB = new WebResourcePermission("/:/a.jsp:/c.jsp:/b.jsp", (String) null);
// assertTrue(pA.implies(pB)); // no longer true with extension methods
assertTrue(pB.implies(pA));
}
public void testImpliesExtensionExcludes() {
//test against all permissions
WebResourcePermission pA = new WebResourcePermission("/foo", "FOO,BAR,fizzle");
WebResourcePermission pB = new WebResourcePermission("/foo", (String) null);
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
assertTrue(pA.implies(pA));
assertTrue(pB.implies(pB));
pA = new WebResourcePermission("/foo", "!FOO,BAR,fizzle");
pB = new WebResourcePermission("/foo", (String) null);
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
assertTrue(pA.implies(pA));
pA = new WebResourcePermission("/foo", "GET,POST");
pB = new WebResourcePermission("/foo", (String) null);
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "!GET,POST");
pB = new WebResourcePermission("/foo", (String) null);
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
//both positive sets
pA = new WebResourcePermission("/foo", "GET,POST");
pB = new WebResourcePermission("/foo", "GET,POST,OPTIONS");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "GET,POST");
pB = new WebResourcePermission("/foo", "GET,POST,FOO");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "GET,FOO");
pB = new WebResourcePermission("/foo", "GET,BAR,FOO");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "FOO,BAR");
pB = new WebResourcePermission("/foo", "FOO,BAR,fizzle");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
//both exclusions
pA = new WebResourcePermission("/foo", "!FOO,BAR,fizzle");
pB = new WebResourcePermission("/foo", "!FOO,BAR");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "!GET,POST,FOO");
pB = new WebResourcePermission("/foo", "!GET,POST");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "!GET,BAR,FOO");
pB = new WebResourcePermission("/foo", "!GET,BAR");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "!GET,POST,OPTIONS");
pB = new WebResourcePermission("/foo", "!GET,POST");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
//one of each
pA = new WebResourcePermission("/foo", "GET");
pB = new WebResourcePermission("/foo", "!FOO,BAR");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "fizzle");
pB = new WebResourcePermission("/foo", "!FOO,BAR");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "GET");
pB = new WebResourcePermission("/foo", "!POST");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
pA = new WebResourcePermission("/foo", "GET");
pB = new WebResourcePermission("/foo", "!POST,BAR");
assertFalse(pA.implies(pB));
assertTrue(pB.implies(pA));
}
/*
* Testing WebResourcePermission(String, String[])
*/
public void testConstructorStringStringArray() {
}
public void testImpliesStringStringArray() {
}
/*
* Testing WebResourcePermission(HttpServletRequest)
*/
public void testConstructorHttpServletRequest() {
Permission p = new WebResourcePermission(new MockHttpServletRequest("/foo", "", "GET"));
checkPermission(p, "/foo", "GET");
p = new WebResourcePermission(new MockHttpServletRequest("", "/foo", "GET"));
checkPermission(p, "/foo", "GET");
p = new WebResourcePermission(new MockHttpServletRequest("/foo", "/foo", "BAR"));
checkPermission(p, "/foo/foo", "BAR");
p = new WebResourcePermission(new MockHttpServletRequest("/foo", "/foo:bar", "BAR"));
checkPermission(p, "/foo/foo%3Abar", "BAR");
p = new WebResourcePermission(new MockHttpServletRequest("/foo", "/foo%3Abar", "BAR"));
checkPermission(p, "/foo/foo%3A%3Abar", "BAR");
}
private void checkPermission(Permission p, String name, String actions) {
assertEquals(p.getName(), name);
assertEquals(p.getActions(), actions);
}
public void testImpliesHttpServletRequest() {
}
public void testGetActions() {
WebResourcePermission p = new WebResourcePermission("/foo", "");
assertEquals(p.getActions(), "");
p = new WebResourcePermission("/foo", "!GET,POST");
assertEquals(p.getActions(), "!GET,POST");
p = new WebResourcePermission("/foo", "!POST,GET");
assertEquals(p.getActions(), "!GET,POST");
p = new WebResourcePermission("/foo", "!POST,GET,GET,POST");
assertEquals(p.getActions(), "!GET,POST");
//extension methods follow regular methods
p = new WebResourcePermission("/foo", "FOO,BAR,POST,FOO,GET,GET,POST");
assertEquals("GET,POST,BAR,FOO", p.getActions());
p = new WebResourcePermission("/foo", "!FOO,BAR,POST,FOO,GET,GET,POST");
assertEquals("!GET,POST,BAR,FOO", p.getActions());
}
public static void main(String[] args) {
WebResourcePermissionTest test = new WebResourcePermissionTest();
test.testConstructorStringString();
test.testImpliesStringString();
test.testConstructorStringStringArray();
test.testImpliesStringStringArray();
test.testConstructorHttpServletRequest();
test.testImpliesHttpServletRequest();
}
}
geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/EJBRoleRefPermissionTest.java 0000644 0000000 0000000 00000004364 10517560657 030176 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import junit.framework.TestCase;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public class EJBRoleRefPermissionTest extends TestCase {
public void testConstructor() {
EJBRoleRefPermission permission1 = new EJBRoleRefPermission("foo", "bar");
EJBRoleRefPermission permission2 = new EJBRoleRefPermission("foo", "bar");
EJBRoleRefPermission permission3 = new EJBRoleRefPermission("foo", "cat");
assertTrue(permission1.implies(permission1));
assertTrue(permission1.implies(permission2));
assertTrue(permission2.implies(permission1));
assertTrue(permission1.equals(permission1));
assertTrue(permission1.equals(permission2));
assertTrue(permission2.equals(permission1));
assertFalse(permission1.implies(permission3));
assertFalse(permission3.implies(permission1));
assertFalse(permission1.equals(permission3));
assertFalse(permission3.equals(permission1));
assertEquals(permission1.getName(), "foo");
assertEquals(permission1.getActions(), "bar");
assertEquals(permission1.hashCode(), permission2.hashCode());
}
public void testImplies() {
}
}
geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/MockHttpServletRequest.java 0000644 0000000 0000000 00000013144 10745577260 030052 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.security.jacc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* @version $Rev: 614454 $ $Date: 2008-01-23 09:45:36 +0100 (mer. 23 janv. 2008) $
*/
public class MockHttpServletRequest implements HttpServletRequest {
private final String servletPath;
private final String pathInfo;
private final String method;
public MockHttpServletRequest(String servletPath, String pathInfo) {
this.servletPath = servletPath;
this.pathInfo = pathInfo;
this.method = "GET";
}
public MockHttpServletRequest(String servletPath, String pathInfo, String method) {
this.servletPath = servletPath;
this.pathInfo = pathInfo;
this.method = method;
}
public String getAuthType() {
return null;
}
public Cookie[] getCookies() {
return new Cookie[0];
}
public long getDateHeader(String transOID) {
return 0;
}
public String getHeader(String transOID) {
return null;
}
public Enumeration getHeaders(String transOID) {
return null;
}
public Enumeration getHeaderNames() {
return null;
}
public int getIntHeader(String transOID) {
return 0;
}
public String getMethod() {
return method;
}
public String getPathInfo() {
return pathInfo;
}
public String getPathTranslated() {
return null;
}
public String getContextPath() {
return null;
}
public String getQueryString() {
return null;
}
public String getRemoteUser() {
return null;
}
public boolean isUserInRole(String transOID) {
return false;
}
public Principal getUserPrincipal() {
return null;
}
public String getRequestedSessionId() {
return null;
}
public String getRequestURI() {
return null;
}
public StringBuffer getRequestURL() {
return null;
}
public String getServletPath() {
return servletPath;
}
public HttpSession getSession(boolean b) {
return null;
}
public HttpSession getSession() {
return null;
}
public boolean isRequestedSessionIdValid() {
return false;
}
public boolean isRequestedSessionIdFromCookie() {
return false;
}
public boolean isRequestedSessionIdFromURL() {
return false;
}
public boolean isRequestedSessionIdFromUrl() {
return false;
}
public Object getAttribute(String transOID) {
return null;
}
public Enumeration getAttributeNames() {
return null;
}
public String getCharacterEncoding() {
return null;
}
public void setCharacterEncoding(String transOID) throws UnsupportedEncodingException {
}
public int getContentLength() {
return 0;
}
public String getContentType() {
return null;
}
public ServletInputStream getInputStream() throws IOException {
return null;
}
public String getParameter(String transOID) {
return null;
}
public Enumeration getParameterNames() {
return null;
}
public String[] getParameterValues(String transOID) {
return new String[0];
}
public Map getParameterMap() {
return null;
}
public String getProtocol() {
return null;
}
public String getScheme() {
return null;
}
public String getServerName() {
return null;
}
public int getServerPort() {
return 0;
}
public BufferedReader getReader() throws IOException {
return null;
}
public String getRemoteAddr() {
return null;
}
public String getRemoteHost() {
return null;
}
public void setAttribute(String transOID, Object object) {
}
public void removeAttribute(String transOID) {
}
public Locale getLocale() {
return null;
}
public Enumeration getLocales() {
return null;
}
public boolean isSecure() {
return false;
}
public RequestDispatcher getRequestDispatcher(String transOID) {
return null;
}
public String getRealPath(String transOID) {
return null;
}
public int getRemotePort() {
return 0;
}
public String getLocalName() {
return null;
}
public String getLocalAddr() {
return null;
}
public int getLocalPort() {
return 0;
}
}
geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/WebUserDataPermissionTest.java 0000644 0000000 0000000 00000014442 10745577260 030464 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.Permission;
import junit.framework.TestCase;
/**
* @version $Rev: 614454 $ $Date: 2008-01-23 09:45:36 +0100 (mer. 23 janv. 2008) $
*/
public class WebUserDataPermissionTest extends TestCase {
/*
* Testing WebResourcePermission(java.lang.String, java.lang.String)
*/
public void testConstructorStringString() {
MockHttpServletRequest request = new MockHttpServletRequest("/portal", "/services/services_jdbc/_rp_services_jdbc_row1_col1_p1_adapterDisplayName/1_TranQL0x8Generic0x8JDBC0x8Resource0x8Adapter/_rp_services_jdbc_row1_col1_p1_rarPath/1_tranql0x3tranql-connector0x310x220x3rar/_rp_services_jdbc_row1_col1_p1_mode/1_params/_rp_services_jdbc_row1_col1_p1_driverClass/1_org0x2hsqldb0x2jdbcDriver/_pm_services_jdbc_row1_col1_p1/view/_rp_services_jdbc_row1_col1_p1_dbtype/1_HSQLDB0x8embedded/_rp_services_jdbc_row1_col1_p1_urlPrototype/1_jdbc:hsqldb:{Database}/_st_services_jdbc_row1_col1_p1/normal/_ps_services_jdbc_row1_col1_p1/normal/_pid/services_jdbc_row1_col1_p1/_md_services_jdbc_row1_col1_p1/view/_rp_services_jdbc_row1_col1_p1_name/1_FFFFF");
new WebUserDataPermission(URLPatternSpec.encodeColons(request), "GET:NONE");
WebUserDataPermission permission = new WebUserDataPermission("/foo", "GET,POST:INTEGRAL");
assertEquals(permission.getName(), "/foo");
assertEquals(permission.getActions(), "GET,POST:INTEGRAL");
permission = new WebUserDataPermission("/foo", "GET,POST,POST,GET:INTEGRAL");
assertEquals(permission.getActions(), "GET,POST:INTEGRAL");
//extension method
permission = new WebUserDataPermission("/foo", "GET,POST,BAR:INTEGRAL");
// bad HTTP method
try {
permission = new WebUserDataPermission("/foo", "GET,POST,B A R:INTEGRAL");
fail("Bad HTTP method");
} catch (IllegalArgumentException iae) {
}
// If you have a colon, then you must have a transportType
try {
permission = new WebUserDataPermission("/foo", "GET,POST,BAR:");
fail("Missing transportType");
} catch (IllegalArgumentException iae) {
}
}
public void testSerialization() throws Exception {
testSerialization(new WebUserDataPermission("/foo", "GET,POST:INTEGRAL"));
testSerialization(new WebUserDataPermission("/foo", "GET,POST:NONE"));
testSerialization(new WebUserDataPermission("/foo", ""));
testSerialization(new WebUserDataPermission("/foo", ":NONE"));
testSerialization(new WebUserDataPermission("/foo", "GET,POST"));
}
private void testSerialization(WebUserDataPermission permission) throws IOException, ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(permission);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Object o = ois.readObject();
assertEquals(permission, o);
}
public void testImpliesStringString() {
// An actions string without a transportType is a shorthand for a
// actions string with the value "NONE" as its TransportType
WebUserDataPermission permissionFooGP = new WebUserDataPermission("/foo", "GET,POST:INTEGRAL");
WebUserDataPermission permissionFooE = new WebUserDataPermission("/foo", "");
WebUserDataPermission permissionFooGPN = new WebUserDataPermission("/foo", "GET,POST");
assertTrue(permissionFooE.implies(permissionFooGP));
assertTrue(permissionFooE.implies(permissionFooGPN));
assertFalse(permissionFooGP.implies(permissionFooE));
assertFalse(permissionFooGPN.implies(permissionFooE));
assertTrue(permissionFooGPN.implies(permissionFooGP));
assertFalse(permissionFooGP.implies(permissionFooGPN));
}
/*
* Testing WebResourcePermission(String, String[])
*/
public void testConstructorStringStringArray() {
}
public void testImpliesStringStringArray() {
}
/*
* Testing WebResourcePermission(HttpServletRequest)
*/
public void testConstructorHttpServletRequest() {
Permission p = new WebUserDataPermission(new MockHttpServletRequest("/foo", "", "GET"));
checkPermission(p, "/foo", "GET");
p = new WebUserDataPermission(new MockHttpServletRequest("", "/foo", "GET"));
checkPermission(p, "/foo", "GET");
p = new WebUserDataPermission(new MockHttpServletRequest("/foo", "/foo", "BAR"));
checkPermission(p, "/foo/foo", "BAR");
p = new WebUserDataPermission(new MockHttpServletRequest("/foo", "/foo:bar", "BAR"));
checkPermission(p, "/foo/foo%3Abar", "BAR");
p = new WebUserDataPermission(new MockHttpServletRequest("/foo", "/foo%3Abar", "BAR"));
checkPermission(p, "/foo/foo%3A%3Abar", "BAR");
}
private void checkPermission(Permission p, String name, String actions) {
assertEquals(p.getName(), name);
assertEquals(p.getActions(), actions);
}
public void testImpliesHttpServletRequest() {
}
}
geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/EJBMethodPermissionTest.java 0000644 0000000 0000000 00000036500 10517560657 030055 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import junit.framework.TestCase;
import java.lang.reflect.Method;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public class EJBMethodPermissionTest extends TestCase {
protected Method method;
public void setUp() {
try {
method = TestClass.class.getDeclaredMethod("cat", new Class[] { Integer.class, Float.class, Long.class, Double.class });
} catch (NoSuchMethodException e) {
e.printStackTrace(); //To change body of catch statement use Options | File Templates.
} catch (SecurityException e) {
e.printStackTrace(); //To change body of catch statement use Options | File Templates.
}
}
/*
* Testing EJBMethodPermission(java.lang.String, java.lang.String)
*/
public void testConstructorStringString() throws Exception {
// methodSpec ::= null
EJBMethodPermission permission = new EJBMethodPermission("foo", null);
doTestSerialization(permission);
// methodSpec ::= methodNameSpec
permission = new EJBMethodPermission("foo", "");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat");
doTestSerialization(permission);
// methodSpec ::= methodNameSpec comma methodInterface
permission = new EJBMethodPermission("foo", ",ServiceEndpoint");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,ServiceEndpoint");
doTestSerialization(permission);
// methodSpec ::= methodNameSpec comma methodInterfaceSpec comma methodParamsSpec
permission = new EJBMethodPermission("foo", ",,");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,,");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", ",Home,");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,Home,");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", ",,a,b,c,d");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,,a,b,c,d");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", ",Home,a,b,c,d");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d");
doTestSerialization(permission);
// methodInterface ::= "Home" | "LocalHome" | "Remote" | "Local" | "ServiceEndpoint"
permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,Remote,a,b,c,d");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,Local,a,b,c,d");
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat,ServiceEndpoint,a,b,c,d");
doTestSerialization(permission);
assertEquals(permission.getName(), "foo");
assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d");
// bad methodInterface
try {
permission = new EJBMethodPermission("foo", "cat,Interface,a,b,c,d");
fail("Bad method interface");
} catch(IllegalArgumentException iae) {
}
// no production produces "emptyString,emptyString"
try {
permission = new EJBMethodPermission("foo", ",");
fail("Empty method interface");
} catch(IllegalArgumentException iae) {
}
// no production produces "methodName ,emptyString"
try {
permission = new EJBMethodPermission("foo", "cat,");
fail("Empty method interface");
} catch(IllegalArgumentException iae) {
}
// no production produces an empty method parameter
try {
permission = new EJBMethodPermission("foo", ",,,");
fail("Empty method parameter");
} catch(IllegalArgumentException iae) {
}
// no production produces an empty method parameter
try {
permission = new EJBMethodPermission("foo", ",,,,,,");
fail("Empty method parameter");
} catch(IllegalArgumentException iae) {
}
}
public void testImpliesStringString() throws Exception {
EJBMethodPermission permissionFooEEE = new EJBMethodPermission("foo", "");
EJBMethodPermission permissionFooMIP = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d");
EJBMethodPermission permissionBarEEE = new EJBMethodPermission("bar", "");
EJBMethodPermission permissionFooEIP = new EJBMethodPermission("foo", ",LocalHome,a,b,c,d");
EJBMethodPermission permissionFooEIE = new EJBMethodPermission("foo", ",LocalHome,");
EJBMethodPermission permissionFooEI = new EJBMethodPermission("foo", ",LocalHome");
assertTrue(permissionFooEEE.implies(permissionFooEEE));
assertTrue(permissionFooEEE.implies(permissionFooMIP));
assertTrue(permissionFooEEE.implies(permissionFooEIP));
assertTrue(permissionFooEEE.implies(permissionFooEIE));
assertTrue(permissionFooEEE.implies(permissionFooEI));
assertFalse(permissionFooMIP.implies(permissionFooEEE));
assertTrue(permissionFooEEE.equals(permissionFooEEE));
assertFalse(permissionFooEEE.equals(permissionFooMIP));
assertFalse(permissionFooMIP.equals(permissionFooEEE));
assertFalse(permissionFooEEE.implies(permissionBarEEE));
assertFalse(permissionBarEEE.implies(permissionFooEEE));
assertFalse(permissionFooEEE.equals(permissionBarEEE));
assertFalse(permissionBarEEE.equals(permissionFooEEE));
assertTrue(permissionFooEIP.implies(permissionFooMIP));
assertFalse(permissionFooEIE.implies(permissionFooMIP));
assertTrue(permissionFooEI.implies(permissionFooMIP));
assertTrue(permissionFooEI.implies(permissionFooEIP));
assertTrue(permissionFooEI.implies(permissionFooEIE));
assertFalse(permissionFooEEE.hashCode() == permissionBarEEE.hashCode());
doTestSerialization(permissionFooEEE);
doTestSerialization(permissionFooMIP);
doTestSerialization(permissionBarEEE);
doTestSerialization(permissionFooEIP);
doTestSerialization(permissionFooEIE);
doTestSerialization(permissionFooEI);
}
/*
* Testing EJBMethodPermission(String, String, String, String[])
*/
public void testConstructorStringStringStringStringArray() throws Exception {
// methodSpec ::= null
EJBMethodPermission permission = new EJBMethodPermission("foo", null, null, null);
doTestSerialization(permission);
// methodSpec ::= methodNameSpec
permission = new EJBMethodPermission("foo", "", "", null);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "", null);
doTestSerialization(permission);
// methodSpec ::= methodNameSpec comma methodInterface
permission = new EJBMethodPermission("foo", "", "ServiceEndpoint", null);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "ServiceEndpoint", null);
doTestSerialization(permission);
// methodSpec ::= methodNameSpec comma methodInterfaceSpec comma methodParamsSpec
permission = new EJBMethodPermission("foo", "", "", new String[]{});
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "", new String[]{});
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "", "Home", new String[]{});
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "Home", new String[] {});
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "", "", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "", "Home", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
// methodInterface ::= "Home" | "LocalHome" | "Remote" | "Local" | "ServiceEndpoint"
permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "LocalHome", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "Remote", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "Local", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "cat", "ServiceEndpoint", new String[] { "a", "b", "c", "d" });
doTestSerialization(permission);
assertEquals(permission.getName(), "foo");
assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d");
// bad methodInterface
try {
permission = new EJBMethodPermission("foo", "cat", "Interface", new String[] { "a", "b", "c", "d" });
fail("Bad method interface");
} catch(IllegalArgumentException iae) {
}
}
public void testImpliesStringStringStringStringArray() throws Exception {
EJBMethodPermission permissionFooEEE = new EJBMethodPermission("foo", "", "", null);
EJBMethodPermission permissionFooMIP = new EJBMethodPermission("foo", "cat", "LocalHome", new String[] { "a", "b", "c", "d" });
EJBMethodPermission permissionBarEEE = new EJBMethodPermission("bar", "", "", new String[] {});
EJBMethodPermission permissionFooEIP = new EJBMethodPermission("foo", "", "LocalHome", new String[] { "a", "b", "c", "d" });
EJBMethodPermission permissionFooEIE = new EJBMethodPermission("foo", "", "LocalHome", new String[] {});
EJBMethodPermission permissionFooEI = new EJBMethodPermission("foo", "", "LocalHome", null);
assertTrue(permissionFooEEE.implies(permissionFooEEE));
assertTrue(permissionFooEEE.implies(permissionFooMIP));
assertTrue(permissionFooEEE.implies(permissionFooEIP));
assertTrue(permissionFooEEE.implies(permissionFooEIE));
assertTrue(permissionFooEEE.implies(permissionFooEI));
assertFalse(permissionFooMIP.implies(permissionFooEEE));
assertTrue(permissionFooEEE.equals(permissionFooEEE));
assertFalse(permissionFooEEE.equals(permissionFooMIP));
assertFalse(permissionFooMIP.equals(permissionFooEEE));
assertFalse(permissionFooEEE.implies(permissionBarEEE));
assertFalse(permissionBarEEE.implies(permissionFooEEE));
assertFalse(permissionFooEEE.equals(permissionBarEEE));
assertFalse(permissionBarEEE.equals(permissionFooEEE));
assertTrue(permissionFooEIP.implies(permissionFooMIP));
assertFalse(permissionFooEIE.implies(permissionFooMIP));
assertTrue(permissionFooEI.implies(permissionFooMIP));
assertTrue(permissionFooEI.implies(permissionFooEIP));
assertTrue(permissionFooEI.implies(permissionFooEIE));
assertFalse(permissionFooEEE.hashCode() == permissionBarEEE.hashCode());
doTestSerialization(permissionFooEEE);
doTestSerialization(permissionFooMIP);
doTestSerialization(permissionBarEEE);
doTestSerialization(permissionFooEIP);
doTestSerialization(permissionFooEIE);
doTestSerialization(permissionFooEI);
}
/*
* Testing EJBMethodPermission(String, String, Method)
*/
public void testConstructorStringStringMethod() throws Exception {
EJBMethodPermission permission = new EJBMethodPermission("foo", "ServiceEndpoint", method);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", null, method);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "", method);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "Home", method);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "LocalHome", method);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "Remote", method);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "Local", method);
doTestSerialization(permission);
permission = new EJBMethodPermission("foo", "ServiceEndpoint", method);
doTestSerialization(permission);
assertEquals(permission.getName(), "foo");
assertEquals(permission.getActions(), "cat,ServiceEndpoint,java.lang.Integer,java.lang.Float,java.lang.Long,java.lang.Double");
// Parameter method must not be null
try {
permission = new EJBMethodPermission("foo", "ServiceEndpoint", null);
fail("Parameter method must not be null");
} catch(IllegalArgumentException iae) {
}
}
public void testImpliesStringStringMethod() {
}
private void doTestSerialization(EJBMethodPermission permission) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(permission);
oos.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Object o = ois.readObject();
assertEquals("Permission did not serialize correctly", permission, o);
}
class TestClass {
public Object cat(Integer a, Float b, Long c, Double d) {
return null;
}
}
}
geronimo-jacc-1.1-spec-1.0.1/src/test/java/javax/security/jacc/WebRoleRefPermissionTest.java 0000644 0000000 0000000 00000004303 10517560657 030304 0 ustar root root /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.security.jacc;
import junit.framework.TestCase;
/**
* @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (mer. 25 oct. 2006) $
*/
public class WebRoleRefPermissionTest extends TestCase {
public void test() {
WebRoleRefPermission permission1 = new WebRoleRefPermission("foo", "bar");
WebRoleRefPermission permission2 = new WebRoleRefPermission("foo", "bar");
WebRoleRefPermission permission3 = new WebRoleRefPermission("foo", "cat");
assertTrue(permission1.implies(permission1));
assertTrue(permission1.implies(permission2));
assertTrue(permission2.implies(permission1));
assertTrue(permission1.equals(permission1));
assertTrue(permission1.equals(permission2));
assertTrue(permission2.equals(permission1));
assertFalse(permission1.implies(permission3));
assertFalse(permission3.implies(permission1));
assertFalse(permission1.equals(permission3));
assertFalse(permission3.equals(permission1));
assertEquals(permission1.getName(), "foo");
assertEquals(permission1.getActions(), "bar");
assertEquals(permission1.hashCode(), permission2.hashCode());
}
}
geronimo-jacc-1.1-spec-1.0.1/pom.xml 0000644 0000000 0000000 00000004470 10750572526 015504 0 ustar root root
4.0.0
org.apache.geronimo.specs
specs
1.4
geronimo-jacc_1.1_spec
jar
J2EE JACC 1.1
1.0.1
javax.security.jacc*
1.1
org.apache.geronimo.specs
geronimo-servlet_2.5_spec
1.1.2
provided
scm:svn:https://svn.apache.org/repos/asf/geronimo/specs/tags/geronimo-jacc_1.1_spec-1.0.1
scm:svn:https://svn.apache.org/repos/asf/geronimo/specs/tags/geronimo-jacc_1.1_spec-1.0.1
scm:svn:https://svn.apache.org/repos/asf/geronimo/specs/tags/geronimo-jacc_1.1_spec-1.0.1
geronimo-jacc-1.1-spec-1.0.1/NOTICE.txt 0000644 0000000 0000000 00000000253 10750440550 015673 0 ustar root root Apache Geronimo
Copyright 2003-2008 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).