Representation of a security constraint element for a web application,
as represented in a
element in the
deployment descriptor.
| Method from org.apache.catalina.deploy.SecurityConstraint Detail: |
public void addAuthRole(String authRole) {
if (authRole == null)
return;
if ("*".equals(authRole)) {
allRoles = true;
return;
}
String results[] = new String[authRoles.length + 1];
for (int i = 0; i < authRoles.length; i++)
results[i] = authRoles[i];
results[authRoles.length] = authRole;
authRoles = results;
authConstraint = true;
}
Add an authorization role, which is a role name that will be
permitted access to the resources protected by this security constraint. |
public void addCollection(SecurityCollection collection) {
if (collection == null)
return;
SecurityCollection results[] =
new SecurityCollection[collections.length + 1];
for (int i = 0; i < collections.length; i++)
results[i] = collections[i];
results[collections.length] = collection;
collections = results;
}
Add a new web resource collection to those protected by this
security constraint. |
public boolean findAuthRole(String role) {
if (role == null)
return (false);
for (int i = 0; i < authRoles.length; i++) {
if (role.equals(authRoles[i]))
return (true);
}
return (false);
}
Return true if the specified role is permitted access to
the resources protected by this security constraint. |
public String[] findAuthRoles() {
return (authRoles);
}
Return the set of roles that are permitted access to the resources
protected by this security constraint. If none have been defined,
a zero-length array is returned (which implies that all authenticated
users are permitted access). |
public SecurityCollection findCollection(String name) {
if (name == null)
return (null);
for (int i = 0; i < collections.length; i++) {
if (name.equals(collections[i].getName()))
return (collections[i]);
}
return (null);
}
Return the web resource collection for the specified name, if any;
otherwise, return null. |
public SecurityCollection[] findCollections() {
return (collections);
}
Return all of the web resource collections protected by this
security constraint. If there are none, a zero-length array is
returned. |
public boolean getAllRoles() {
// ------------------------------------------------------------- Properties
return (this.allRoles);
}
Was the "all roles" wildcard included in this authentication
constraint? |
public boolean getAuthConstraint() {
return (this.authConstraint);
}
Return the authorization constraint present flag for this security
constraint. |
public String getDisplayName() {
return (this.displayName);
}
Return the display name of this security constraint. |
public String getUserConstraint() {
return (userConstraint);
}
Return the user data constraint for this security constraint. |
public boolean included(String uri,
String method) {
// We cannot match without a valid request method
if (method == null)
return (false);
// Check all of the collections included in this constraint
for (int i = 0; i < collections.length; i++) {
if (!collections[i].findMethod(method))
continue;
String patterns[] = collections[i].findPatterns();
for (int j = 0; j < patterns.length; j++) {
if (matchPattern(uri, patterns[j]))
return (true);
}
}
// No collection included in this constraint matches this request
return (false);
}
Return true if the specified context-relative URI (and
associated HTTP method) are protected by this security constraint. |
public void removeAuthRole(String authRole) {
if (authRole == null)
return;
int n = -1;
for (int i = 0; i < authRoles.length; i++) {
if (authRoles[i].equals(authRole)) {
n = i;
break;
}
}
if (n >= 0) {
int j = 0;
String results[] = new String[authRoles.length - 1];
for (int i = 0; i < authRoles.length; i++) {
if (i != n)
results[j++] = authRoles[i];
}
authRoles = results;
}
}
Remove the specified role from the set of roles permitted to access
the resources protected by this security constraint. |
public void removeCollection(SecurityCollection collection) {
if (collection == null)
return;
int n = -1;
for (int i = 0; i < collections.length; i++) {
if (collections[i].equals(collection)) {
n = i;
break;
}
}
if (n >= 0) {
int j = 0;
SecurityCollection results[] =
new SecurityCollection[collections.length - 1];
for (int i = 0; i < collections.length; i++) {
if (i != n)
results[j++] = collections[i];
}
collections = results;
}
}
Remove the specified web resource collection from those protected by
this security constraint. |
public void setAuthConstraint(boolean authConstraint) {
this.authConstraint = authConstraint;
}
Set the authorization constraint present flag for this security
constraint. |
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
Set the display name of this security constraint. |
public void setUserConstraint(String userConstraint) {
if (userConstraint != null)
this.userConstraint = userConstraint;
}
Set the user data constraint for this security constraint. |
public String toString() {
StringBuffer sb = new StringBuffer("SecurityConstraint[");
for (int i = 0; i < collections.length; i++) {
if (i > 0)
sb.append(", ");
sb.append(collections[i].getName());
}
sb.append("]");
return (sb.toString());
}
Return a String representation of this security constraint. |