org.mortbay.http

Class SecurityConstraint

public class SecurityConstraint extends Object implements Cloneable, Serializable

Describe an auth and/or data constraint.

Version: $Revision: 1.44 $

Author: Greg Wilkins (gregw)

Nested Class Summary
static classSecurityConstraint.Nobody
Nobody user.
Field Summary
static StringANY_ROLE
static intDC_CONFIDENTIAL
static intDC_INTEGRAL
static intDC_NONE
static intDC_UNSET
static StringNONE
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
voidaddMethod(String method)
voidaddRole(String role)
static booleancheck(List constraints, Authenticator authenticator, UserRealm realm, String pathInContext, HttpRequest request, HttpResponse response)
Check security contraints
Objectclone()
booleanforMethod(String method)
booleangetAuthenticate()
intgetDataConstraint()
ListgetMethods()
ListgetRoles()
booleanhasDataConstraint()
booleanhasRole(String role)
booleanisAnyRole()
booleanisForbidden()
voidsetAuthenticate(boolean authenticate)
voidsetDataConstraint(int c)
voidsetName(String name)
StringtoString()

Field Detail

ANY_ROLE

public static final String ANY_ROLE

DC_CONFIDENTIAL

public static final int DC_CONFIDENTIAL

DC_INTEGRAL

public static final int DC_INTEGRAL

DC_NONE

public static final int DC_NONE

DC_UNSET

public static final int DC_UNSET

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 Detail

SecurityConstraint

public SecurityConstraint()
Constructor.

SecurityConstraint

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

Parameters: name role

Method Detail

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)
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 IOException

clone

public Object clone()

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.