public static Response decodeSAMLResponse(String responseMessage) throws ConfigurationException, ParserConfigurationException, SAXException, IOException, UnmarshallingException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); byte[] base64DecodedResponse = Base64.decode(responseMessage); Document document = docBuilder.parse(new ByteArrayInputStream(base64DecodedResponse)); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return (Response) unmarshaller.unmarshall(element); }
/** {@inheritDoc} */ protected byte[] getEncodedPublicKey(String keyConfigContent) { return Base64.decode(keyConfigContent); }
/** * Decode a base64-encoded ds:CryptoBinary value to a native Java BigInteger type. * * @param base64Value base64-encoded CryptoBinary value * @return the decoded BigInteger */ public static final BigInteger decodeBigIntegerFromCryptoBinary(String base64Value) { return new BigInteger(1, Base64.decode(base64Value)); }
/** * Decoding and deflating the encoded AuthReq * * @param encodedStr encoded AuthReq * @return decoded AuthReq */ public static String decode(String encodedStr) throws Exception { return new String(Base64.decode(encodedStr)); }
/** * Decode a base64-encoded ds:CryptoBinary value to a native Java BigInteger type. * * @param base64Value base64-encoded CryptoBinary value * @return the decoded BigInteger */ public static final BigInteger decodeBigIntegerFromCryptoBinary(String base64Value) { return new BigInteger(1, Base64.decode(base64Value)); }
/** * Build Java certificate from base64 encoding. * * @param base64Cert base64-encoded certificate * @return a native Java X509 certificate * @throws CertificateException thrown if there is an error constructing certificate */ public static java.security.cert.X509Certificate buildJavaX509Cert(String base64Cert) throws CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); ByteArrayInputStream input = new ByteArrayInputStream(Base64.decode(base64Cert)); return (java.security.cert.X509Certificate) cf.generateCertificate(input); }
/** * Build Java certificate from base64 encoding. * * @param base64Cert base64-encoded certificate * @return a native Java X509 certificate * @throws CertificateException thrown if there is an error constructing certificate */ public static java.security.cert.X509Certificate buildJavaX509Cert(String base64Cert) throws CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); ByteArrayInputStream input = new ByteArrayInputStream(Base64.decode(base64Cert)); return (java.security.cert.X509Certificate) cf.generateCertificate(input); }
/** * Convenience method for getting an artifact builder and parsing the given Base64 encoded artifact with it. * * @param base64Artifact Base64 encoded artifact to parse * * @return constructed artifact */ public AbstractSAML1Artifact buildArtifact(String base64Artifact){ return buildArtifact(Base64.decode(base64Artifact)); }
/** * Convenience method for getting an artifact builder and parsing the given Base64 encoded artifact with it. * * @param base64Artifact Base64 encoded artifact to parse * * @return constructed artifact */ public AbstractSAML2Artifact buildArtifact(String base64Artifact){ return buildArtifact(Base64.decode(base64Artifact)); }
/** * Build Java RSA public key from base64 encoding. * * @param base64EncodedKey base64-encoded RSA public key * @return a native Java RSAPublicKey * @throws KeyException thrown if there is an error constructing key */ public static RSAPublicKey buildJavaRSAPublicKey(String base64EncodedKey) throws KeyException { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(base64EncodedKey)); return (RSAPublicKey) buildKey(keySpec, "RSA"); }
/** * Build Java RSA public key from base64 encoding. * * @param base64EncodedKey base64-encoded RSA public key * @return a native Java RSAPublicKey * @throws KeyException thrown if there is an error constructing key */ public static RSAPublicKey buildJavaRSAPublicKey(String base64EncodedKey) throws KeyException { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(base64EncodedKey)); return (RSAPublicKey) buildKey(keySpec, "RSA"); }
/** * Build Java private key from base64 encoding. The key should have no password. * * @param base64EncodedKey base64-encoded private key * @return a native Java PrivateKey * @throws KeyException thrown if there is an error constructing key */ public static PrivateKey buildJavaPrivateKey(String base64EncodedKey) throws KeyException { return SecurityHelper.decodePrivateKey(Base64.decode(base64EncodedKey), null); }
/** * Build Java DSA public key from base64 encoding. * * @param base64EncodedKey base64-encoded DSA public key * @return a native Java DSAPublicKey * @throws KeyException thrown if there is an error constructing key */ public static DSAPublicKey buildJavaDSAPublicKey(String base64EncodedKey) throws KeyException { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(base64EncodedKey)); return (DSAPublicKey) buildKey(keySpec, "DSA"); }
/** * Build Java EC public key from base64 encoding. * * @param base64EncodedKey base64-encoded EC public key * @return a native Java ECPublicKey * @throws KeyException thrown if there is an error constructing key */ public static ECPublicKey buildJavaECPublicKey(String base64EncodedKey) throws KeyException { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(base64EncodedKey)); return (ECPublicKey) buildKey(keySpec, "EC"); }
/** * Build Java DSA public key from base64 encoding. * * @param base64EncodedKey base64-encoded DSA public key * @return a native Java DSAPublicKey * @throws KeyException thrown if there is an error constructing key */ public static DSAPublicKey buildJavaDSAPublicKey(String base64EncodedKey) throws KeyException { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(base64EncodedKey)); return (DSAPublicKey) buildKey(keySpec, "DSA"); }
/** * Build Java EC public key from base64 encoding. * * @param base64EncodedKey base64-encoded EC public key * @return a native Java ECPublicKey * @throws KeyException thrown if there is an error constructing key */ public static ECPublicKey buildJavaECPublicKey(String base64EncodedKey) throws KeyException { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(base64EncodedKey)); return (ECPublicKey) buildKey(keySpec, "EC"); }
/** * Build Java private key from base64 encoding. The key should have no password. * * @param base64EncodedKey base64-encoded private key * @return a native Java PrivateKey * @throws KeyException thrown if there is an error constructing key */ public static PrivateKey buildJavaPrivateKey(String base64EncodedKey) throws KeyException { return SecurityHelper.decodePrivateKey(Base64.decode(base64EncodedKey), null); }
/** * Build Java CRL from base64 encoding. * * @param base64CRL base64-encoded CRL * @return a native Java X509 CRL * @throws CertificateException thrown if there is an error constructing certificate * @throws CRLException thrown if there is an error constructing CRL */ public static java.security.cert.X509CRL buildJavaX509CRL(String base64CRL) throws CertificateException, CRLException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); ByteArrayInputStream input = new ByteArrayInputStream(Base64.decode(base64CRL)); return (java.security.cert.X509CRL) cf.generateCRL(input); }
/** * Build Java CRL from base64 encoding. * * @param base64CRL base64-encoded CRL * @return a native Java X509 CRL * @throws CertificateException thrown if there is an error constructing certificate * @throws CRLException thrown if there is an error constructing CRL */ public static java.security.cert.X509CRL buildJavaX509CRL(String base64CRL) throws CertificateException, CRLException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); ByteArrayInputStream input = new ByteArrayInputStream(Base64.decode(base64CRL)); return (java.security.cert.X509CRL) cf.generateCRL(input); }
/** * Convert an {@link org.opensaml.xml.signature.X509CRL} into a native Java representation. * * @param xmlCRL object to extract the CRL from * * @return a native Java {@link java.security.cert.X509CRL} object * * @throws CRLException thrown if there is a problem converting the * CRL data into {@link java.security.cert.X509CRL}s */ public static X509CRL getCRL(org.opensaml.xml.signature.X509CRL xmlCRL) throws CRLException { if (xmlCRL == null || xmlCRL.getValue() == null) { return null; } Collection<X509CRL> crls = X509Util.decodeCRLs(Base64.decode(xmlCRL.getValue())); return crls.iterator().next(); }