io.undertow.util.HexConverter Java Examples
The following examples show how to use
io.undertow.util.HexConverter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DigestAuthTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
/** * Creates a response value from the supplied parameters. * * @return The generated Hex encoded MD5 digest based response. */ private String createResponse(final String userName, final String realm, final String password, final String method, final String uri, final String nonce) throws Exception { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(userName.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(realm.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(password.getBytes(UTF_8)); byte[] ha1 = HexConverter.convertToHexBytes(digest.digest()); digest.update(method.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(uri.getBytes(UTF_8)); byte[] ha2 = HexConverter.convertToHexBytes(digest.digest()); digest.update(ha1); digest.update((byte) ':'); digest.update(nonce.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(ha2); return HexConverter.convertToHexString(digest.digest()); }
Example #2
Source File: DigestAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 6 votes |
private byte[] createRFC2069RequestDigest(final byte[] ha1, final byte[] ha2, final DigestContext context) { final MessageDigest digest = context.getDigest(); final Map<DigestAuthorizationToken, String> parsedHeader = context.getParsedHeader(); byte[] nonce = parsedHeader.get(DigestAuthorizationToken.NONCE).getBytes(StandardCharsets.UTF_8); try { digest.update(ha1); digest.update(COLON); digest.update(nonce); digest.update(COLON); digest.update(ha2); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }
Example #3
Source File: DigestAuthentication2069TestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
/** * Creates a response value from the supplied parameters. * * @return The generated Hex encoded MD5 digest based response. */ private String createResponse(final String userName, final String realm, final String password, final String method, final String uri, final String nonce) throws Exception { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(userName.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(realm.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(password.getBytes(UTF_8)); byte[] ha1 = HexConverter.convertToHexBytes(digest.digest()); digest.update(method.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(uri.getBytes(UTF_8)); byte[] ha2 = HexConverter.convertToHexBytes(digest.digest()); digest.update(ha1); digest.update((byte) ':'); digest.update(nonce.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(ha2); return HexConverter.convertToHexString(digest.digest()); }
Example #4
Source File: DigestAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 6 votes |
private byte[] createRFC2069RequestDigest(final byte[] ha1, final byte[] ha2, final DigestContext context) { final MessageDigest digest = context.getDigest(); final Map<DigestAuthorizationToken, String> parsedHeader = context.getParsedHeader(); byte[] nonce = parsedHeader.get(DigestAuthorizationToken.NONCE).getBytes(StandardCharsets.UTF_8); try { digest.update(ha1); digest.update(COLON); digest.update(nonce); digest.update(COLON); digest.update(ha2); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }
Example #5
Source File: DigestAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 5 votes |
private byte[] createHA2Auth(final DigestContext context, Map<DigestAuthorizationToken, String> parsedHeader) { byte[] method = context.getMethod().getBytes(StandardCharsets.UTF_8); byte[] digestUri = parsedHeader.get(DigestAuthorizationToken.DIGEST_URI).getBytes(StandardCharsets.UTF_8); MessageDigest digest = context.getDigest(); try { digest.update(method); digest.update(COLON); digest.update(digestUri); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }
Example #6
Source File: DigestAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 5 votes |
private byte[] createRFC2617RequestDigest(final byte[] ha1, final byte[] ha2, final DigestContext context) { final MessageDigest digest = context.getDigest(); final Map<DigestAuthorizationToken, String> parsedHeader = context.getParsedHeader(); byte[] nonce = parsedHeader.get(DigestAuthorizationToken.NONCE).getBytes(StandardCharsets.UTF_8); byte[] nonceCount = parsedHeader.get(DigestAuthorizationToken.NONCE_COUNT).getBytes(StandardCharsets.UTF_8); byte[] cnonce = parsedHeader.get(DigestAuthorizationToken.CNONCE).getBytes(StandardCharsets.UTF_8); byte[] qop = parsedHeader.get(DigestAuthorizationToken.MESSAGE_QOP).getBytes(StandardCharsets.UTF_8); try { digest.update(ha1); digest.update(COLON); digest.update(nonce); digest.update(COLON); digest.update(nonceCount); digest.update(COLON); digest.update(cnonce); digest.update(COLON); digest.update(qop); digest.update(COLON); digest.update(ha2); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }
Example #7
Source File: DigestAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 5 votes |
private byte[] createHA2Auth(final DigestContext context) { byte[] digestUri = context.getParsedHeader().get(DigestAuthorizationToken.DIGEST_URI).getBytes(StandardCharsets.UTF_8); MessageDigest digest = context.getDigest(); try { digest.update(COLON); digest.update(digestUri); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }
Example #8
Source File: DigestAuthenticationAuthTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
private static String createNonce() { // This if just for testing so we are not concerned with how securely the client side nonce is. Random rand = new Random(); byte[] nonceBytes = new byte[32]; rand.nextBytes(nonceBytes); return HexConverter.convertToHexString(nonceBytes); }
Example #9
Source File: DigestAuthenticationAuthTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
/** * Creates a response value from the supplied parameters. * * @return The generated Hex encoded MD5 digest based response. */ private static String createResponse(final String userName, final String realm, final String password, final String method, final String uri, final String nonce, final String nonceCount, final String cnonce) throws Exception { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(userName.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(realm.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(password.getBytes(UTF_8)); byte[] ha1 = HexConverter.convertToHexBytes(digest.digest()); digest.update(method.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(uri.getBytes(UTF_8)); byte[] ha2 = HexConverter.convertToHexBytes(digest.digest()); digest.update(ha1); digest.update((byte) ':'); digest.update(nonce.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(nonceCount.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(cnonce.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(DigestQop.AUTH.getToken().getBytes(UTF_8)); digest.update((byte) ':'); digest.update(ha2); return HexConverter.convertToHexString(digest.digest()); }
Example #10
Source File: DigestAuthenticationAuthTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
private static String createRspAuth(final String userName, final String realm, final String password, final String uri, final String nonce, final String nonceCount, final String cnonce) throws Exception { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(userName.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(realm.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(password.getBytes(UTF_8)); byte[] ha1 = HexConverter.convertToHexBytes(digest.digest()); digest.update((byte) ':'); digest.update(uri.getBytes(UTF_8)); byte[] ha2 = HexConverter.convertToHexBytes(digest.digest()); digest.update(ha1); digest.update((byte) ':'); digest.update(nonce.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(nonceCount.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(cnonce.getBytes(UTF_8)); digest.update((byte) ':'); digest.update(DigestQop.AUTH.getToken().getBytes(UTF_8)); digest.update((byte) ':'); digest.update(ha2); return HexConverter.convertToHexString(digest.digest()); }
Example #11
Source File: DigestAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 5 votes |
private byte[] createHA2Auth(final DigestContext context, Map<DigestAuthorizationToken, String> parsedHeader) { byte[] method = context.getMethod().getBytes(StandardCharsets.UTF_8); byte[] digestUri = parsedHeader.get(DigestAuthorizationToken.DIGEST_URI).getBytes(StandardCharsets.UTF_8); MessageDigest digest = context.getDigest(); try { digest.update(method); digest.update(COLON); digest.update(digestUri); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }
Example #12
Source File: DigestAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 5 votes |
private byte[] createRFC2617RequestDigest(final byte[] ha1, final byte[] ha2, final DigestContext context) { final MessageDigest digest = context.getDigest(); final Map<DigestAuthorizationToken, String> parsedHeader = context.getParsedHeader(); byte[] nonce = parsedHeader.get(DigestAuthorizationToken.NONCE).getBytes(StandardCharsets.UTF_8); byte[] nonceCount = parsedHeader.get(DigestAuthorizationToken.NONCE_COUNT).getBytes(StandardCharsets.UTF_8); byte[] cnonce = parsedHeader.get(DigestAuthorizationToken.CNONCE).getBytes(StandardCharsets.UTF_8); byte[] qop = parsedHeader.get(DigestAuthorizationToken.MESSAGE_QOP).getBytes(StandardCharsets.UTF_8); try { digest.update(ha1); digest.update(COLON); digest.update(nonce); digest.update(COLON); digest.update(nonceCount); digest.update(COLON); digest.update(cnonce); digest.update(COLON); digest.update(qop); digest.update(COLON); digest.update(ha2); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }
Example #13
Source File: DigestAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 5 votes |
private byte[] createHA2Auth(final DigestContext context) { byte[] digestUri = context.getParsedHeader().get(DigestAuthorizationToken.DIGEST_URI).getBytes(StandardCharsets.UTF_8); MessageDigest digest = context.getDigest(); try { digest.update(COLON); digest.update(digestUri); return HexConverter.convertToHexBytes(digest.digest()); } finally { digest.reset(); } }