public static void decode(char[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(decodeChunk(id, o, l)); } catch (IOException e) { // convert exception to Base64Exception throw new Base64Exception(new Message("BASE64_RUNTIME_EXCEPTION", LOG), e); } }
public static String encode(byte[] id) { char[] cd = encodeChunk(id, 0, id.length); return new String(cd, 0, cd.length); }
obcount += processEncodeme(ib, ob, obcount);
protected void setHeaders(MessageContext ctx) { ctx.put(ObjectMessageContext.MESSAGE_INPUT, true); Map<String, List<String>> headers = new HashMap<String, List<String>>(); copyRequestHeaders(ctx, headers); ctx.put(GenericMessageContext.HTTP_REQUEST_HEADERS, headers); if (headers.containsKey("Authorization")) { List<String> authorizationLines = headers.get("Authorization"); String credentials = authorizationLines.get(0); String authType = credentials.split(" ")[0]; if ("Basic".equals(authType)) { String authEncoded = credentials.split(" ")[1]; try { String authDecoded = new String(Base64Utility.decode(authEncoded)); String authInfo[] = authDecoded.split(":"); String username = authInfo[0]; String password = authInfo[1]; ctx.put(BindingProvider.USERNAME_PROPERTY, username); ctx.put(BindingProvider.PASSWORD_PROPERTY, password); } catch (Base64Exception ex) { //ignore, we'll leave things alone. They can try decoding it themselves } } } headers = new HashMap<String, List<String>>(); setPolicies(ctx, headers); ctx.put(GenericMessageContext.HTTP_RESPONSE_HEADERS, headers); } protected void setPolicies(MessageContext ctx, Map<String, List<String>> headers) {
userName += passwd; userName = Base64Utility.encode(userName.getBytes()); headers.put("Authorization", Arrays.asList(new String[] {"Basic " + userName})); userName += passwd; userName = Base64Utility.encode(userName.getBytes()); headers.put("Proxy-Authorization", Arrays.asList(new String[] {"Basic " + userName}));
public static void encodeChunk(byte[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(new String(encodeChunk(id, o, l)).getBytes()); } catch (IOException e) { throw new Base64Exception(new Message("BASE64_ENCODE_IOEXCEPTION", LOG), e); } }
public static void decode(String id, OutputStream ostream) throws Base64Exception { try { char[] cd = id.toCharArray(); ostream.write(decodeChunk(cd, 0, cd.length)); } catch (IOException e) { throw new Base64Exception(new Message("BASE64_DECODE_IOEXCEPTION", LOG), e); } }
public static void encode(byte[] id, int o, int l, Writer writer) throws Base64Exception { try { writer.write(encodeChunk(id, o, l)); } catch (IOException e) { throw new Base64Exception(new Message("BASE64_ENCODE_WRITER_IOEXCEPTION", LOG), e); } }