public static void encode(char[] string, org.wildfly.common.bytes.ByteStringBuilder target, long profile) { encode(new String(string), target, profile); }
if (isSet(profile, NORMALIZE_KC)) string = Normalizer.normalize(string, Normalizer.Form.NFKC); final int len = string.length(); boolean isRALString = false; if (isSet(profile, MAP_TO_NOTHING) && mapCodePointToNothing(cp)) continue; if (isSet(profile, MAP_TO_SPACE) && mapCodePointToSpace(cp)) { target.append(' '); continue; if (isSet(profile, MAP_SCRAM_LOGIN_CHARS) || isSet(profile, MAP_GS2_LOGIN_CHARS)) { if (cp == '=') { target.append('=').append('3').append('D'); else if (isSet(profile, UNMAP_SCRAM_LOGIN_CHARS) || isSet(profile, UNMAP_GS2_LOGIN_CHARS)) { if (cp == '=') { if (i + 1 >= len) { if (isSet(profile, FORBID_NON_ASCII_SPACES)) forbidNonAsciiSpaces(cp); if (isSet(profile, FORBID_ASCII_CONTROL)) forbidAsciiControl(cp); if (isSet(profile, FORBID_NON_ASCII_CONTROL)) forbidNonAsciiControl(cp); if (isSet(profile, FORBID_PRIVATE_USE)) forbidPrivateUse(cp); if (isSet(profile, FORBID_NON_CHARACTER)) forbidNonCharacter(cp); if (isSet(profile, FORBID_SURROGATE)) forbidSurrogate(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT)) forbidInappropriateForPlainText(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_CANON_REP)) forbidInappropriateForCanonicalRepresentation(cp); if (isSet(profile, FORBID_CHANGE_DISPLAY_AND_DEPRECATED)) forbidChangeDisplayPropertiesOrDeprecated(cp); if (isSet(profile, FORBID_TAGGING)) forbidTagging(cp); if (isSet(profile, FORBID_UNASSIGNED)) forbidUnassigned(cp);
if (isSet(profile, NORMALIZE_KC)) string = Normalizer.normalize(string, Normalizer.Form.NFKC); final int len = string.length(); boolean isRALString = false; if (isSet(profile, MAP_TO_NOTHING) && mapCodePointToNothing(cp)) continue; if (isSet(profile, MAP_TO_SPACE) && mapCodePointToSpace(cp)) { target.append(' '); continue; if (isSet(profile, MAP_SCRAM_LOGIN_CHARS) || isSet(profile, MAP_GS2_LOGIN_CHARS)) { if (cp == '=') { target.append('=').append('3').append('D'); else if (isSet(profile, UNMAP_SCRAM_LOGIN_CHARS) || isSet(profile, UNMAP_GS2_LOGIN_CHARS)) { if (cp == '=') { if (i + 1 >= len) { if (isSet(profile, FORBID_NON_ASCII_SPACES)) forbidNonAsciiSpaces(cp); if (isSet(profile, FORBID_ASCII_CONTROL)) forbidAsciiControl(cp); if (isSet(profile, FORBID_NON_ASCII_CONTROL)) forbidNonAsciiControl(cp); if (isSet(profile, FORBID_PRIVATE_USE)) forbidPrivateUse(cp); if (isSet(profile, FORBID_NON_CHARACTER)) forbidNonCharacter(cp); if (isSet(profile, FORBID_SURROGATE)) forbidSurrogate(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT)) forbidInappropriateForPlainText(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_CANON_REP)) forbidInappropriateForCanonicalRepresentation(cp); if (isSet(profile, FORBID_CHANGE_DISPLAY_AND_DEPRECATED)) forbidChangeDisplayPropertiesOrDeprecated(cp); if (isSet(profile, FORBID_TAGGING)) forbidTagging(cp); if (isSet(profile, FORBID_UNASSIGNED)) forbidUnassigned(cp);
@Deprecated public static void encode(char[] string, ByteStringBuilder target, long profile) { encode(new String(string), target, profile); }
if (isSet(profile, NORMALIZE_KC)) string = Normalizer.normalize(string, Normalizer.Form.NFKC); final int len = string.length(); boolean isRALString = false; if (isSet(profile, MAP_TO_NOTHING) && mapCodePointToNothing(cp)) continue; if (isSet(profile, MAP_TO_SPACE) && mapCodePointToSpace(cp)) { target.append(' '); continue; if (isSet(profile, MAP_SCRAM_LOGIN_CHARS) || isSet(profile, MAP_GS2_LOGIN_CHARS)) { if (cp == '=') { target.append('=').append('3').append('D'); else if (isSet(profile, UNMAP_SCRAM_LOGIN_CHARS) || isSet(profile, UNMAP_GS2_LOGIN_CHARS)) { if (cp == '=') { if (i + 1 >= len) { if (isSet(profile, FORBID_NON_ASCII_SPACES)) forbidNonAsciiSpaces(cp); if (isSet(profile, FORBID_ASCII_CONTROL)) forbidAsciiControl(cp); if (isSet(profile, FORBID_NON_ASCII_CONTROL)) forbidNonAsciiControl(cp); if (isSet(profile, FORBID_PRIVATE_USE)) forbidPrivateUse(cp); if (isSet(profile, FORBID_NON_CHARACTER)) forbidNonCharacter(cp); if (isSet(profile, FORBID_SURROGATE)) forbidSurrogate(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT)) forbidInappropriateForPlainText(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_CANON_REP)) forbidInappropriateForCanonicalRepresentation(cp); if (isSet(profile, FORBID_CHANGE_DISPLAY_AND_DEPRECATED)) forbidChangeDisplayPropertiesOrDeprecated(cp); if (isSet(profile, FORBID_TAGGING)) forbidTagging(cp); if (isSet(profile, FORBID_UNASSIGNED)) forbidUnassigned(cp);
private String getPasswordFromPasswordChars(char[] passwordChars) { final ByteStringBuilder b = new ByteStringBuilder(); StringPrep.encode(passwordChars, b, StringPrep.PROFILE_SASL_STORED); Arrays.fill(passwordChars, (char) 0); // Wipe out the password return new String(b.toArray(), StandardCharsets.UTF_8); }
if (isSet(profile, NORMALIZE_KC)) string = Normalizer.normalize(string, Normalizer.Form.NFKC); final int len = string.length(); boolean isRALString = false; if (isSet(profile, MAP_TO_NOTHING) && mapCodePointToNothing(cp)) continue; if (isSet(profile, MAP_TO_SPACE) && mapCodePointToSpace(cp)) { target.append(' '); continue; if (isSet(profile, MAP_SCRAM_LOGIN_CHARS) || isSet(profile, MAP_GS2_LOGIN_CHARS)) { if (cp == '=') { target.append('=').append('3').append('D'); else if (isSet(profile, UNMAP_SCRAM_LOGIN_CHARS) || isSet(profile, UNMAP_GS2_LOGIN_CHARS)) { if (cp == '=') { if (i + 1 >= len) { if (isSet(profile, FORBID_NON_ASCII_SPACES)) forbidNonAsciiSpaces(cp); if (isSet(profile, FORBID_ASCII_CONTROL)) forbidAsciiControl(cp); if (isSet(profile, FORBID_NON_ASCII_CONTROL)) forbidNonAsciiControl(cp); if (isSet(profile, FORBID_PRIVATE_USE)) forbidPrivateUse(cp); if (isSet(profile, FORBID_NON_CHARACTER)) forbidNonCharacter(cp); if (isSet(profile, FORBID_SURROGATE)) forbidSurrogate(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT)) forbidInappropriateForPlainText(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_CANON_REP)) forbidInappropriateForCanonicalRepresentation(cp); if (isSet(profile, FORBID_CHANGE_DISPLAY_AND_DEPRECATED)) forbidChangeDisplayPropertiesOrDeprecated(cp); if (isSet(profile, FORBID_TAGGING)) forbidTagging(cp); if (isSet(profile, FORBID_UNASSIGNED)) forbidUnassigned(cp);
final ByteStringBuilder b = new ByteStringBuilder(); if (authorizationId != null) { StringPrep.encode(authorizationId, b, StringPrep.PROFILE_SASL_STORED); StringPrep.encode(name, b, StringPrep.PROFILE_SASL_STORED); b.append((byte) 0); StringPrep.encode(password, b, StringPrep.PROFILE_SASL_STORED); return b.toArray(); } catch (IllegalArgumentException ex) {
if (isSet(profile, NORMALIZE_KC)) string = Normalizer.normalize(string, Normalizer.Form.NFKC); final int len = string.length(); boolean isRALString = false; if (isSet(profile, MAP_TO_NOTHING) && mapCodePointToNothing(cp)) continue; if (isSet(profile, MAP_TO_SPACE) && mapCodePointToSpace(cp)) { target.append(' '); continue; if (isSet(profile, MAP_SCRAM_LOGIN_CHARS) || isSet(profile, MAP_GS2_LOGIN_CHARS)) { if (cp == '=') { target.append('=').append('3').append('D'); else if (isSet(profile, UNMAP_SCRAM_LOGIN_CHARS) || isSet(profile, UNMAP_GS2_LOGIN_CHARS)) { if (cp == '=') { if (i + 1 >= len) { if (isSet(profile, FORBID_NON_ASCII_SPACES)) forbidNonAsciiSpaces(cp); if (isSet(profile, FORBID_ASCII_CONTROL)) forbidAsciiControl(cp); if (isSet(profile, FORBID_NON_ASCII_CONTROL)) forbidNonAsciiControl(cp); if (isSet(profile, FORBID_PRIVATE_USE)) forbidPrivateUse(cp); if (isSet(profile, FORBID_NON_CHARACTER)) forbidNonCharacter(cp); if (isSet(profile, FORBID_SURROGATE)) forbidSurrogate(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT)) forbidInappropriateForPlainText(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_CANON_REP)) forbidInappropriateForCanonicalRepresentation(cp); if (isSet(profile, FORBID_CHANGE_DISPLAY_AND_DEPRECATED)) forbidChangeDisplayPropertiesOrDeprecated(cp); if (isSet(profile, FORBID_TAGGING)) forbidTagging(cp); if (isSet(profile, FORBID_UNASSIGNED)) forbidUnassigned(cp);
StringPrep.encode(name, b, 0 | StringPrep.MAP_TO_NOTHING | StringPrep.MAP_TO_SPACE
if (isSet(profile, NORMALIZE_KC)) string = Normalizer.normalize(string, Normalizer.Form.NFKC); final int len = string.length(); boolean isRALString = false; if (isSet(profile, MAP_TO_NOTHING) && mapCodePointToNothing(cp)) continue; if (isSet(profile, MAP_TO_SPACE) && mapCodePointToSpace(cp)) { target.append(' '); continue; if (isSet(profile, MAP_SCRAM_LOGIN_CHARS) || isSet(profile, MAP_GS2_LOGIN_CHARS)) { if (cp == '=') { target.append('=').append('3').append('D'); else if (isSet(profile, UNMAP_SCRAM_LOGIN_CHARS) || isSet(profile, UNMAP_GS2_LOGIN_CHARS)) { if (cp == '=') { if (i + 1 >= len) { if (isSet(profile, FORBID_NON_ASCII_SPACES)) forbidNonAsciiSpaces(cp); if (isSet(profile, FORBID_ASCII_CONTROL)) forbidAsciiControl(cp); if (isSet(profile, FORBID_NON_ASCII_CONTROL)) forbidNonAsciiControl(cp); if (isSet(profile, FORBID_PRIVATE_USE)) forbidPrivateUse(cp); if (isSet(profile, FORBID_NON_CHARACTER)) forbidNonCharacter(cp); if (isSet(profile, FORBID_SURROGATE)) forbidSurrogate(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT)) forbidInappropriateForPlainText(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_CANON_REP)) forbidInappropriateForCanonicalRepresentation(cp); if (isSet(profile, FORBID_CHANGE_DISPLAY_AND_DEPRECATED)) forbidChangeDisplayPropertiesOrDeprecated(cp); if (isSet(profile, FORBID_TAGGING)) forbidTagging(cp); if (isSet(profile, FORBID_UNASSIGNED)) forbidUnassigned(cp);
StringPrep.encode(authorizationId, encoded, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_SCRAM_LOGIN_CHARS); StringPrep.encode(name, encoded, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_SCRAM_LOGIN_CHARS); encoded.append(',').append('r').append('='); final byte[] nonce = ScramUtil.generateNonce(48, getRandom());
if (isSet(profile, NORMALIZE_KC)) string = Normalizer.normalize(string, Normalizer.Form.NFKC); final int len = string.length(); boolean isRALString = false; if (isSet(profile, MAP_TO_NOTHING) && mapCodePointToNothing(cp)) continue; if (isSet(profile, MAP_TO_SPACE) && mapCodePointToSpace(cp)) { target.append(' '); continue; if (isSet(profile, MAP_SCRAM_LOGIN_CHARS) || isSet(profile, MAP_GS2_LOGIN_CHARS)) { if (cp == '=') { target.append('=').append('3').append('D'); else if (isSet(profile, UNMAP_SCRAM_LOGIN_CHARS) || isSet(profile, UNMAP_GS2_LOGIN_CHARS)) { if (cp == '=') { if (i + 1 >= len) { if (isSet(profile, FORBID_NON_ASCII_SPACES)) forbidNonAsciiSpaces(cp); if (isSet(profile, FORBID_ASCII_CONTROL)) forbidAsciiControl(cp); if (isSet(profile, FORBID_NON_ASCII_CONTROL)) forbidNonAsciiControl(cp); if (isSet(profile, FORBID_PRIVATE_USE)) forbidPrivateUse(cp); if (isSet(profile, FORBID_NON_CHARACTER)) forbidNonCharacter(cp); if (isSet(profile, FORBID_SURROGATE)) forbidSurrogate(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT)) forbidInappropriateForPlainText(cp); if (isSet(profile, FORBID_INAPPROPRIATE_FOR_CANON_REP)) forbidInappropriateForCanonicalRepresentation(cp); if (isSet(profile, FORBID_CHANGE_DISPLAY_AND_DEPRECATED)) forbidChangeDisplayPropertiesOrDeprecated(cp); if (isSet(profile, FORBID_TAGGING)) forbidTagging(cp); if (isSet(profile, FORBID_UNASSIGNED)) forbidUnassigned(cp);
} else { ByteStringBuilder bsb = new ByteStringBuilder(); StringPrep.encode(authorizationID, bsb, StringPrep.PROFILE_SASL_QUERY | StringPrep.UNMAP_SCRAM_LOGIN_CHARS); authorizationID = new String(bsb.toArray(), StandardCharsets.UTF_8);
if (authorizationId != null) { header.append("a="); StringPrep.encode(authorizationId, header, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_GS2_LOGIN_CHARS);
public OAuth2InitialClientMessage getInitialResponse() throws AuthenticationMechanismException { final CredentialCallback credentialCallback = new CredentialCallback(BearerTokenCredential.class); try { MechanismUtil.handleCallbacks(log, this.callbackHandler, credentialCallback); } catch (UnsupportedCallbackException e) { throw log.mechCallbackHandlerUnsupportedCallback(e); } assertTrue(credentialCallback.isCredentialTypeSupported(BearerTokenCredential.class)); final String token = credentialCallback.applyToCredential(BearerTokenCredential.class, BearerTokenCredential::getToken); if (token == null) { throw log.mechNoTokenGiven(); } final ByteStringBuilder encoded = new ByteStringBuilder(); encoded.append("n").append(","); if (this.authorizationId != null) { encoded.append('a').append('='); StringPrep.encode(this.authorizationId, encoded, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_SCRAM_LOGIN_CHARS); } encoded.append(",").append(KV_DELIMITER).append("auth").append("=").append("Bearer").append(" ").append(token).append(KV_DELIMITER); return new OAuth2InitialClientMessage(null, null, encoded.toArray()); }
if (getAuthorizationId() != null) { b2.append("a="); StringPrep.encode(getAuthorizationId(), b2, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_SCRAM_LOGIN_CHARS); if (getAuthorizationId() != null) { b2.append("a="); StringPrep.encode(getAuthorizationId(), b2, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_SCRAM_LOGIN_CHARS);
StringPrep.encode(bi.delimitedBy(',').asUtf8String().drainToString(), bsb, StringPrep.PROFILE_SASL_QUERY | StringPrep.UNMAP_SCRAM_LOGIN_CHARS); authenticationName = new String(bsb.toArray(), StandardCharsets.UTF_8);
public static void encode(char[] string, org.wildfly.common.bytes.ByteStringBuilder target, long profile) { encode(new String(string), target, profile); }