public class SecurityUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTHENTICATION_SCHEME_BASIC |
static java.lang.String |
AUTHENTICATION_SCHEME_BEARER |
static java.lang.String |
AUTHENTICATION_SCHEME_DIGEST |
static java.lang.String |
BASIC_CREDENTIALS_SEPARATOR |
static SecurityUtil |
SECU |
Modifier | Constructor and Description |
---|---|
protected |
SecurityUtil() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
createBASICAuthorization(java.lang.String username,
java.lang.String password)
Creates the full authorization header value for the HTTP BASIC authentication
scheme as defined in RFC-2617.
|
java.lang.String |
createBEARERAuthorization(byte[] token)
Creates the full authorization header value for the BEARER authentication
scheme as defined in RFC-6750.
|
java.lang.String |
createBEARERAuthorization(java.lang.String token,
java.nio.charset.Charset charset)
Creates the full authorization header value for the BEARER authentication
scheme as defined in RFC-6750.
|
static SecurityUtil |
current()
Returns the only instance this class supports (design pattern "Singleton")
|
IStringPair |
decodeBASICCredentials(java.lang.String basicCredentials)
Decodes and splits up the value presented by a BASIC authentication
header as to RFC-2617.
|
IStringPair |
decodeBASICCredentials(java.lang.String basicCredentials,
java.nio.charset.Charset charset)
Decodes and splits up the value presented by a BASIC authentication
header as to RFC-2617.
|
java.lang.String |
encodeBASICCredentials(java.lang.String username,
java.lang.String password)
Encodes the given username and password according to the BASIC authentication
scheme specification (RFC-2617).
|
java.lang.String |
encodeBASICCredentials(java.lang.String username,
java.lang.String password,
java.nio.charset.Charset charset)
Encodes the given username and password according to the BASIC authentication
scheme specification (RFC-2617).
|
java.util.List<GeneralName> |
getSubjectAlternativeNamesFrom(java.security.cert.X509Certificate serverCertificate) |
java.security.cert.X509Certificate[] |
readX509CertificateChainFromPEM(java.io.File pemFile)
Reads a certificate chain from the given PEM file.
|
java.security.cert.X509Certificate |
readX509CertificateFromPKCS7(java.io.File file)
Reads a certificate from the given PKCS#7 file.
|
java.security.cert.X509Certificate |
readX509CertificateFromPKCS7(java.io.InputStream inStream)
Reads a certificate from the given PKCS#7 stream.
|
java.util.Collection<java.security.cert.X509Certificate> |
readX509CertificatesFromPKCS7(java.io.InputStream inStream)
Read all certificates from the given PKCS#7 stream.
|
public static final SecurityUtil SECU
public static final java.lang.String BASIC_CREDENTIALS_SEPARATOR
public static final java.lang.String AUTHENTICATION_SCHEME_BASIC
public static final java.lang.String AUTHENTICATION_SCHEME_DIGEST
public static final java.lang.String AUTHENTICATION_SCHEME_BEARER
public static SecurityUtil current()
public java.lang.String encodeBASICCredentials(java.lang.String username, java.lang.String password)
username
- The username (must not be null).password
- The password (must not be null)public java.lang.String encodeBASICCredentials(java.lang.String username, java.lang.String password, java.nio.charset.Charset charset)
username
- The username (must not be null).password
- The password (must not be null)charset
- The charset to be used for the string encoding (must not be null).public IStringPair decodeBASICCredentials(java.lang.String basicCredentials, java.nio.charset.Charset charset)
basicCredentials
- The base64 encoded concatenated username password string (must not be null).charset
- The charset to be used for the string encoding (must not be null).java.lang.IllegalArgumentException
- If the given string cannot be decoded or cannot be split into two sub-values.public IStringPair decodeBASICCredentials(java.lang.String basicCredentials)
basicCredentials
- The base64 encoded concatenated username password string (must not be null).java.lang.IllegalArgumentException
- If the given string cannot be decoded or cannot be split into two sub-values.public java.lang.String createBASICAuthorization(java.lang.String username, java.lang.String password)
username
- The username (must not be null).password
- The password (must not be null)public java.lang.String createBEARERAuthorization(byte[] token)
token
- The token that will be base64 encoded by this method (must not be null).public java.lang.String createBEARERAuthorization(java.lang.String token, java.nio.charset.Charset charset)
token
- The token that will be base64 encoded by this method (must not be null).charset
- The charset to be used for the string encoding (must not be null).public java.util.List<GeneralName> getSubjectAlternativeNamesFrom(java.security.cert.X509Certificate serverCertificate)
public java.util.Collection<java.security.cert.X509Certificate> readX509CertificatesFromPKCS7(java.io.InputStream inStream) throws java.security.cert.CertificateException
inStream
- A stream that is expected to contain X.509 certificates in PKCS#7 format.java.security.cert.CertificateException
- For any case of format or IO errors.public java.security.cert.X509Certificate readX509CertificateFromPKCS7(java.io.InputStream inStream) throws java.security.cert.CertificateException
inStream
- A stream that is expected to contain X.509 certificates in PKCS#7 format.java.security.cert.CertificateException
- For any case of format or IO errors.public java.security.cert.X509Certificate readX509CertificateFromPKCS7(java.io.File file) throws java.security.cert.CertificateException
file
- A file that is expected to contain X.509 certificates in PKCS#7 format.java.security.cert.CertificateException
- For any case of format or IO errors.public java.security.cert.X509Certificate[] readX509CertificateChainFromPEM(java.io.File pemFile)
pemFile
- The file to read from (must not be null).