2.17.2: 2011-06-17

net.sf.basedb.core
Class PluginSessionControl

java.lang.Object
  extended by net.sf.basedb.core.SessionControl
      extended by net.sf.basedb.core.PluginSessionControl

 class PluginSessionControl
extends SessionControl

This is a special session control implementation that is used for executing plugins that prevents them from logging in or out. If the plugin has enabled permissions those permissions are also loaded and taken into account when checking access to items.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2010-04-20 10:02:16 +0200 (Tue, 20 Apr 2010) $

Field Summary
private  SessionControl parent
           
 
Constructor Summary
PluginSessionControl(String id, SessionControl parent, PluginDefinition plugin, Job job)
          Create a new plugin session control
 
Method Summary
 PluginSessionControl getPluginSessionControl(PluginDefinition plugin, Job job)
          Create a new session control for executing a plugin using the same parent as this session control has.
 SessionControl impersonateLogin(int userId, String comment)
          Log in as another user.
 SessionControl impersonateLogin(Ownable item, String comment)
          Log in as the owner of the specified item.
(package private)  void login(Keyring keyring)
           
 void login(String login, String password, String comment, boolean encryptedPassword)
          Log in to BASE.
 void logout()
          Do nothing, a plugin is not allowed to log out.
 
Methods inherited from class net.sf.basedb.core.SessionControl
cleanUp, clearDbControlCache, close, deleteContext, deleteCurrentContexts, finalize, getActiveProjectId, getAllCurrentContexts, getAllPermissions, getAllPermissions, getChallenge, getClientDefaultSetting, getClientId, getContext, getContextNames, getContextNames, getCurrentContext, getCurrentContext, getCurrentContext, getCurrentContext, getCurrentSessionId, getExternalClientId, getFriends, getGroups, getId, getItemKeyId, getItemKeys, getItemKeys, getJobId, getLastAccess, getLocale, getLoggedInUserId, getPluginId, getPluginPermissions, getProjectKeyId, getProjectKeys, getProjectKeys, getProjectPermission, getProjects, getRemoteId, getRolePermissions, getRoles, getSessionSetting, getSharedPermissions, getUserClientSetting, getUserDefaultSetting, hasPermission, hasSystemPermission, isClosed, isDenied, isFriendOf, isImpersonated, isLoggedIn, isMemberOf, isMemberOf, isMemberOf, loadContext, newDbControl, reloadPermissions, reloadSettings, saveCurrentContextAs, saveCurrentContextAs, setActiveProject, setSessionSetting, setUserClientSetting, setUserDefaultSetting, updateLastAccess
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

private final SessionControl parent
Constructor Detail

PluginSessionControl

PluginSessionControl(String id,
                     SessionControl parent,
                     PluginDefinition plugin,
                     Job job)
Create a new plugin session control

Parameters:
id - The ID of the session control
parent - The parent session control which settings and permissions should be copied from
plugin - The plugin that is executing
Method Detail

login

void login(Keyring keyring)
Overrides:
login in class SessionControl
Throws:
PermissionDeniedException - Always

login

public void login(String login,
                  String password,
                  String comment,
                  boolean encryptedPassword)
           throws ItemNotFoundException,
                  PermissionDeniedException,
                  InvalidPasswordException,
                  BaseException
Description copied from class: SessionControl
Log in to BASE. The method checks that the given login is valid, the password is correct and that the user has USE permission for the client application if one has been specified.

The encryptedPassword parameter is used if the client application sends the password encrypted. See SessionControl.getChallenge() for information about how to encrypt the password.

Overrides:
login in class SessionControl
Parameters:
login - The login of the user
password - The UTF-8 encoded password for the user
comment - A comment for the login, which will show in the Session
encryptedPassword - A flag indicating if the password has been encrypted or not
Throws:
PermissionDeniedException - Always
ItemNotFoundException - If a user with the specified username is not found
InvalidPasswordException - If the specified password is incorrect
BaseException - If there is any other error
See Also:
SessionControl.logout(), SessionControl.isLoggedIn(), SessionControl.getLoggedInUserId()

logout

public void logout()
            throws BaseException
Do nothing, a plugin is not allowed to log out.

Overrides:
logout in class SessionControl
Throws:
BaseException - If there is an error
See Also:
SessionControl.login(String, String, String, boolean), SessionControl.isLoggedIn(), SessionControl.impersonateLogin(int, String), SessionControl.isImpersonated()

impersonateLogin

public SessionControl impersonateLogin(int userId,
                                       String comment)
                                throws ItemNotFoundException,
                                       PermissionDeniedException,
                                       BaseException
Description copied from class: SessionControl
Log in as another user. If this call is successful, you will get a new SessionControl object which is equivalent to a SessionControl where that user logged in by normal means. This method requires that the logged in user has Permission.ACT_AS_ANOTHER_USER permission.

Overrides:
impersonateLogin in class SessionControl
Parameters:
userId - The id of the user to login as
comment - A comment that will be placed in the Session information
Returns:
A new SessionControl object
Throws:
PermissionDeniedException - Always
ItemNotFoundException - If no user with the specified id exists
BaseException - If there is another error

impersonateLogin

public SessionControl impersonateLogin(Ownable item,
                                       String comment)
Description copied from class: SessionControl
Log in as the owner of the specified item.

Overrides:
impersonateLogin in class SessionControl
Parameters:
item - Login as the owner of this Item. Null is not allowed
comment - A comment that will be placed in the Session information
Returns:
A SessionControl for the created session.
Throws:
PermissionDeniedException - Always
See Also:
SessionControl.impersonateLogin(int, String)

getPluginSessionControl

public PluginSessionControl getPluginSessionControl(PluginDefinition plugin,
                                                    Job job)
Create a new session control for executing a plugin using the same parent as this session control has.

Overrides:
getPluginSessionControl in class SessionControl
Parameters:
plugin - The plugin to execute
job - The job that executes the plug-in, or null
Returns:
A plugin session control

2.17.2: 2011-06-17