private static byte[] decodeColumn(String string, Encoding encoding) { switch (encoding) { case BASE64: return CodePointIterator.ofString(string).base64Decode(Base64Alphabet.STANDARD, false).drain(); case HEX: return CodePointIterator.ofString(string).hexDecode().drain(); } throw new IllegalStateException(); }
/** * Convert the given hexadecimal OTP value into a hash. * * @param otp the OTP in hexadecimal format * @return the OTP hash that corresponds to the given hexadecimal value * @throws SaslException if an error occurs while parsing the hexadecimal value */ public static byte[] convertFromHex(String otp) throws SaslException { final CodePointIterator cpi = CodePointIterator.ofString(otp); final CodePointIterator di = cpi.delimitedBy(DELIMS); // Remove any white space final StringBuilder sb = new StringBuilder(); while (di.hasNext()) { di.drainTo(sb); skipDelims(di, cpi); } return CodePointIterator.ofString(sb.toString()).hexDecode().drain(); }
byte[] hashed = ByteIterator.ofBytes(accountEntry.getPasswordRepresentation().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(accountEntry.getName(), loadedState.getRealmName(), hashed);
passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); try { byte[] hashed = ByteIterator.ofBytes(accountEntry.getPasswordRepresentation().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(accountEntry.getName(), loadedState.getRealmName(), hashed); } catch (DecodeException e) {
response = ByteIterator.ofBytes(responseTokens.get(RESPONSE)).asUtf8String().hexDecode().drain(); } else { throw httpDigest.mechMissingDirective(RESPONSE);
private static byte[] decodeColumn(String string, Encoding encoding) { switch (encoding) { case BASE64: return CodePointIterator.ofString(string).base64Decode(Base64Alphabet.STANDARD, false).drain(); case HEX: return CodePointIterator.ofString(string).hexDecode().drain(); } throw new IllegalStateException(); }
private static byte[] decodeColumn(String string, Encoding encoding) { switch (encoding) { case BASE64: return CodePointIterator.ofString(string).base64Decode(Base64Alphabet.STANDARD, false).drain(); case HEX: return CodePointIterator.ofString(string).hexDecode().drain(); } throw new IllegalStateException(); }
private static byte[] decodeColumn(String string, Encoding encoding) { switch (encoding) { case BASE64: return CodePointIterator.ofString(string).base64Decode(Base64Alphabet.STANDARD, false).drain(); case HEX: return CodePointIterator.ofString(string).hexDecode().drain(); } throw new IllegalStateException(); }
passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), algorithmParameterSpec); } else { byte[] hashed = ByteIterator.ofBytes(password.getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(principal.getName(), realm, hashed);
@Override public boolean verifyEvidence(Evidence evidence) throws RealmUnavailableException { if (password == null || evidence instanceof PasswordGuessEvidence == false) { return false; } final char[] guess = ((PasswordGuessEvidence) evidence).getGuess(); final PasswordFactory passwordFactory; final PasswordSpec passwordSpec; final Password actualPassword; if (plainText) { passwordFactory = getPasswordFactory(ALGORITHM_CLEAR); passwordSpec = new ClearPasswordSpec(password.toCharArray()); } else { passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); byte[] hashed = ByteIterator.ofBytes(password.getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(principal.getName(), realm, hashed); } try { actualPassword = passwordFactory.generatePassword(passwordSpec); return passwordFactory.verify(actualPassword, guess); } catch (InvalidKeySpecException | InvalidKeyException | IllegalStateException e) { throw new IllegalStateException(e); } }
/** * Convert the given hexadecimal OTP value into a hash. * * @param otp the OTP in hexadecimal format * @return the OTP hash that corresponds to the given hexadecimal value * @throws SaslException if an error occurs while parsing the hexadecimal value */ public static byte[] convertFromHex(String otp) throws SaslException { final CodePointIterator cpi = CodePointIterator.ofString(otp); final CodePointIterator di = cpi.delimitedBy(DELIMS); // Remove any white space final StringBuilder sb = new StringBuilder(); while (di.hasNext()) { di.drainTo(sb); skipDelims(di, cpi); } return CodePointIterator.ofString(sb.toString()).hexDecode().drain(); }
@Override public boolean verifyEvidence(Evidence evidence) throws RealmUnavailableException { if (password == null || evidence instanceof PasswordGuessEvidence == false) { return false; } final char[] guess = ((PasswordGuessEvidence) evidence).getGuess(); final PasswordFactory passwordFactory; final PasswordSpec passwordSpec; final Password actualPassword; if (plainText) { passwordFactory = getPasswordFactory(ALGORITHM_CLEAR); passwordSpec = new ClearPasswordSpec(password.toCharArray()); } else { passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); byte[] hashed = ByteIterator.ofBytes(password.getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(principal.getName(), realm, hashed); } try { actualPassword = passwordFactory.generatePassword(passwordSpec); return passwordFactory.verify(actualPassword, guess); } catch (InvalidKeySpecException | InvalidKeyException | IllegalStateException e) { throw new IllegalStateException(e); } }
/** * Convert the given hexadecimal OTP value into a hash. * * @param otp the OTP in hexadecimal format * @return the OTP hash that corresponds to the given hexadecimal value * @throws SaslException if an error occurs while parsing the hexadecimal value */ public static byte[] convertFromHex(String otp) throws SaslException { final CodePointIterator cpi = CodePointIterator.ofString(otp); final CodePointIterator di = cpi.delimitedBy(DELIMS); // Remove any white space final StringBuilder sb = new StringBuilder(); while (di.hasNext()) { di.drainTo(sb); skipDelims(di, cpi); } return CodePointIterator.ofString(sb.toString()).hexDecode().drain(); }
@Override public boolean hasChild(PathElement element) { SSLContext sslContext; if (ElytronDescriptionConstants.SSL_SESSION.equals(element.getKey()) && (sslContext = getSSLContext(sslContextServiceController)) != null) { byte[] sessionId = ByteIterator.ofBytes(element.getValue().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); SSLSessionContext sslSessionContext = server ? sslContext.getServerSessionContext() : sslContext.getClientSessionContext(); return sslSessionContext.getSession(sessionId) != null; } return false; }
/** * Convert the given hexadecimal OTP value into a hash. * * @param otp the OTP in hexadecimal format * @return the OTP hash that corresponds to the given hexadecimal value * @throws SaslException if an error occurs while parsing the hexadecimal value */ public static byte[] convertFromHex(String otp) throws SaslException { final CodePointIterator cpi = CodePointIterator.ofString(otp); final CodePointIterator di = cpi.delimitedBy(DELIMS); // Remove any white space final StringBuilder sb = new StringBuilder(); while (di.hasNext()) { di.drainTo(sb); skipDelims(di, cpi); } return CodePointIterator.ofString(sb.toString()).hexDecode().drain(); }
private static byte[] sessionId(ModelNode operation) { PathAddress pa = PathAddress.pathAddress(operation.require(OP_ADDR)); for (int i = pa.size() - 1; i > 0; i--) { PathElement pe = pa.getElement(i); if (ElytronDescriptionConstants.SSL_SESSION.equals(pe.getKey())) { return ByteIterator.ofBytes(pe.getValue().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); } } throw ROOT_LOGGER.operationAddressMissingKey(ElytronDescriptionConstants.SSL_SESSION); } }
byte[] hashed = ByteIterator.ofBytes(accountEntry.getPasswordRepresentation().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(accountEntry.getName(), loadedState.getRealmName(), hashed);
passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); try { byte[] hashed = ByteIterator.ofBytes(accountEntry.getPasswordRepresentation().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(accountEntry.getName(), loadedState.getRealmName(), hashed); } catch (DecodeException e) {
passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); try { byte[] hashed = ByteIterator.ofBytes(accountEntry.getPasswordRepresentation().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(accountEntry.getName(), loadedState.getRealmName(), hashed); } catch (DecodeException e) {
passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); try { byte[] hashed = ByteIterator.ofBytes(accountEntry.getPasswordRepresentation().getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain(); passwordSpec = new DigestPasswordSpec(accountEntry.getName(), loadedState.getRealmName(), hashed); } catch (DecodeException e) {