com.j_spaces.core
Class SecurityContext

java.lang.Object
  extended by com.j_spaces.core.SecurityContext
All Implemented Interfaces:
Externalizable, Serializable

public class SecurityContext
extends Object
implements Externalizable

The SecurityContext class defines security info passed from the proxy to the space, and is used by the security filters to validate access to space functions.

See Also:
IJSpace.setSecurityContext(SecurityContext), Serialized Form

Field Summary
static String ANONYMOUS_USER
          Default user name and password, when default constructor is used.
static char PERMISSION_ADMIN
          Admin functions permission.
static char PERMISSION_READ
          Read permission.
static char PERMISSION_WRITE
          Write/Take/Update/Replace permission.
 
Constructor Summary
SecurityContext()
          The default constructor shall create a security context used for ANONYMOUS_USER user account.
SecurityContext(String username, String password)
          Create new security context.
 
Method Summary
 void disableAllOperations()
          Disable all operations to user represented by this security context.
 Object getImplementorContext()
          Get the implementation specific free context.
 String getPassword()
          Gets the password.
 String getPermissions()
          Gets the the permission String.
 String getUsername()
          Gets user name.
 boolean isEncrypted()
          Check is encrypted.
 void readExternal(ObjectInput in)
          
 void setEncrypted(boolean isEncrypted)
          Set indicator if encrypted.
 void setImplementorContext(Object implementorContext)
          Set implementation specific free context, must implement Serializable.
 void setPassword(String pass)
          Sets password.
 void setPermissions(String permissions)
          Set the permission.
 void setUsername(String username)
          Sets user name.
 void writeExternal(ObjectOutput out)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERMISSION_READ

public static final char PERMISSION_READ
Read permission.

See Also:
Constant Field Values

PERMISSION_WRITE

public static final char PERMISSION_WRITE
Write/Take/Update/Replace permission.

See Also:
Constant Field Values

PERMISSION_ADMIN

public static final char PERMISSION_ADMIN
Admin functions permission.

See Also:
Constant Field Values

ANONYMOUS_USER

public static final String ANONYMOUS_USER
Default user name and password, when default constructor is used.

See Also:
SecurityContext(), Constant Field Values
Constructor Detail

SecurityContext

public SecurityContext()
The default constructor shall create a security context used for ANONYMOUS_USER user account.


SecurityContext

public SecurityContext(String username,
                       String password)
Create new security context.

Parameters:
username - - User name shouldn't be null value.
password - - Password shouldn't be null value.
Method Detail

disableAllOperations

public void disableAllOperations()
Disable all operations to user represented by this security context.


writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException

Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException

Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

setUsername

public void setUsername(String username)
Sets user name.

Parameters:
username - the user name

getUsername

public String getUsername()
Gets user name.

Returns:
user name

setPassword

public void setPassword(String pass)
Sets password.

Parameters:
pass - the password

getPassword

public String getPassword()
Gets the password.

Returns:
the password

setEncrypted

public void setEncrypted(boolean isEncrypted)
Set indicator if encrypted.

Parameters:
isEncrypted - true if encrypted

isEncrypted

public boolean isEncrypted()
Check is encrypted.

Returns:
true if encrypted

setPermissions

public void setPermissions(String permissions)
Set the permission.
 For example:
 
    SecurityContext context = ...;
    context.setPermissions("" + PERMISSION_WRITE + PERMISSION_READ); // read & write permission 
 
 

Parameters:
permissions - the permission string

getPermissions

public String getPermissions()
Gets the the permission String.

Returns:
the permission String
See Also:
setPermissions(String)

setImplementorContext

public void setImplementorContext(Object implementorContext)
Set implementation specific free context, must implement Serializable. This can be used to attach a metadata to the context.

Parameters:
implementorContext - implementation specific free context

getImplementorContext

public Object getImplementorContext()
Get the implementation specific free context.

Returns:
implementation specific free context
See Also:
setImplementorContext(Object)