Package com.ibm.cloud.sdk.core.util
Class CredentialUtils
- java.lang.Object
-
- com.ibm.cloud.sdk.core.util.CredentialUtils
-
public final class CredentialUtils extends java.lang.Object
CredentialUtils retrieves service credentials from the environment.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CredentialUtils.VcapCredentials
This class is used to unmarshal the contents of the "credentials" field within a vcap service entry.static class
CredentialUtils.VcapService
This class is used to unmarshal an item in the list of services belonging to a particular service key.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PLAN_STANDARD
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.String>
getServiceProperties(java.lang.String serviceName)
This function will retrieve configuration properties for the specified service from the following external config sources (in priority order): 1) Credential file 2) Environment variables 3) VCAP_SERVICES 4) System properties The properties are returned in a Map.static java.util.Map<java.lang.String,java.util.List<CredentialUtils.VcapService>>
getVcapServicesObj()
Retrieves the VCAP_SERVICES environment variable and unmarshals it.static boolean
hasBadStartOrEndChar(java.lang.String credentialValue)
Returns true if the supplied value begins or ends with curly brackets or quotation marks.
-
-
-
Field Detail
-
PLAN_STANDARD
public static final java.lang.String PLAN_STANDARD
- See Also:
- Constant Field Values
-
-
Method Detail
-
getServiceProperties
public static java.util.Map<java.lang.String,java.lang.String> getServiceProperties(java.lang.String serviceName)
This function will retrieve configuration properties for the specified service from the following external config sources (in priority order): 1) Credential file 2) Environment variables 3) VCAP_SERVICES 4) System properties The properties are returned in a Map.- Parameters:
serviceName
- the name of the service. When searching for service-related properties in the credential file and environment variable config sources, this service name is transformed by folding it to upper case and replacing "-" with "_". (e.g. "my-service" yields "MY_SERVICE"). When searching for the service within the VCAP_SERVICES setting, no transformation of the service name is performed.- Returns:
- a Map of properties associated with the service
-
hasBadStartOrEndChar
public static boolean hasBadStartOrEndChar(java.lang.String credentialValue)
Returns true if the supplied value begins or ends with curly brackets or quotation marks. Returns false for null inputs.- Parameters:
credentialValue
- the credential value to check- Returns:
- true if the value starts or ends with these characters and is therefore invalid
-
getVcapServicesObj
public static java.util.Map<java.lang.String,java.util.List<CredentialUtils.VcapService>> getVcapServicesObj()
Retrieves the VCAP_SERVICES environment variable and unmarshals it.- Returns:
- a map containing the unmarshalled VCAP_SERVICES value
-
-