public class AuthenticationRequest extends VaultRequest
Note that the VaultClient automatically performs Authentication requests to establish the Vault session.
HTTP_HEADER_AUTHORIZATION, HTTP_HEADER_VAULT_CLIENT_ID, vaultClient
Modifier and Type | Method and Description |
---|---|
DiscoveryResponse |
authenticationTypeDiscovery(String username)
Authenticate via standard Vault user name and password
in the user's default Vault.
|
AuthenticationResponse |
login(String userName,
String userPassword)
Authenticate via standard Vault user name and password in the user's default Vault.
|
AuthenticationResponse |
login(String username,
String password,
String vaultDNS)
Authenticate via standard Vault user name and password
in a specific Vault Domain.
|
AuthenticationResponse |
loginOAuth(String oauthOidcProfileId,
String accessToken,
String vaultDNS)
Authenticate your account using OAuth 2.0 / Open ID Connect token to obtain a Vault session ID.
|
AuthenticationResponse |
loginWithDiscovery(String vaultUserName,
String password,
String vaultDNS)
Authenticate using Vault Discovery endpoints.
|
ApiVersionResponse |
retrieveApiVersions()
Retrieves api versions supported by the current Vault
|
AuthenticationRequest |
setIdpUserName(String idpUserName) |
AuthenticationRequest |
setValidateDNS(Boolean validateDNS)
Validate Vault DNS after successful login
|
AuthenticationRequest |
setVaultOAuthClientId(String vaultOAuthClientId)
Set the Header Accept to return CSV
|
UserRetrieveResponse |
validateSessionUser()
Validate Session User
|
getBaseObjectMapper, send, send, sendReturnBinary, sendReturnBinary, sendToFile, sendToFile, setVaultClient
public ApiVersionResponse retrieveApiVersions()
GET /api
public AuthenticationResponse login(String userName, String userPassword)
userName
- The user name for authenticationuserPassword
- The user passwordGET /api/{version}/auth
public AuthenticationResponse login(String username, String password, String vaultDNS)
username
- The user name for authenticationpassword
- The user passwordvaultDNS
- The DNS of the vault for which you want to generate a sessionGET /api/{version}/auth
public AuthenticationResponse loginOAuth(String oauthOidcProfileId, String accessToken, String vaultDNS)
When requesting a sessionId, Vault allows the ability for Oauth2/OIDC client applications to pass the client_id with the request. Vault uses this client_id when talking with the introspection endpoint at the authorization server to validate that the access_token presented by the application is valid. Learn more about Client ID in the REST API Documentation.
oauthOidcProfileId
- The ID of your OAuth2.0 / Open ID Connect profile.accessToken
- OAuth Access Token (access_token)vaultDNS
- The DNS of the vault for which you want to generate a sessionPOST login.veevavault.com/auth/oauth/session/{oath_oidc_profile_id}
public AuthenticationResponse loginWithDiscovery(String vaultUserName, String password, String vaultDNS)
vaultUserName
- The user name for authenticationpassword
- The user passwordvaultDNS
- The DNS of the vault for which you want to generate a sessionpublic DiscoveryResponse authenticationTypeDiscovery(String username)
username
- The user name for authenticationGET login.veevavault.com/auth/discovery
public UserRetrieveResponse validateSessionUser()
Given a valid session ID, this request returns information for the currently authenticated user. If the session ID is not valid, this request returns an INVALID_SESSION_ID error type. This is similar to a whoami request.
GET /api/{version}/objects/users/me
UserRetrieveResponse resp = vaultClient.newRequest(AuthenticationRequest.class).validateSessionUser();
for(UserRetrieveResponse.UserNode userNode : resp.getUsers()) { User user = userNode.getUser(); System.out.println("User name: " + user.getUserName()); System.out.println("User: " + user.getUserFirstName() + " " + user.getUserLastName()); System.out.println("Email: " + user.getUserEmail()); System.out.println("Id: " + user.getId()); }
public AuthenticationRequest setVaultOAuthClientId(String vaultOAuthClientId)
vaultOAuthClientId
- Client Id for the Vault Apppublic AuthenticationRequest setIdpUserName(String idpUserName)
public AuthenticationRequest setValidateDNS(Boolean validateDNS)
validateDNS
- true/falseCopyright © 2021. All rights reserved.