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; } }
String authEncoded = creds[1]; try { byte[] authBytes = Base64Utility.decode(authEncoded);
public static byte[] decode(String id) throws Base64Exception { return decode(id, false); }
public static byte[] decode(String id) throws Base64Exception { return decode(id, false); }
public static byte[] decode(String encoded) throws Base64Exception { return Base64Utility.decode(encoded, true); }
public static byte[] decode(String encoded) throws Base64Exception { return Base64Utility.decode(encoded, true); }
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; } }
private static String base64Decode(String srcString) { byte[] transformed = null; try { transformed = Base64Utility.decode(srcString); return new String(transformed, "ISO-8859-1"); } catch (UnsupportedEncodingException uee) { return srcString; } catch (Base64Exception e) { return srcString; } }
public static Certificate decodeCertificate(String encodedCert) { try { byte[] decoded = Base64Utility.decode(encodedCert); return CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(decoded)); } catch (Exception ex) { throw new SecurityException(ex); } } public static PublicKey loadPublicKey(InputStream storeLocation, char[] storePassword, String alias,
public static Certificate decodeCertificate(String encodedCert) { try { byte[] decoded = Base64Utility.decode(encodedCert); return CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(decoded)); } catch (Exception ex) { throw new SecurityException(ex); } } public static PublicKey loadPublicKey(InputStream storeLocation, char[] storePassword, String alias,
public static X509Certificate loadX509Certificate(Crypto crypto, Element certNode) throws Exception { String base64Value = certNode.getTextContent().trim(); byte[] certBytes = Base64Utility.decode(base64Value); Crypto certCrypto = crypto; if (certCrypto == null) { certCrypto = new Merlin(); } return certCrypto.loadCertificate(new ByteArrayInputStream(certBytes)); }
public static X509Certificate loadX509Certificate(Crypto crypto, Element certNode) throws Exception { String base64Value = certNode.getTextContent().trim(); byte[] certBytes = Base64Utility.decode(base64Value); Crypto certCrypto = crypto; if (certCrypto == null) { certCrypto = new Merlin(); } return certCrypto.loadCertificate(new ByteArrayInputStream(certBytes)); }
public static boolean compareTlsCertificates(TLSSessionInfo tlsInfo, List<String> base64EncodedCerts) { Certificate[] clientCerts = tlsInfo.getPeerCertificates(); if (clientCerts.length == base64EncodedCerts.size()) { try { for (int i = 0; i < clientCerts.length; i++) { X509Certificate x509Cert = (X509Certificate)clientCerts[i]; byte[] encodedKey = x509Cert.getEncoded(); byte[] clientKey = Base64Utility.decode(base64EncodedCerts.get(i)); if (!Arrays.equals(encodedKey, clientKey)) { return false; } } return true; } catch (Exception ex) { // throw exception later } } return false; }
public static String[] getBasicAuthParts(String basicAuthData) { String authDecoded = null; try { authDecoded = new String(Base64Utility.decode(basicAuthData)); } catch (Exception ex) { throw ExceptionUtils.toNotAuthorizedException(ex, null); } String[] authInfo = authDecoded.split(":"); if (authInfo.length == 2) { return authInfo; } throw ExceptionUtils.toNotAuthorizedException(null, null); }
public static String[] getBasicAuthParts(String basicAuthData) { String authDecoded = null; try { authDecoded = new String(Base64Utility.decode(basicAuthData)); } catch (Exception ex) { throw ExceptionUtils.toNotAuthorizedException(ex, null); } String[] authInfo = authDecoded.split(":"); if (authInfo.length == 2) { return authInfo; } throw ExceptionUtils.toNotAuthorizedException(null, null); }
private byte[] getServiceTicket(String encodedServiceTicket) { try { return Base64Utility.decode(encodedServiceTicket); } catch (Base64Exception ex) { throw ExceptionUtils.toNotAuthorizedException(null, getFaultResponse()); } }
private byte[] getServiceTicket(String encodedServiceTicket) { try { return Base64Utility.decode(encodedServiceTicket); } catch (Base64Exception ex) { throw ExceptionUtils.toNotAuthorizedException(null, getFaultResponse()); } }
protected RequestAbstractType extractRequest(RequestContext context, String samlRequest) throws Exception { byte[] deflatedToken = Base64Utility.decode(samlRequest); String httpMethod = WebUtils.getHttpServletRequest(context).getMethod(); InputStream tokenStream = supportDeflateEncoding || "GET".equals(httpMethod) ? new DeflateEncoderDecoder().inflateToken(deflatedToken) : new ByteArrayInputStream(deflatedToken); Document responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, StandardCharsets.UTF_8)); if (LOG.isDebugEnabled()) { LOG.debug(DOM2Writer.nodeToString(responseDoc)); } return (RequestAbstractType)OpenSAMLUtil.fromDom(responseDoc.getDocumentElement()); }
/** * This function extracts the user:pass token from * the Authorization:Basic header. It returns a two element * String array, the first being the userid, the second * being the password. It returns null, if it cannot parse. */ private String[] extractUserPass(String token) { try { byte[] userpass = Base64Utility.decode(token); String up = IOUtils.newStringFromBytes(userpass); String user = up.substring(0, up.indexOf(':')); String pass = up.substring(up.indexOf(':') + 1); return new String[] {user, pass}; } catch (Exception e) { return null; } }
protected void handleToken(Message message, String assertion) { // the assumption here is that saml:Assertion is directly available, however, it // may be contained inside saml:Response or saml:ArtifactResponse/saml:Response if (assertion == null) { throwFault("SAML assertion is not available", null); } try { byte[] deflatedToken = Base64Utility.decode(assertion); InputStream is = useDeflateEncoding() ? new DeflateEncoderDecoder().inflateToken(deflatedToken) : new ByteArrayInputStream(deflatedToken); validateToken(message, is); } catch (Base64Exception ex) { throwFault("Base64 decoding has failed", ex); } catch (DataFormatException ex) { throwFault("Encoded assertion can not be inflated", ex); } } }