JXTA

net.jxta.impl.access
Class AccessList

java.lang.Object
  extended by net.jxta.impl.access.AccessList

public class AccessList
extends Object

Manages Access Permissions.


Nested Class Summary
static class AccessList.Entry
          Entries class
 
Field Summary
protected  Map<ID,AccessList.Entry> accessMap
           
(package private)  String description
           
(package private)  boolean grantAll
           
 
Constructor Summary
AccessList()
          Default Constructor
AccessList(Element root)
          Construct from a StructuredDocument
AccessList(InputStream stream)
          Initialize access list from an InputStream
AccessList(Map<ID,AccessList.Entry> map)
           
AccessList(URI uri)
          Initialize access list from a URI

e.g. file:/export/dist/acl.xml, e.g. http://configserver.net/edge.acl

 
Method Summary
 void add(AccessList.Entry entry)
          Adds an ACL entry
 Map<ID,AccessList.Entry> getAccessMap()
          gets the entries list
static String getAdvertisementType()
          All messages have a type (in xml this is !doctype) which identifies the message
 String getDescrption()
          gets the description of this access control
 Document getDocument(MimeMediaType asMimeType)
          Returns the Document
 boolean getGrantAll()
          Determine if all access is granted.
 void init(File fromFile)
          Initialize access list from a file
 void init(URI uri)
          Initialize the access list from a URI
protected  void initialize(XMLElement doc)
          Process an individual element from the document.
 boolean isAllowed(ID id)
          Determines if an entry has access
 void refresh(File file)
          Deprecated. use URI variant
 void refresh(InputStream stream)
          refresh the access list from a stream
 void refresh(URI uri)
          refresh the access list from a URI
 void remove(AccessList.Entry entry)
          Removes an ACL entry
 void setDescrption(String description)
          sets the ACL description
protected  void setEntries(Map<ID,AccessList.Entry> map)
          sets the entries list
 void setGrantAll(boolean grantAll)
          Allows/denies all access
 String toString()
          returns the document string representation of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

accessMap

protected final Map<ID,AccessList.Entry> accessMap

description

String description

grantAll

boolean grantAll
Constructor Detail

AccessList

public AccessList()
Default Constructor


AccessList

public AccessList(InputStream stream)
           throws IOException
Initialize access list from an InputStream

Parameters:
stream - the input stream
Throws:
IOException - if an io error occurs

AccessList

public AccessList(URI uri)
           throws IOException
Initialize access list from a URI

e.g. file:/export/dist/acl.xml, e.g. http://configserver.net/edge.acl

Parameters:
uri - the URI to the access control list
Throws:
IOException - if an i/o error occurs

AccessList

public AccessList(Map<ID,AccessList.Entry> map)
Parameters:
map - The map of addresses and permissions.

AccessList

public AccessList(Element root)
Construct from a StructuredDocument

Parameters:
root - root element
Method Detail

init

public void init(URI uri)
          throws IOException
Initialize the access list from a URI

Parameters:
uri - the refresh URI
Throws:
IOException - if an io error occurs

init

public void init(File fromFile)
          throws IOException
Initialize access list from a file

Parameters:
fromFile - file to init from
Throws:
IOException - if an io error occurs

refresh

@Deprecated
public void refresh(File file)
Deprecated. use URI variant

Refresh access list from a file

Parameters:
file - file to refresh from

refresh

public void refresh(InputStream stream)
             throws IOException
refresh the access list from a stream

Parameters:
stream - the input stream
Throws:
IOException - if an io error occurs

refresh

public void refresh(URI uri)
             throws IOException
refresh the access list from a URI

Parameters:
uri - the refresh URI
Throws:
IOException - if an io error occurs

getDescrption

public String getDescrption()
gets the description of this access control

Returns:
the document description

getGrantAll

public boolean getGrantAll()
Determine if all access is granted.

Returns:
If true then all access requests will be granted.

setGrantAll

public void setGrantAll(boolean grantAll)
Allows/denies all access

Parameters:
grantAll - If true then all access requests will be granted.

setDescrption

public void setDescrption(String description)
sets the ACL description

Parameters:
description - The new description

setEntries

protected void setEntries(Map<ID,AccessList.Entry> map)
sets the entries list

Parameters:
map - The new access map

add

public void add(AccessList.Entry entry)
Adds an ACL entry

Parameters:
entry - the entry to add

remove

public void remove(AccessList.Entry entry)
Removes an ACL entry

Parameters:
entry - the entry to remove

isAllowed

public boolean isAllowed(ID id)
Determines if an entry has access

Parameters:
id - the PeerID
Returns:
ture if access is allowed, always true if grantAll is set

getAccessMap

public Map<ID,AccessList.Entry> getAccessMap()
gets the entries list

Returns:
List The List containing Entries

getDocument

public Document getDocument(MimeMediaType asMimeType)
Returns the Document

Parameters:
asMimeType - mime type encoding
Returns:
The document value

initialize

protected void initialize(XMLElement doc)
Process an individual element from the document.

Parameters:
doc - the element

toString

public String toString()
returns the document string representation of this object

Overrides:
toString in class Object
Returns:
String representation of the of this message type

getAdvertisementType

public static String getAdvertisementType()
All messages have a type (in xml this is !doctype) which identifies the message

Returns:
String "jxta:XACL"

JXSE