org.mortbay.http

Class SecurityConstraint

Implemented Interfaces:
Cloneable, Serializable

public class SecurityConstraint
extends java.lang.Object
implements Cloneable, Serializable

Describe an auth and/or data constraint.
Version:
$Revision: 1.44 $
Author:
Greg Wilkins (gregw)

Nested Class Summary

static class
SecurityConstraint.Nobody
Nobody user.

Field Summary

static String
ANY_ROLE
static int
DC_CONFIDENTIAL
static int
DC_INTEGRAL
static int
DC_NONE
static int
DC_UNSET
static String
NONE
static String
__BASIC_AUTH
static String
__CERT_AUTH
static String
__CERT_AUTH2
static String
__DIGEST_AUTH
static String
__FORM_AUTH
static SecurityConstraint.Nobody
__NOBODY

Constructor Summary

SecurityConstraint()
Constructor.
SecurityConstraint(String name, String role)
Conveniance Constructor.

Method Summary

void
addMethod(String method)
void
addRole(String role)
static boolean
check(List constraints, Authenticator authenticator, UserRealm realm, String pathInContext, HttpRequest request, HttpResponse response)
Check security contraints
Object
clone()
boolean
forMethod(String method)
boolean
getAuthenticate()
int
getDataConstraint()
List
getMethods()
List
getRoles()
boolean
hasDataConstraint()
boolean
hasRole(String role)
boolean
isAnyRole()
boolean
isForbidden()
void
setAuthenticate(boolean authenticate)
void
setDataConstraint(int c)
void
setName(String name)
String
toString()

Field Details

ANY_ROLE

public static final String ANY_ROLE

DC_CONFIDENTIAL

public static final int DC_CONFIDENTIAL
Field Value:
2

DC_INTEGRAL

public static final int DC_INTEGRAL
Field Value:
1

DC_NONE

public static final int DC_NONE
Field Value:
0

DC_UNSET

public static final int DC_UNSET
Field Value:
-1

NONE

public static final String NONE

__BASIC_AUTH

public static final String __BASIC_AUTH

__CERT_AUTH

public static final String __CERT_AUTH

__CERT_AUTH2

public static final String __CERT_AUTH2

__DIGEST_AUTH

public static final String __DIGEST_AUTH

__FORM_AUTH

public static final String __FORM_AUTH

__NOBODY

public static final SecurityConstraint.Nobody __NOBODY

Constructor Details

SecurityConstraint

public SecurityConstraint()
Constructor.

SecurityConstraint

public SecurityConstraint(String name,
                          String role)
Conveniance Constructor.
Parameters:
name -
role -

Method Details

addMethod

public void addMethod(String method)
Parameters:
method -

addRole

public void addRole(String role)
Parameters:
role - The rolename. If the rolename is '*' all other roles are removed and anyRole is set true and subsequent addRole calls are ignored. Authenticate is forced true by this call.

check

public static boolean check(List constraints,
                            Authenticator authenticator,
                            UserRealm realm,
                            String pathInContext,
                            HttpRequest request,
                            HttpResponse response)
            throws HttpException,
                   IOException
Check security contraints
Parameters:
constraints -
authenticator -
realm -
pathInContext -
request -
response -
Returns:
false if the request has failed a security constraint or the authenticator has already sent a response.
Throws:
HttpException -

clone

public Object clone()
            throws CloneNotSupportedException

forMethod

public boolean forMethod(String method)
Parameters:
method - Method name.
Returns:
True if this constraint applies to the method. If no method has been set, then the constraint applies to all methods.

getAuthenticate

public boolean getAuthenticate()
Returns:
True if the constraint requires request authentication

getDataConstraint

public int getDataConstraint()
Returns:
Data constrain indicator: 0=DC+NONE, 1=DC_INTEGRAL & 2=DC_CONFIDENTIAL

getMethods

public List getMethods()

getRoles

public List getRoles()
Returns:
List of roles for this constraint.

hasDataConstraint

public boolean hasDataConstraint()
Returns:
True if a data constraint has been set.

hasRole

public boolean hasRole(String role)
Parameters:
role -
Returns:
True if the constraint contains the role.

isAnyRole

public boolean isAnyRole()
Returns:
True if any user role is permitted.

isForbidden

public boolean isForbidden()
Returns:
True if authentication required but no roles set

setAuthenticate

public void setAuthenticate(boolean authenticate)
Parameters:
authenticate - True if users must be authenticated

setDataConstraint

public void setDataConstraint(int c)
Parameters:
c -

setName

public void setName(String name)
Parameters:
name -

toString

public String toString()

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.