com.j_spaces.core.filters
Class DefaultSecurityFilter

java.lang.Object
  extended by com.j_spaces.core.filters.DefaultSecurityFilter
All Implemented Interfaces:
ISpaceFilter

public class DefaultSecurityFilter
extends Object
implements ISpaceFilter

On Init of DefaultSecurityFilter reads a encrypted binary file to configure the valid users, passwords, and roles. This filter will called only when setSecurityContext is set. If the userID not found or password is wrong SecurityException will be thrown.

See Also:
SecurityException

Field Summary
static String OPERATION_NOTIFY
          Notify operation.
static String OPERATION_READ
          Read operation.
static String OPERATION_TAKE
          Take operation.
static String OPERATION_UPDATE
          Update operation.
static String OPERATION_WRITE
          Write operation.
 
Constructor Summary
DefaultSecurityFilter()
          Empty constructor.
 
Method Summary
 void close()
          Closes this filter, enabling the developer to clean open resources.
 void init(IJSpace space, String filterId, String url, int priority)
          Initializes this filter.
 void initSpaceUserAccountDriver(String spaceName, String url)
          For internal use only.
 void process(SpaceContext context, ISpaceFilterEntry[] subject, int operationCode)
          Called only on before replace.
 void process(SpaceContext context, ISpaceFilterEntry subject, int operationCode)
          
 This method is called by the engine when an event matching this filter's
  operation code occurs in the space engine.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPERATION_WRITE

public static final String OPERATION_WRITE
Write operation.

See Also:
Constant Field Values

OPERATION_READ

public static final String OPERATION_READ
Read operation.

See Also:
Constant Field Values

OPERATION_TAKE

public static final String OPERATION_TAKE
Take operation.

See Also:
Constant Field Values

OPERATION_UPDATE

public static final String OPERATION_UPDATE
Update operation.

See Also:
Constant Field Values

OPERATION_NOTIFY

public static final String OPERATION_NOTIFY
Notify operation.

See Also:
Constant Field Values
Constructor Detail

DefaultSecurityFilter

public DefaultSecurityFilter()
Empty constructor.

Method Detail

init

public void init(IJSpace space,
                 String filterId,
                 String url,
                 int priority)
          throws RuntimeException
Initializes this filter.

Specified by:
init in interface ISpaceFilter
Parameters:
space - an embedded proxy to the space that contain this filter.
filterId - the name of this filter.
url - The URL that was passed when this filter was created.
priority - defines the order in which filters are activated.
Throws:
RuntimeException - if this exception is raised, the filter will be discarded by the engine for the current engine execution ,unless defined otherwise in space configuration.

initSpaceUserAccountDriver

public void initSpaceUserAccountDriver(String spaceName,
                                       String url)
                                throws Exception
For internal use only.

Parameters:
spaceName -
url -
Throws:
Exception

process

public void process(SpaceContext context,
                    ISpaceFilterEntry[] subject,
                    int operationCode)
             throws RuntimeException
Called only on before replace. And after replace and update.

Specified by:
process in interface ISpaceFilter
Parameters:
context - the Context passed by the caller, contains security context. some of the filters (like ON_INIT) will always receive a null context.
subject - an array of two elements:

On BEFORE_UPDATE: the first element represents the template and the second is the new entry (can only happen when replace is called).

On AFTER_UPDATE: the first element represents the old entry while the second is the new entry.

On BEFORE_NOTIFY_TRIGGER and AFTER_NOTIFY_TRIGGER: the first element represents the entry while the second is the template.

operationCode - the operation that defines when this filter is activated. The operation codes are defined in FilterOperationCodes.
Throws:
RuntimeException - if this exception is raised for BEFORE filters,

process

public void process(SpaceContext context,
                    ISpaceFilterEntry subject,
                    int operationCode)
             throws RuntimeException
 This method is called by the engine when an event matching this filter's
  operation code occurs in the space engine.

 Only for SecurityFilter implementation: On SET_SECURITY operation code call SpaceContext.setSecurityContext().
 

Specified by:
process in interface ISpaceFilter
Parameters:
context - the Context passed by the caller, contains security context. some of the filters (like ON_INIT) will always receive a null context.
subject - the event that occurred.
operationCode - the operation that defines when this filter is activated. The operation codes are defined in FilterOperationCodes.
Throws:
RuntimeException - if this exception is raised for BEFORE filters, it aborts the execution of the operation.

close

public void close()
           throws RuntimeException
Closes this filter, enabling the developer to clean open resources.

Specified by:
close in interface ISpaceFilter
Throws:
RuntimeException - if this exception is raised it will be logged. This should be used as away to report a filter internal error.