public class LoginDelegator extends BaseDelegator implements ILoginDelegator
MAX_LIMIT_SUPPORTED_MIN_VERSION, QUERY_EXPRESSIONS_SUPPORTED_MIN_VERSION, USER_RESTRICTIONS_SUPPORTED_MIN_VERSION
Constructor and Description |
---|
LoginDelegator(IOptionsServer server)
Instantiates a new login delegator.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getLoginStatus()
Return a string indicating the current login status; corresponds to the
p4 login -s command.
|
boolean |
isDontWriteTicket(java.lang.String cmd,
java.lang.String[] cmdArgs)
Special case handling of the "-p" flag for the "p4 login" command.
|
void |
login(IUser user,
java.lang.StringBuffer ticket,
LoginOptions opts)
Log another user in to Perforce by obtaining a session ticket for that
user.
|
void |
login(java.lang.String password)
Convenience method for login(password, false).
|
void |
login(java.lang.String password,
boolean allHosts)
Log the current user (if any) in to a Perforce server, optionally
arranging to be logged in for all hosts.
|
void |
login(java.lang.String password,
LoginOptions opts)
Log the current user (if any) in to a Perforce server, optionally
arranging to be logged in for all hosts.
|
void |
login(java.lang.String password,
java.lang.StringBuffer ticket,
LoginOptions opts)
Log the current user (if any) in to a Perforce server using.
|
public LoginDelegator(IOptionsServer server)
server
- the serverpublic java.lang.String getLoginStatus() throws P4JavaException
ILoginDelegator
getLoginStatus
in interface ILoginDelegator
P4JavaException
- if any errors occur during the processing of this command.public void login(java.lang.String password) throws ConnectionException, RequestException, AccessException, ConfigException
ILoginDelegator
login
in interface ILoginDelegator
password
- Perforce password; can be null if no password is needed (as in
the case of SSO logins)ConnectionException
- if the Perforce server is unreachable or is not connected.RequestException
- if the Perforce server encounters an error during its
processing of the requestAccessException
- if the Perforce server denies access to the callerConfigException
- if the p4tickets file could not be updated successfullypublic void login(java.lang.String password, boolean allHosts) throws ConnectionException, RequestException, AccessException, ConfigException
ILoginDelegator
Attempts to log in to the underlying Perforce server. If successful, successive calls to server-side services will succeed until the session is terminated by the server or the user logs out.
Behaviour is undefined if the server's user name attribute is null (but will probably cause a NullPointerError with most implementations).
Login will work with the Perforce SSO (single sign-on) scheme: in this case your password should be null, and the environment variable P4LOGINSSO should point to an executable SSO script as described in p4 help undoc (help for this is beyond the scope of this method doc, unfortunately, and the feature is not well tested here, but it "works" in general...).
login
in interface ILoginDelegator
password
- Perforce password; can be null if no password is needed (as in
the case of SSO logins)allHosts
- if true, perform the equivalent of a "login -a"ConnectionException
- if the Perforce server is unreachable or is not connected.RequestException
- if the Perforce server encounters an error during its
processing of the requestAccessException
- if the Perforce server denies access to the callerConfigException
- if the p4tickets file could not be updated successfullypublic boolean isDontWriteTicket(java.lang.String cmd, java.lang.String[] cmdArgs)
ILoginDelegator
isDontWriteTicket
in interface ILoginDelegator
cmd
- the cmdcmdArgs
- the cmd argspublic void login(java.lang.String password, LoginOptions opts) throws P4JavaException
ILoginDelegator
Attempts to log in to the underlying Perforce server. If successful, successive calls to server-side services will succeed until the session is terminated by the server or the user logs out.
Behavior is undefined if the server's user name attribute is null (but will probably cause a NullPointerError with most implementations).
Login will work with the Perforce SSO (single sign-on) scheme: in this case your password should be null, and the environment variable P4LOGINSSO should point to an executable SSO script as described in p4 help undoc (help for this is beyond the scope of this method doc, unfortunately, and the feature is not well tested here, but it "works" in general...).
login
in interface ILoginDelegator
password
- Perforce password; can be null if no password is needed (as in
the case of SSO logins)opts
- if LoginOptions.allHosts is true, perform the equivalent of a
"login -a". A null LoginOptions parameter is equivalent to no
options being set.P4JavaException
- if any error occurs in the processing of this method. A
specific ConfigException is thrown if the p4tickets file
could not be updated successfully.public void login(java.lang.String password, java.lang.StringBuffer ticket, LoginOptions opts) throws P4JavaException
ILoginDelegator
Optionally, if the opts.isDontWriteTicket() is true ('login -p'), the ticket is not written to file; if opts.isAllHosts is true ('login -a'), the ticket is valid on all hosts; if opts.getHost() is non-null ('login -h'), the ticket is valid on the specified host.
Note: if the passed-in ticket StringBuffer originally has content it will remain there. The auth ticket will only be appended to the buffer. If a null ticket StringBuffer is passed in, the auth ticket will not be appended to it. The normal use case should be to pass in a new ticket StringBuffer.
login
in interface ILoginDelegator
password
- Perforce actuallPassword; can be null if no actuallPassword is
needed (as in the case of SSO logins)ticket
- if the ticket StringBuffer parameter is non-null, the auth
ticket that was returned by the login attempt is appended to
the passed-in ticket StringBuffer.opts
- LoginOptions describing the associated options; if null, no
options are set.P4JavaException
- if any error occurs in the processing of this method.public void login(@Nonnull IUser user, java.lang.StringBuffer ticket, LoginOptions opts) throws P4JavaException
ILoginDelegator
Optionally, if the opts.isDontWriteTicket() is true ('login -p'), the ticket is not written to file; if opts.isAllHosts is true ('login -a'), the ticket is valid on all hosts; if opts.getHost() is non-null ('login -h'), the ticket is valid on the specified host.
Specifying a user as an argument requires 'super' access, which is granted by 'p4 protect'. In this case, login another user does not require a password, assuming that you (a 'super' user) had already been logged in.
Note: if the passed-in ticket StringBuffer originally has content it will remain there. The auth ticket will only be appended to the buffer. If a null ticket StringBuffer is passed in, the auth ticket will not be appended to it. The normal use case should be to pass in a new ticket StringBuffer.
login
in interface ILoginDelegator
user
- non-null Perforce user; login request is for this specified
user.ticket
- if the ticket StringBuffer parameter is non-null, the auth
ticket that was returned by the login attempt is appended to
the passed-in ticket StringBuffer.opts
- LoginOptions describing the associated options; if null, no
options are set.P4JavaException
- if any error occurs in the processing of this method.