public class IdentityUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FILE_NAME_REGEX |
static String |
PEM_BEGIN_CERTFICATE |
static String |
PEM_END_CERTIFICATE |
static String |
PROP_TRUST_STORE_UPDATE_REQUIRED |
static ThreadLocal<Map<String,Object>> |
threadLocalProperties |
Constructor and Description |
---|
IdentityUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
addDomainToName(String name,
String domainName)
Appends domain name to the user/role name
|
static byte[] |
base58Decode(String input)
Decodes the given base58 string into the original data bytes.
|
static String |
base58Encode(byte[] input)
Encodes the given bytes as a base58 string (no checksum is appended).
|
static String |
buildFragmentString(Map<String,String[]> parameterMap) |
static String |
buildFragmentUrl(String baseUrl,
Map<String,String[]> parameterMap) |
static String |
buildQueryComponent(Map<String,String[]> parameterMap) |
static String |
buildQueryString(Map<String,String[]> parameterMap) |
static String |
buildQueryUrl(String baseUrl,
Map<String,String[]> parameterMap) |
static void |
clearIdentityErrorMsg() |
static String |
convertCertificateToPEM(Certificate certificate)
Returns the PEM encoded certificate out of the given certificate object.
|
static Certificate |
convertPEMEncodedContentToCertificate(String certificateContent)
Converts and returns a
Certificate object for given PEM content. |
static String |
extractDomainFromName(String nameWithDomain) |
static String |
fillURLPlaceholders(String urlWithPlaceholders)
Replace the placeholders with the related values in the URL.
|
static String |
generateUUID()
Generates a secure random hexadecimal string using SHA1 PRNG and digest
|
static String |
getCertificateString(String certificateContent)
Extract certificate content and returns a
String object for given PEM content. |
static long |
getCleanUpPeriod(String tenantDomain) |
static long |
getCleanUpTimeout() |
static String |
getClientIpAddress(javax.servlet.http.HttpServletRequest request)
Get client IP address from the http request
|
static int |
getClockSkewInSeconds()
Get the server synchronization tolerance value in seconds
|
static String |
getFirstIP(String commaSeparatedIPs)
Get the first IP from a comma separated list of IPs
|
static String |
getHMAC(String secretKey,
String baseString) |
static String |
getHostName()
Get the host name of the server.
|
static IdentityCacheConfig |
getIdentityCacheConfig(String cacheManagerName,
String cacheName)
This reads the <CacheConfig> configuration in identity.xml.
|
static String |
getIdentityConfigDirPath() |
static IdentityCookieConfig |
getIdentityCookieConfig(String cookieName) |
static Map<String,IdentityCookieConfig> |
getIdentityCookiesConfigurationHolder() |
static IdentityErrorMsgContext |
getIdentityErrorMsg() |
static long |
getOperationCleanUpPeriod(String tenantDomain) |
static long |
getOperationCleanUpTimeout() |
static String |
getPPIDDisplayValue(String value) |
static String |
getPrimaryDomainName() |
static String |
getProperty(String key)
Read configuration elements from the identity.xml
|
static int |
getRandomInteger() |
static String |
getRandomNumber()
Generates a random number using two UUIDs and HMAC-SHA1
|
static DocumentBuilderFactory |
getSecuredDocumentBuilderFactory()
Create DocumentBuilderFactory with the XXE and XEE prevention measurements.
|
static TransformerFactory |
getSecuredTransformerFactory()
Create TransformerFactory with the XXE and XEE prevention measurements.
|
static String |
getServerURL(String endpoint,
boolean addProxyContextPath,
boolean addWebContextRoot) |
static String |
getServicePath()
Get the axis service path
|
static long |
getTempDataCleanUpTimeout() |
static boolean |
isBlank(String input) |
static boolean |
isFederatedUserAssociationEnabled()
Get the server config for enabling federated user association
|
static boolean |
isNotBlank(String input) |
static boolean |
isRecoveryEPAvailable() |
static boolean |
isSelfSignUpEPAvailable() |
static boolean |
isSupportedByUserStore(org.wso2.carbon.user.core.UserStoreManager userStoreManager,
String operation)
Returns whether the passed operation is supported by userstore or not
|
static boolean |
isTokenLoggable(String tokenName)
Check whether the given token value is appropriate to log.
|
static boolean |
isUseCaseSensitiveUsernameForCacheKeys(org.wso2.carbon.user.core.UserStoreManager userStoreManager)
This returns whether case sensitive user name can be used as the cache key.
|
static boolean |
isUserStoreCaseSensitive(String userStoreDomain,
int tenantId)
Check the case sensitivity of the user store.
|
static boolean |
isUserStoreCaseSensitive(org.wso2.carbon.user.core.UserStoreManager userStoreManager)
Check the case sensitivity of the user store.
|
static boolean |
isUserStoreInUsernameCaseSensitive(String username)
Check the case sensitivity of the user store in which the user is in.
|
static boolean |
isUserStoreInUsernameCaseSensitive(String username,
int tenantId)
Check the case sensitivity of the user store in which the user is in.
|
static boolean |
isValidFileName(String fileName) |
static boolean |
isValidPEMCertificate(String certificateContent)
Checks whether the PEM content is valid.
|
static String |
nodeToString(Node node)
Serialize the given node to a String.
|
static void |
populateProperties() |
static IdentityEventListenerConfig |
readEventListenerProperty(String type,
String name) |
static void |
setIdentityErrorMsg(IdentityErrorMsgContext error) |
static org.opensaml.xml.XMLObject |
unmarshall(String xmlString)
Constructing the SAML or XACML Objects from a String
|
public static final ThreadLocal<Map<String,Object>> threadLocalProperties
public static final String DEFAULT_FILE_NAME_REGEX
public static final String PEM_BEGIN_CERTFICATE
public static final String PEM_END_CERTIFICATE
public static final String PROP_TRUST_STORE_UPDATE_REQUIRED
public static IdentityErrorMsgContext getIdentityErrorMsg()
public static void setIdentityErrorMsg(IdentityErrorMsgContext error)
error
- public static void clearIdentityErrorMsg()
public static String getProperty(String key)
key
- Element Name as specified from the parent elements in the XML structure.
To read the element value of b in , the property
name should be passed as "a.b"public static IdentityEventListenerConfig readEventListenerProperty(String type, String name)
public static IdentityCacheConfig getIdentityCacheConfig(String cacheManagerName, String cacheName)
When calling this method, only pass the cacheManagerName and cacheName parameters considering how the names are set in a clustered environment i.e. without the CachingConstants.LOCAL_CACHE_PREFIX.
public static IdentityCookieConfig getIdentityCookieConfig(String cookieName)
public static Map<String,IdentityCookieConfig> getIdentityCookiesConfigurationHolder()
public static void populateProperties()
public static String getPPIDDisplayValue(String value) throws Exception
Exception
public static String nodeToString(Node node)
node
- Node to be serialized.public static String getHMAC(String secretKey, String baseString) throws SignatureException
SignatureException
public static String generateUUID() throws Exception
Exception
public static String getRandomNumber() throws org.wso2.carbon.identity.base.IdentityException
org.wso2.carbon.identity.base.IdentityException
- Exception due to Invalid Algorithm or Invalid Keypublic static int getRandomInteger() throws org.wso2.carbon.identity.base.IdentityException
org.wso2.carbon.identity.base.IdentityException
public static String getIdentityConfigDirPath()
public static String getServerURL(String endpoint, boolean addProxyContextPath, boolean addWebContextRoot) throws org.wso2.carbon.identity.base.IdentityRuntimeException
org.wso2.carbon.identity.base.IdentityRuntimeException
public static String getServicePath()
public static org.opensaml.xml.XMLObject unmarshall(String xmlString) throws org.wso2.carbon.identity.base.IdentityException
xmlString
- Decoded SAML or XACML Stringorg.wso2.carbon.identity.base.IdentityException
public static DocumentBuilderFactory getSecuredDocumentBuilderFactory()
public static TransformerFactory getSecuredTransformerFactory()
public static boolean isUserStoreInUsernameCaseSensitive(String username)
username
- Full qualified usernamepublic static boolean isUserStoreInUsernameCaseSensitive(String username, int tenantId)
username
- user name with user store domaintenantId
- tenant id of the userpublic static boolean isUserStoreCaseSensitive(String userStoreDomain, int tenantId)
userStoreDomain
- user store domaintenantId
- tenant id of the user storepublic static boolean isUserStoreCaseSensitive(org.wso2.carbon.user.core.UserStoreManager userStoreManager)
userStoreManager
- public static boolean isUseCaseSensitiveUsernameForCacheKeys(org.wso2.carbon.user.core.UserStoreManager userStoreManager)
userStoreManager
- user-store managerpublic static boolean isNotBlank(String input)
public static boolean isBlank(String input)
public static long getCleanUpTimeout()
public static long getCleanUpPeriod(String tenantDomain)
public static long getOperationCleanUpTimeout()
public static long getTempDataCleanUpTimeout()
public static long getOperationCleanUpPeriod(String tenantDomain)
public static String addDomainToName(String name, String domainName)
name
- user/role namedomainName
- domain namepublic static String getPrimaryDomainName()
public static boolean isValidFileName(String fileName)
public static String fillURLPlaceholders(String urlWithPlaceholders)
urlWithPlaceholders
- URL with the placeholders.public static boolean isTokenLoggable(String tokenName)
tokenName
- Name of the token.public static String getHostName()
public static String buildQueryString(Map<String,String[]> parameterMap) throws UnsupportedEncodingException
UnsupportedEncodingException
public static String buildFragmentString(Map<String,String[]> parameterMap) throws UnsupportedEncodingException
UnsupportedEncodingException
public static String buildQueryUrl(String baseUrl, Map<String,String[]> parameterMap) throws UnsupportedEncodingException
UnsupportedEncodingException
public static String buildFragmentUrl(String baseUrl, Map<String,String[]> parameterMap) throws UnsupportedEncodingException
UnsupportedEncodingException
public static String buildQueryComponent(Map<String,String[]> parameterMap) throws UnsupportedEncodingException
UnsupportedEncodingException
public static String getClientIpAddress(javax.servlet.http.HttpServletRequest request)
request
- http servlet requestpublic static String getFirstIP(String commaSeparatedIPs)
commaSeparatedIPs
- String which contains comma+space separated IPspublic static int getClockSkewInSeconds()
public static boolean isFederatedUserAssociationEnabled()
public static boolean isSupportedByUserStore(org.wso2.carbon.user.core.UserStoreManager userStoreManager, String operation)
userStoreManager
- User Storeoperation
- Operation namepublic static boolean isRecoveryEPAvailable()
public static boolean isSelfSignUpEPAvailable()
public static Certificate convertPEMEncodedContentToCertificate(String certificateContent) throws CertificateException
Certificate
object for given PEM content.certificateContent
- CertificateException
public static String getCertificateString(String certificateContent)
String
object for given PEM content.certificateContent
- initial certificate contentCertificateException
public static String convertCertificateToPEM(Certificate certificate) throws CertificateException
certificate
- String
CertificateException
public static boolean isValidPEMCertificate(String certificateContent)
certificateContent
- PEM content to be validated.public static String base58Encode(byte[] input)
input
- the bytes to encodepublic static byte[] base58Decode(String input) throws RuntimeException
input
- the base58-encoded string to decodeRuntimeException
- if the given string is not a valid base58 stringCopyright © 2019 WSO2. All rights reserved.