Package oracle.security.xs
Interface Session
-
public interface SessionThis interface represents an application security context that encapsulates user, role, and namespace.
The session is created at database, and attached to a JDBC connection to enforce data security. The session state (user, role, and namespace) can be changed after attach. The changes take effect immediately on the current JDBC connection (database session), and are committed to database upon detach from the connection.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SessionNamespacecreateNamespace(java.lang.String name)Creates a new namespace for this session.voiddeleteNamespace(java.lang.String namespace)Removes a namespace from a session.voiddisableRole(Role role)Disables a role granted to the current user for this session.voidenableRole(Role role)Enables a role granted to the current user for this session.java.sql.ConnectiongetConnection()Returns the Oracle JDBCConnectionattached with this session.java.lang.StringgetCookie()Returns the secure session cookie used for this session.java.util.Collection<Role>getEnabledRoles()Returns a collection of all currently enabled roles.java.lang.StringgetId()Returns the internal session ID generated at server for this session.SessionNamespacegetNamespace(java.lang.String name)Returns the specified namespace in the session.java.lang.StringgetUser()Returns current session's userbooleanisAnonymous()Determines if this session user is anonymous.booleanisAttached()Determines if this session is attached to aConnection.booleanisRoleEnabled(java.lang.String roleName)Tests if the specified role is enabled in this user's session.booleanisTrusted()Determins if the current session is in trusted mode.voidswitchUser(java.lang.String targetUser, java.util.Collection<NamespaceValue> namespaceValues)Changes the session user.voidswitchUserKeepState(java.lang.String targetUser, java.util.Collection<NamespaceValue> namespaceValues)Changes the session user and retains session state (Namespace).java.lang.StringtoString()
-
-
-
Method Detail
-
switchUser
void switchUser(java.lang.String targetUser, java.util.Collection<NamespaceValue> namespaceValues) throws java.sql.SQLException, AccessDeniedException, InvalidSessionException, InvalidXSUserException, XSException, NotAttachedException, InvalidXSNamespaceExceptionChanges the session user. By default, it does not retain the session state, which means that all the existing namespaces in the session are dropped and newly specified namespaces are created. The attribute values inside NamespaceValue are set or created.- Parameters:
targetUser- aUserobject initialized based on authenticationnamespaceValues- a list ofNamespaceValueobjects to be created and changed.- Throws:
AccessDeniedException- the current user does not have the privilege to switch to the target user.XSException- a generic error is detectedjava.sql.SQLException- a JDBC exception is thrownInvalidSessionException- an attempt is made to reference an invalid sessionInvalidXSUserException- XS user specified is invalidNotAttachedException- session not attachedInvalidXSNamespaceException- when an invalid namespace specified
-
switchUserKeepState
void switchUserKeepState(java.lang.String targetUser, java.util.Collection<NamespaceValue> namespaceValues) throws java.sql.SQLException, AccessDeniedException, InvalidSessionException, InvalidXSUserException, XSException, NotAttachedException, InvalidXSNamespaceExceptionChanges the session user and retains session state (Namespace). If the given namespaces do not exist in the current session, then they are created. The attributes value insideNamespaceValuewill be set/created.- Parameters:
targetUser- aUserobject initialized based on authenticationnamespaceValues- a list ofNamespaceValueobjects to be created and changed.- Throws:
AccessDeniedException- the current user does not have the privilege to switch to the target user.XSException- a generic error is detectedjava.sql.SQLException- a JDBC exception is thrownInvalidSessionException- an attempt is made to reference an invalid sessionInvalidXSUserException- XS user specified is invalidNotAttachedException- session not attachedInvalidXSNamespaceException- when an invalid namespace specified
-
getEnabledRoles
java.util.Collection<Role> getEnabledRoles()
Returns a collection of all currently enabled roles. No database roundtrip is required.
-
isRoleEnabled
boolean isRoleEnabled(java.lang.String roleName) throws XSException, NotAttachedExceptionTests if the specified role is enabled in this user's session. No database roundtrip is required.- Parameters:
roleName- name of role to enable- Returns:
- boolean true if role is enabled or else false
- Throws:
NotAttachedException- session not attachedXSException- generic error is detected
-
getCookie
java.lang.String getCookie()
Returns the secure session cookie used for this session.- Returns:
- The cookie
-
getId
java.lang.String getId()
Returns the internal session ID generated at server for this session.- Returns:
- The Session ID
-
isAttached
boolean isAttached()
Determines if this session is attached to aConnection.- Returns:
- Boolean indicating whether the session is attached
-
isAnonymous
boolean isAnonymous()
Determines if this session user is anonymous.- Returns:
- Boolean indicating whether the session user is anonymous
-
getConnection
java.sql.Connection getConnection()
Returns the Oracle JDBCConnectionattached with this session.- Returns:
- The JDBC
Connection
-
enableRole
void enableRole(Role role) throws AccessDeniedException, java.sql.SQLException, XSException, InvalidSessionException, NotAttachedException
Enables a role granted to the current user for this session. This method has no effect if the role is currently enabled. This operation requires a database roundtrip.- Throws:
AccessDeniedException- the current user does not have the privilege to enable this roleXSException- a generic error is detectedjava.sql.SQLException- a JDBC exception is thrownInvalidSessionException- an attempt is made to reference an invalid sessionNotAttachedException- session not attached
-
disableRole
void disableRole(Role role) throws AccessDeniedException, java.sql.SQLException, XSException, InvalidSessionException, NotAttachedException
Disables a role granted to the current user for this session. This operation requires a database roundtrip.- Throws:
AccessDeniedException- the current user does not have the privilege to disable this roleXSException- a generic error is detectedjava.sql.SQLException- a JDBC exception is thrownInvalidSessionException- an attempt is made to reference an invalid sessionNotAttachedException- session not attached
-
createNamespace
SessionNamespace createNamespace(java.lang.String name) throws java.sql.SQLException, AccessDeniedException, XSException, InvalidXSNamespaceException, InvalidSessionException, NotAttachedException
Creates a new namespace for this session. The createNamespace method creates a new session namespace using the namespace template document, whose name matches with the specified name. If an event handler is defined in the template document, then the defined event handler applies to all the namespaces created using that template.- Parameters:
name- the name of the session namespace. The user should have "bindNamespace" privilege on the namespace template documents corersponding to the name.- Returns:
SessionNamespacethat is created- Throws:
AccessDeniedException- user does not have the privilege to create the namespaceXSException- a generic error is detectedjava.sql.SQLException- a JDBC exception is thrownInvalidXSNamespaceException- namespace already existsInvalidSessionException- an attempt is made to reference an invalid sessionNotAttachedException- session not attached
-
getNamespace
SessionNamespace getNamespace(java.lang.String name) throws java.sql.SQLException, AccessDeniedException, XSException, InvalidSessionException, InvalidXSNamespaceException, NotAttachedException
Returns the specified namespace in the session.- Parameters:
name- the namespace to get- Returns:
- object corresponding to the namespace name
- Throws:
AccessDeniedException- the current user does not have the privilege to get namespaceXSException- a generic error is detectedjava.sql.SQLException- a JDBC exception is thrownInvalidXSNamespaceException- namespace already existsInvalidSessionException- attempt to reference an invalid sessionNotAttachedException- session not attached
-
deleteNamespace
void deleteNamespace(java.lang.String namespace) throws java.sql.SQLException, AccessDeniedException, XSException, InvalidXSNamespaceException, InvalidSessionException, NotAttachedExceptionRemoves a namespace from a session.- Parameters:
namespace- the namespace object to be removed- Throws:
AccessDeniedException- the current user does not have the privilege to delete this namespacejava.sql.SQLException- a JDBC exception is thrownInvalidXSNamespaceException- namespace is invalidInvalidSessionException- attempted to reference an invalid sessionNotAttachedException- session not attachedXSException- a generic error is detected
-
isTrusted
boolean isTrusted()
Determins if the current session is in trusted mode.- Returns:
- true if it is trusted; otherwise false.
-
getUser
java.lang.String getUser()
Returns current session's user
-
toString
java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-