Refine search
public static String getBasicAuthHeader(String userName, String passwd, boolean useIso8859) { String userAndPass = userName + ":" + passwd; byte[] authBytes = useIso8859 ? userAndPass.getBytes(StandardCharsets.ISO_8859_1) : userAndPass.getBytes(); return "Basic " + Base64Utility.encode(authBytes); }
private static String base64Decode(String srcString) { byte[] transformed = null; try { transformed = Base64Utility.decode(srcString); return new String(transformed, "ISO-8859-1"); } catch (UnsupportedEncodingException | Base64Exception e) { return srcString; } }
public static String encodeChunk(byte[] id, int offset, int length) { char[] chunk = Base64Utility.encodeChunk(id, offset, length, true); if (chunk != null) { return new String(chunk); } return null; }
public static void decode(char[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(decodeChunk(id, o, l)); } catch (Exception e) { LOG.warning("Invalid base64 encoded string : " + new String(id)); throw new Base64Exception(new Message("BASE64_RUNTIME_EXCEPTION", 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); } } //---- Private static methods --------------------------------------
obcount += processEncodeme(ib, ob, obcount);
/** * Decode a requested number of bytes of data into a buffer. * * @return true if we were able to obtain more data, false otherwise. */ private boolean decodeStreamData() throws IOException { decodedIndex = 0; // fill up a data buffer with input data int readCharacters = fillEncodedBuffer(); if (readCharacters > 0) { try { decodedChars = Base64Utility.decodeChunk(encodedChars, 0, readCharacters); } catch (Base64Exception e) { throw new IOException(e); } decodedCount = decodedChars.length; return true; } return false; }
public static void decode(char[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(decodeChunk(id, o, l)); } catch (Exception e) { LOG.warning("Invalid base64 encoded string : " + new String(id)); throw new Base64Exception(new Message("BASE64_RUNTIME_EXCEPTION", LOG), e); } }
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); } }
obcount += processEncodeme(ib, ob, obcount);
/** * Decode a requested number of bytes of data into a buffer. * * @return true if we were able to obtain more data, false otherwise. */ private boolean decodeStreamData() throws IOException { decodedIndex = 0; // fill up a data buffer with input data int readCharacters = fillEncodedBuffer(); if (readCharacters > 0) { try { decodedChars = Base64Utility.decodeChunk(encodedChars, 0, readCharacters); } catch (Base64Exception e) { throw new IOException(e); } decodedCount = decodedChars.length; return true; } return false; }
public static void decode(char[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(decodeChunk(id, o, l)); } catch (Exception e) { LOG.warning("Invalid base64 encoded string : " + new String(id)); throw new Base64Exception(new Message("BASE64_RUNTIME_EXCEPTION", 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); } }
public String getAuthorization(AuthorizationPolicy authPolicy, URI currentURI, Message message) { if (!HttpAuthHeader.AUTH_TYPE_NEGOTIATE.equals(authPolicy.getAuthorizationType())) { return null; } try { String spn = getCompleteServicePrincipalName(currentURI); boolean useKerberosOid = MessageUtils.getContextualBoolean(message, PROPERTY_USE_KERBEROS_OID); Oid oid = new Oid(useKerberosOid ? KERBEROS_OID : SPNEGO_OID); byte[] token = getToken(authPolicy, spn, oid, message); return HttpAuthHeader.AUTH_TYPE_NEGOTIATE + " " + Base64Utility.encode(token); } catch (LoginException | GSSException e) { throw new RuntimeException(e.getMessage(), e); } }
String authEncoded = creds[1]; try { byte[] authBytes = Base64Utility.decode(authEncoded);
public static String encode(byte[] id, boolean urlSafe) { char[] cd = encodeChunk(id, 0, id.length); return new String(cd, 0, cd.length); }
obcount += processEncodeme(ib, ob, obcount);
public static void decode(char[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(decodeChunk(id, o, l)); } catch (Exception e) { LOG.warning("Invalid base64 encoded string : " + new String(id)); throw new Base64Exception(new Message("BASE64_RUNTIME_EXCEPTION", LOG), e); } }
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 GuvnorRepositoryImpl(String packageName, String packageVersion, String packageUsername, String packagePassword, String ruleBaseid) { this.packageName = packageName; this.packageVersion = packageVersion; this.packageUsername = packageUsername; this.packagePassword = packagePassword; this.ruleBaseid = ruleBaseid; this.auth = "Basic " + Base64Utility.encode((packageUsername + ":" + packagePassword).getBytes()); }