|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.security.SecurityUtil
public class SecurityUtil
This singleton supports utility methods around various security aspects. It has a protected default constructor, so it can be extended!
Field Summary | |
---|---|
static String |
AUTHENTICATION_SCHEME_BASIC
|
static String |
AUTHENTICATION_SCHEME_BEARER
|
static String |
AUTHENTICATION_SCHEME_DIGEST
|
static String |
BASIC_CREDENTIALS_SEPARATOR
|
Method Summary | |
---|---|
String |
createBASICAuthorization(String username,
String password)
Creates the full authorization header value for the HTTP BASIC authentication scheme as defined in RFC-2617. |
String |
createBEARERAuthorization(byte[] token)
Creates the full authorization header value for the BEARER authentication scheme as defined in RFC-6750. |
String |
createBEARERAuthorization(String token,
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") |
org.pf.bif.text.IStringPair |
decodeBASICCredentials(String basicCredentials)
Decodes and splits up the value presented by a BASIC authentication header as to RFC-2617. |
org.pf.bif.text.IStringPair |
decodeBASICCredentials(String basicCredentials,
Charset charset)
Decodes and splits up the value presented by a BASIC authentication header as to RFC-2617. |
String |
encodeBASICCredentials(String username,
String password)
Encodes the given username and password according to the BASIC authentication scheme specification (RFC-2617). |
String |
encodeBASICCredentials(String username,
String password,
Charset charset)
Encodes the given username and password according to the BASIC authentication scheme specification (RFC-2617). |
X509Certificate |
readX509CertificateFromPKCS7(File file)
Reads a certificate from the given PKCS#7 file. |
X509Certificate |
readX509CertificateFromPKCS7(InputStream inStream)
Reads a certificate from the given PKCS#7 stream. |
Collection<X509Certificate> |
readX509CertificatesFromPKCS7(InputStream inStream)
Read all certificates from the given PKCS#7 stream. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String BASIC_CREDENTIALS_SEPARATOR
public static final String AUTHENTICATION_SCHEME_BASIC
public static final String AUTHENTICATION_SCHEME_DIGEST
public static final String AUTHENTICATION_SCHEME_BEARER
Method Detail |
---|
public static SecurityUtil current()
public String encodeBASICCredentials(String username, String password)
username
- The username (must not be null).password
- The password (must not be null)
public String encodeBASICCredentials(String username, String password, 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 org.pf.bif.text.IStringPair decodeBASICCredentials(String basicCredentials, 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).
IllegalArgumentException
- If the given string cannot be decoded or cannot be split into two sub-values.public org.pf.bif.text.IStringPair decodeBASICCredentials(String basicCredentials)
basicCredentials
- The base64 encoded concatenated username password string (must not be null).
IllegalArgumentException
- If the given string cannot be decoded or cannot be split into two sub-values.public String createBASICAuthorization(String username, String password)
username
- The username (must not be null).password
- The password (must not be null)
public String createBEARERAuthorization(byte[] token)
token
- The token that will be base64 encoded by this method (must not be null).
public String createBEARERAuthorization(String token, 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 Collection<X509Certificate> readX509CertificatesFromPKCS7(InputStream inStream) throws CertificateException
inStream
- A stream that is expected to contain X.509 certificates in PKCS#7 format.
CertificateException
- For any case of format or IO errors.public X509Certificate readX509CertificateFromPKCS7(InputStream inStream) throws CertificateException
inStream
- A stream that is expected to contain X.509 certificates in PKCS#7 format.
CertificateException
- For any case of format or IO errors.public X509Certificate readX509CertificateFromPKCS7(File file) throws CertificateException
file
- A file that is expected to contain X.509 certificates in PKCS#7 format.
CertificateException
- For any case of format or IO errors.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |