public abstract class SecretUtils extends Object
Secrets.
Note: API may be subject to change.| Constructor and Description |
|---|
SecretUtils() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
base64Decode(String s)
Convert a String representation of the base64 encoded bytes back to a byte[].
|
static String |
base64DecodeToString(String s)
Convert a String representation of the base64 encoded bytes of a UTF-8 String back to a String.
|
static String |
getCredentialDescription(io.fabric8.kubernetes.api.model.Secret s)
Obtain the credential description from a given
Secret. |
static String |
getCredentialId(io.fabric8.kubernetes.api.model.Secret s)
Obtain the credential ID from a given
Secret. |
static com.cloudbees.plugins.credentials.CredentialsScope |
getCredentialScope(io.fabric8.kubernetes.api.model.Secret s)
Get the scope from a given
Secret. |
static String |
getKeyName(io.fabric8.kubernetes.api.model.Secret s,
String key)
Get the mapping for the specified key name.
|
static String |
getNonNullSecretData(io.fabric8.kubernetes.api.model.Secret s,
String key,
String exceptionMessage)
Get the data for the specified key (or the mapped key if key is mapped), or throw a
CredentialsConvertionException if the data for the given key was not present..
|
static Optional<String> |
getOptionalSecretData(io.fabric8.kubernetes.api.model.Secret s,
String key,
String exceptionMessage)
Get optional data for the specified key (or the mapped key if key is mapped)
|
static <T> T |
requireNonNull(T obj,
String exceptionMessage)
Checks that
obj is not null. |
static <T> T |
requireNonNull(T obj,
String exceptionMessage,
String mapped)
Checks that
obj is not null. |
@CheckForNull @Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String base64DecodeToString(String s)
s - the base64 encoded String representation of the bytes.null if the string could not be converted.@CheckForNull @Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static byte[] base64Decode(String s)
s - the base64 encoded representation of the bytes.null if the string could not be converted.public static com.cloudbees.plugins.credentials.CredentialsScope getCredentialScope(io.fabric8.kubernetes.api.model.Secret s)
throws CredentialsConvertionException
Secret.
If the label is empty, then it defaults to global scope.s - the secret whose scope we want to obtain.CredentialsConvertionException - if scope is invalid.public static String getCredentialId(io.fabric8.kubernetes.api.model.Secret s)
Secret.s - the secret whose id we want to obtain.@CheckForNull public static String getCredentialDescription(io.fabric8.kubernetes.api.model.Secret s)
Secret.s - the secret whose description we want to obtain.public static <T> T requireNonNull(@Nullable
T obj,
String exceptionMessage)
throws CredentialsConvertionException
obj is not null.T - the type of the obj.obj - the Object to check for null.exceptionMessage - detail message to be used in the event that a CredentialsConvertionException is thrown.obj if not null.CredentialsConvertionException - iff obj is null.public static <T> T requireNonNull(@Nullable
T obj,
String exceptionMessage,
@Nullable
String mapped)
throws CredentialsConvertionException
obj is not null.T - the type of the obj.obj - the Object to check for null.exceptionMessage - detail message to be used in the event that a CredentialsConvertionException is thrown.mapped - an optional mapping (adds a "mapped to " + mapped to the exception message if this is non null.obj if not null.CredentialsConvertionException - iff obj is null.public static String getNonNullSecretData(io.fabric8.kubernetes.api.model.Secret s, String key, String exceptionMessage) throws CredentialsConvertionException
s - the Secretkey - the key to get the data for (which may be mapped to another key).exceptionMessage - the detailMessage of the exception if the data for the key (or mapped key) was not
present.CredentialsConvertionException - if the data was not present.public static Optional<String> getOptionalSecretData(io.fabric8.kubernetes.api.model.Secret s, String key, String exceptionMessage) throws CredentialsConvertionException
s - the Secretkey - the key to get the data for (which may be mapped to another key).exceptionMessage - the detailMessage of the exception if the data for the key (or mapped key) was not
present.CredentialsConvertionException - if the data was not present.public static String getKeyName(io.fabric8.kubernetes.api.model.Secret s, String key)
jenkins.io/credentials-keybinding-name containing the custom name - for example
jenkins.io/credentials-keybinding-foo=wibble.s - the secret to inspect for a custom name.key - the name of the key we are looking for.key (identical object) if there is no custom mapping.Copyright © 2018–2021. All rights reserved.