public class KeywhizClient extends HttpClient
Facilitates the manipulation of Clients, Groups, Secrets and the connections between them.
baseUrl, client, JSON, keywhizKeyStore, mapper
Constructor and Description |
---|
KeywhizClient(String baseUrl,
KeywhizKeyStore keywhizKeyStore)
Create a keywhiz client for the given baseurl.
|
Modifier and Type | Method and Description |
---|---|
List<Client> |
allClients() |
List<Group> |
allGroups() |
List<SanitizedSecret> |
allSecrets() |
List<SanitizedSecret> |
allSecretsBatched(int idx,
int num,
boolean newestFirst) |
ClientDetailResponse |
clientDetailsForId(long clientId) |
ClientDetailResponse |
createClient(String name) |
GroupDetailResponse |
createGroup(String name,
String description,
com.google.common.collect.ImmutableMap<String,String> metadata) |
SecretDetailResponse |
createSecret(String name,
String description,
byte[] content,
com.google.common.collect.ImmutableMap<String,String> metadata,
long expiry) |
void |
deleteClientWithId(long clientId) |
void |
deleteGroupWithId(long groupId) |
void |
deleteSecretWithId(long secretId) |
void |
enrollClientInGroupByIds(long clientId,
long groupId) |
void |
evictClientFromGroupByIds(long clientId,
long groupId) |
Client |
getClientByName(String name) |
Group |
getGroupByName(String name) |
SanitizedSecret |
getSanitizedSecretByName(String name) |
void |
grantSecretToGroupByIds(long secretId,
long groupId) |
GroupDetailResponse |
groupDetailsForId(long groupId) |
boolean |
isClientAuthEnabled()
Check if client auth is enabled (mTLS) instead of session cookie.
|
boolean |
isLoggedIn() |
List<SanitizedSecret> |
listSecretVersions(String name,
int idx,
int numVersions) |
void |
login(String username,
char[] password)
Login to the Keywhiz server.
|
void |
revokeSecretFromGroupByIds(long secretId,
long groupId) |
SecretDetailResponse |
rollbackSecret(String name,
long version) |
SecretDetailResponse |
secretDetailsForId(long secretId) |
SecretDetailResponse |
updateSecret(String name,
boolean descriptionPresent,
String description,
boolean contentPresent,
byte[] content,
boolean metadataPresent,
com.google.common.collect.ImmutableMap<String,String> metadata,
boolean expiryPresent,
long expiry) |
clearCookies, createHttpsClient, createObjectMapper, httpDelete, httpGet, httpPost, httpPut, makeCall, throwOnCommonError
public KeywhizClient(String baseUrl, KeywhizKeyStore keywhizKeyStore) throws GeneralSecurityException
baseUrl
- keywhiz server base urlkeywhizKeyStore
- keywhiz keystore.GeneralSecurityException
- throws if any error creating the https client.public boolean isClientAuthEnabled()
HttpClient
isClientAuthEnabled
in class HttpClient
true
if client auth is enabledpublic void login(String username, char[] password) throws IOException
Future requests made using this client instance will be authenticated.
username
- login usernamepassword
- login passwordIOException
- if a network IO error occurspublic List<Group> allGroups() throws IOException
IOException
public GroupDetailResponse createGroup(String name, String description, com.google.common.collect.ImmutableMap<String,String> metadata) throws IOException
IOException
public GroupDetailResponse groupDetailsForId(long groupId) throws IOException
IOException
public void deleteGroupWithId(long groupId) throws IOException
IOException
public List<SanitizedSecret> allSecrets() throws IOException
IOException
public List<SanitizedSecret> allSecretsBatched(int idx, int num, boolean newestFirst) throws IOException
IOException
public SecretDetailResponse createSecret(String name, String description, byte[] content, com.google.common.collect.ImmutableMap<String,String> metadata, long expiry) throws IOException
IOException
public SecretDetailResponse updateSecret(String name, boolean descriptionPresent, String description, boolean contentPresent, byte[] content, boolean metadataPresent, com.google.common.collect.ImmutableMap<String,String> metadata, boolean expiryPresent, long expiry) throws IOException
IOException
public SecretDetailResponse secretDetailsForId(long secretId) throws IOException
IOException
public List<SanitizedSecret> listSecretVersions(String name, int idx, int numVersions) throws IOException
IOException
public SecretDetailResponse rollbackSecret(String name, long version) throws IOException
IOException
public void deleteSecretWithId(long secretId) throws IOException
IOException
public List<Client> allClients() throws IOException
IOException
public ClientDetailResponse createClient(String name) throws IOException
IOException
public ClientDetailResponse clientDetailsForId(long clientId) throws IOException
IOException
public void deleteClientWithId(long clientId) throws IOException
IOException
public void enrollClientInGroupByIds(long clientId, long groupId) throws IOException
IOException
public void evictClientFromGroupByIds(long clientId, long groupId) throws IOException
IOException
public void grantSecretToGroupByIds(long secretId, long groupId) throws IOException
IOException
public void revokeSecretFromGroupByIds(long secretId, long groupId) throws IOException
IOException
public Client getClientByName(String name) throws IOException
IOException
public Group getGroupByName(String name) throws IOException
IOException
public SanitizedSecret getSanitizedSecretByName(String name) throws IOException
IOException
public boolean isLoggedIn() throws IOException
IOException
Copyright © 2018 Walmart, Inc.. All rights reserved.