class Session

Library: OSP/Shell
Package: Shell
Header: Poco/OSP/Shell/Session.h


The Session class provides user authentication and authorization for the CommandProcessor.

It is also passed as the first argument to the execute() member function of Command, so that command implementations can perform custom authorization.

Member Summary

Member Functions: authService, authenticated, authorize, login, user



    Poco::OSP::BundleContext::Ptr pContext,
    const std::string & authServiceName

Creates the Session, using the given bundle context and the given service name of the authentication service.

An empty service name disables authentication and authorization.




Destroys the Session.

Member Functions

authenticated inline

bool authenticated() const;

Returns true if the user is authenticated.


bool authorize(
    const std::string & permission
) const;

Returns true if the user is authenticated and has the given permission, false otherwise.


bool login(
    const std::string & userName,
    const std::string & credentials

Attempts to authenticate the user by checking the given userName and credentials with the authentication service.

Returns true if the user was successfully authenticated, false otherwise.

user inline

const std::string & user() const;

Returns the name of the current user, or an empty string if no user is logged in.

authService protected

Poco::OSP::Auth::AuthService::Ptr authService() const;