String tmp2=encode(md5Helper.digest(EncodingUtils.getBytes(a1, charset))); StringBuilder tmp3 = new StringBuilder(tmp2.length() + nonce.length() + cnonce.length() + 2); tmp3.append(tmp2); throw new AuthenticationException("Unhandled algorithm " + algorithm + " requested"); String md5a1 = encode(md5Helper.digest(EncodingUtils.getBytes(a1, charset)));
EncodingUtils.getBytes(tmp.toString(), charset));
/** * Gets the content in bytes. Bytes are lazily created to allow the charset to be changed * after the part is created. * * @return the content in bytes */ private byte[] getContent() { if (content == null) { content = EncodingUtils.getBytes(value, getCharSet()); } return content; }
/** * Escape and encode a given string with allowed characters not to be * escaped and a given charset. * * @param unescaped a string * @param allowed allowed characters not to be escaped * @param charset the charset * @return the escaped string */ public static String encode(String unescaped, BitSet allowed, String charset) throws UriException { byte[] rawdata = URLCodec.encodeUrl(allowed, EncodingUtils.getBytes(unescaped, charset)); return EncodingUtils.getAsciiString(rawdata); }
@Override public String processResponse(int httpResponseCode, String proxyServerResponse) throws ProxyAuthenticationException { StringBuilder proxyAuthorizationValue = new StringBuilder(); String credentails = String.format("%s:%s", _proxyAuthenticator.getCredentials().get(CredentialName.USERNAME), _proxyAuthenticator.getCredentials().get(CredentialName.PASSWORD)); credentails = EncodingUtils.getAsciiString(Base64.encodeBase64(EncodingUtils.getBytes(credentails, DEFAULT_CHARSET))); validateCredentials(); // throws an exception if invalid if (httpResponseCode == 407) { proxyAuthorizationValue.append(PROXY_AUTHORIZATION_PREFIX); } else { proxyAuthorizationValue.append(AUTHORIZATION_PREFIX); } proxyAuthorizationValue.append(BASIC_RESPONSE_PREFIX); proxyAuthorizationValue.append(credentails); proxyAuthorizationValue.append(EOL); return proxyAuthorizationValue.toString(); }
/** Constructor to use when message contents are known */ NTLMMessage(String messageBody, int expectedType) throws NTLMEngineException { messageContents = Base64.decodeBase64(EncodingUtils.getBytes(messageBody, DEFAULT_CHARSET)); // Look for NTLM message if (messageContents.length < SIGNATURE.length) throw new NTLMEngineException("NTLM message decoding error - packet too short"); int i = 0; while (i < SIGNATURE.length) { if (messageContents[i] != SIGNATURE[i]) throw new NTLMEngineException("NTLM message expected - instead got unrecognized bytes"); i++; } // Check to be sure there's a type 2 message indicator next int type = readULong(SIGNATURE.length); if (type != expectedType) throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType) + " message expected - instead got type " + Integer.toString(type)); currentOutputPosition = messageContents.length; }
/** Constructor to use when message contents are known */ NTLMMessage(final String messageBody, final int expectedType) throws NTLMEngineException { messageContents = Base64.decode(EncodingUtils.getBytes(messageBody, DEFAULT_CHARSET), Base64.NO_WRAP); // Look for NTLM message if (messageContents.length < SIGNATURE.length) { throw new NTLMEngineException("NTLM message decoding error - packet too short"); } int i = 0; while (i < SIGNATURE.length) { if (messageContents[i] != SIGNATURE[i]) { throw new NTLMEngineException( "NTLM message expected - instead got unrecognized bytes"); } i++; } // Check to be sure there's a type 2 message indicator next final int type = readULong(SIGNATURE.length); if (type != expectedType) { throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType) + " message expected - instead got type " + Integer.toString(type)); } currentOutputPosition = messageContents.length; }
/** Constructor to use when message contents are known */ NTLMMessage(final String messageBody, final int expectedType) throws NTLMEngineException { messageContents = Base64.decodeBase64(EncodingUtils.getBytes(messageBody, DEFAULT_CHARSET)); // Look for NTLM message if (messageContents.length < SIGNATURE.length) { throw new NTLMEngineException("NTLM message decoding error - packet too short"); } int i = 0; while (i < SIGNATURE.length) { if (messageContents[i] != SIGNATURE[i]) { throw new NTLMEngineException( "NTLM message expected - instead got unrecognized bytes"); } i++; } // Check to be sure there's a type 2 message indicator next final int type = readULong(SIGNATURE.length); if (type != expectedType) { throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType) + " message expected - instead got type " + Integer.toString(type)); } currentOutputPosition = messageContents.length; }
EncodingUtils.getBytes(tmp.toString(), charset));
EncodingUtils.getBytes(tmp.toString(), charset));
EncodingUtils.getBytes(tmp.toString(), charset), false);
EncodingUtils.getBytes(tmp.toString(), charset), false);
EncodingUtils.getBytes(tmp.toString(), charset), false);
EncodingUtils.getBytes(tmp.toString(), charset), false);
EncodingUtils.getBytes(tmp.toString(), charset), false);
EncodingUtils.getBytes(tmp.toString(), charset), false);
EncodingUtils.getBytes(tmp.toString(), charset), Base64.NO_WRAP);
EncodingUtils.getBytes(tmp.toString(), getCredentialsCharset(request)));
EncodingUtils.getBytes(tmp.toString(), getCredentialsCharset(request)));
EncodingUtils.getBytes(tmp.toString(), getCredentialsCharset(request)), Base64.NO_WRAP);