Class ProxyDigestAuthenticator
java.lang.Object
org.glassfish.jersey.jdk.connector.internal.ProxyDigestAuthenticator
Generates a value of
Authorization
header of HTTP request for Digest Http Authentication scheme (RFC 2617).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
(package private) final class
Digest scheme POJOprivate static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Charset
Encoding used for authentication calculations.private static final int
private static final char[]
private static final Pattern
private static final Logger
private SecureRandom
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
append
(StringBuilder sb, String key, String value) Append comma separated key=value token.private static void
append
(StringBuilder sb, String key, String value, boolean useQuote) Append comma separated key=value tokenprivate static String
bytesToHex
(byte[] bytes) Convert bytes array to hex string.private String
createNextAuthToken
(ProxyDigestAuthenticator.DigestScheme ds, String uri, String method, String userName, String password) Creates digest string including counter.(package private) String
generateAuthorizationHeader
(URI uri, String method, String authenticateHeader, String userName, String password) private static String
Colon separated value MD5 hash.parseAuthHeaders
(String authHeader) Parse digest header.private String
randomBytes
(int nbBytes) Generate a random sequence of bytes and return its hex representation
-
Field Details
-
CHARACTER_SET
Encoding used for authentication calculations. -
logger
-
HEX_ARRAY
private static final char[] HEX_ARRAY -
KEY_VALUE_PAIR_PATTERN
-
CLIENT_NONCE_BYTE_COUNT
private static final int CLIENT_NONCE_BYTE_COUNT- See Also:
-
randomGenerator
-
-
Constructor Details
-
ProxyDigestAuthenticator
ProxyDigestAuthenticator()
-
-
Method Details
-
generateAuthorizationHeader
String generateAuthorizationHeader(URI uri, String method, String authenticateHeader, String userName, String password) throws ProxyAuthenticationException - Throws:
ProxyAuthenticationException
-
parseAuthHeaders
private ProxyDigestAuthenticator.DigestScheme parseAuthHeaders(String authHeader) throws IOException Parse digest header.- Parameters:
authHeader
- value ofWWW-Authenticate
header- Returns:
- DigestScheme or
null
if no digest header exists. - Throws:
IOException
-
createNextAuthToken
private String createNextAuthToken(ProxyDigestAuthenticator.DigestScheme ds, String uri, String method, String userName, String password) throws ProxyAuthenticationException Creates digest string including counter.- Parameters:
ds
- DigestScheme instanceuri
- client request uri- Returns:
- digest authentication token string
- Throws:
ProxyAuthenticationException
- if MD5 hash fails
-
append
Append comma separated key=value token- Parameters:
sb
- string builder instancekey
- key stringvalue
- value stringuseQuote
- true if value needs to be enclosed in quotes
-
append
Append comma separated key=value token. The value gets enclosed in quotes.- Parameters:
sb
- string builder instancekey
- key stringvalue
- value string
-
bytesToHex
Convert bytes array to hex string.- Parameters:
bytes
- array of bytes- Returns:
- hex string
-
md5
Colon separated value MD5 hash.- Parameters:
tokens
- one or more strings- Returns:
- M5 hash string
- Throws:
ProxyAuthenticationException
- if MD5 algorithm cannot be instantiated
-
randomBytes
Generate a random sequence of bytes and return its hex representation- Parameters:
nbBytes
- number of bytes to generate- Returns:
- hex string
-