List of usage examples for org.apache.http.util EncodingUtils getAsciiBytes
public static byte[] getAsciiBytes(String str)
From source file:Main.java
public static ByteBuffer wrap(final String s) { return ByteBuffer.wrap(EncodingUtils.getAsciiBytes(s)); }
From source file:com.cloudbase.CBBasePart.java
private static void append(ByteArrayBuffer buf, String data) { append(buf, EncodingUtils.getAsciiBytes(data)); }
From source file:com.android.pwdhashandroid.sharp2java.HMACMD5.java
public HMACMD5(String key) throws GeneralSecurityException { init(EncodingUtils.getAsciiBytes(key)); }
From source file:com.appunite.websocket.WebSocketWriter.java
public void writeLine(String line) throws IOException { mOutputStream.write(EncodingUtils.getAsciiBytes(line)); writeNewLine(); }
From source file:com.strato.hidrive.api.utils.multipart.Boundary.java
Boundary(String boundary) { if (TextUtils.isEmpty(boundary)) { boundary = generateBoundary();/*from w ww. j ava2 s.c om*/ } this.boundary = boundary; final String starting = "--" + boundary + MultipartEntity.CRLF; //$NON-NLS-1$ final String closing = "--" + boundary + "--" + MultipartEntity.CRLF; //$NON-NLS-1$ startingBoundary = EncodingUtils.getAsciiBytes(starting); closingBoundary = EncodingUtils.getAsciiBytes(closing); }
From source file:com.cloudbase.CBBoundary.java
CBBoundary(String boundary) { if (TextUtils.isEmpty(boundary)) { boundary = generateBoundary();//from ww w. j av a 2 s. c o m } this.boundary = boundary; final String starting = "--" + boundary + CBMultipartEntity.CRLF; //$NON-NLS-1$ final String closing = "--" + boundary + "--" + CBMultipartEntity.CRLF; //$NON-NLS-1$ startingBoundary = EncodingUtils.getAsciiBytes(starting); closingBoundary = EncodingUtils.getAsciiBytes(closing); }
From source file:com.android.pwdhashandroid.sharp2java.HMACMD5.java
public byte[] ComputeHash(String data) { return ComputeHash(EncodingUtils.getAsciiBytes(data)); }
From source file:edu.northwestern.cbits.purple_robot_manager.http.BasicAuthTokenExtractor.java
public String extract(final HttpRequest request) throws HttpException { String auth = null;//from w ww . j av a2 s . c o m final Header h = request.getFirstHeader(AUTH.WWW_AUTH_RESP); if (h != null) { final String s = h.getValue(); if (s != null) { auth = s.trim(); } } if (auth != null) { final int i = auth.indexOf(' '); if (i == -1) { throw new ProtocolException("Invalid Authorization header: " + auth); } final String authscheme = auth.substring(0, i); if (authscheme.equalsIgnoreCase("basic")) { final String s = auth.substring(i + 1).trim(); try { final byte[] credsRaw = EncodingUtils.getAsciiBytes(s); final BinaryDecoder codec = new Base64(); auth = EncodingUtils.getAsciiString(codec.decode(credsRaw)); } catch (final DecoderException ex) { throw new ProtocolException("Malformed BASIC credentials"); } } } return auth; }
From source file:com.jfrog.bintray.client.impl.util.URIUtil.java
/** * Unescape and decode a given string regarded as an escaped string with the * default protocol charset.//from ww w . j a v a 2 s . c om * * @param escaped a string * @return the unescaped string * @throws HttpException if the string cannot be decoded (invalid) */ public static String decode(String escaped) throws HttpException { try { byte[] rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(escaped)); return EncodingUtils.getString(rawdata, UTF8_CHARSET_NAME); } catch (DecoderException e) { throw new HttpException(e.getMessage()); } }
From source file:org.artifactory.util.encodeing.URIUtil.java
/** * Unescape and decode a given string regarded as an escaped string with the * default protocol charset./* ww w .j a va2 s .c o m*/ * * @param escaped a string * @return the unescaped string * @throws HttpException if the string cannot be decoded (invalid) */ public static String decode(String escaped) throws HttpException { try { byte[] rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(escaped)); return EncodingUtils.getString(rawdata, Charsets.UTF_8.name()); } catch (DecoderException e) { throw new HttpException(e.getMessage()); } }