public byte[] getTokenValue() { try { return Base64.decode(bst.getValue()); } catch (Base64DecodingException ex) { CRYPTO_IMPL_LOGGER.log(Level.SEVERE,"WSS1209.bst.base64decode.error",ex); return null; } }
private byte[] getDecodedBase64EncodedData(String encodedData) throws XWSSecurityException { try { return Base64.decode(encodedData); } catch (Base64DecodingException e) { log.log(Level.SEVERE, "WSS0144.unableto.decode.base64.data" ,e); throw new SecurityHeaderException( "Unable to decode Base64 encoded data", e); } }
private byte[] getDecodedBase64EncodedData(String encodedData) throws XWSSecurityException { try { return Base64.decode(encodedData); } catch (Base64DecodingException e) { throw new SecurityHeaderException( "Unable to decode Base64 encoded data", e); } }
import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException; import com.sun.org.apache.xml.internal.security.utils.Base64; import java.io.IOException; public class Base64Test { public static void main(String args[]) throws IOException, Base64DecodingException { String orig = "original String before base64 encoding in Java"; //encoding byte array into base 64 String encoded = Base64.encode(orig.getBytes("UTF-8"));//make sure the bytes are utf-8 and not platform default System.out.println("Original String: " + orig ); System.out.println("Base64 Encoded String : " + new String(encoded,"UTF-8"));//ensure string is utf-8 //decoding byte array into base64 byte[] decoded = Base64.decode(encoded); System.out.println("Base 64 Decoded String : " + new String(decoded,"UTF-8"));//ensure string is utf-8 } }
/** * Read an PEM encoded X.509v3 certificate * * @param inputString * PEM encoded X.509 certificate * @return certificate */ public BurpCertificate importCertificateFromString(String inputString) { setStatus("Importing certificate..."); CertificateFactory certFactory; try { certFactory = CertificateFactory.getInstance("X.509"); ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(inputString)); X509Certificate x509certificate = (X509Certificate) certFactory.generateCertificate(bais); BurpCertificate certificate = new BurpCertificate(x509certificate); certificate.setPublicKey(x509certificate.getPublicKey()); certificate.setSource("Imported"); burpCertificateStore.addCertificate(certificate); setCertificateTree(); setStatus("Certificate imported"); return certificate; } catch (CertificateException | Base64DecodingException e) { setStatus("Error reading input certificate. (" + e.getMessage() + ")"); e.printStackTrace(); } catch (Exception e) { setStatus("Error. (" + e.getMessage() + ")"); e.printStackTrace(); } return null; }
return decrypt(Base64.decode(encrypted), passphrase, salt);
while (it.hasNext()) { X500PrivateCredential cred = (X500PrivateCredential)it.next(); if (matchesKeyIdentifier(Base64.decode(keyIdentifier), cred.getCertificate())) return cred.getPrivateKey();
public PrivateKey getPrivateKey(Map context, byte[] keyIdentifier) throws XWSSecurityException { /* use PrivateKeyCallback */ try { Subject subject = getSubject(context); if (subject != null) { Set set = subject.getPrivateCredentials(X500PrivateCredential.class); if (set != null) { Iterator it = set.iterator(); while (it.hasNext()) { X500PrivateCredential cred = (X500PrivateCredential)it.next(); if (matchesKeyIdentifier(Base64.decode(keyIdentifier), cred.getCertificate())) return cred.getPrivateKey(); } } } PrivateKeyCallback.Request request = new PrivateKeyCallback.SubjectKeyIDRequest( keyIdentifier); PrivateKeyCallback pkCallback = new PrivateKeyCallback(request); Callback[] callbacks = new Callback[] { pkCallback }; _handler.handle(callbacks); return pkCallback.getKey(); } catch (Exception e) { throw new XWSSecurityException(e); } }
while (it.hasNext()) { X500PrivateCredential cred = (X500PrivateCredential)it.next(); if (matchesThumbPrint(Base64.decode(keyIdentifier), cred.getCertificate())) return cred.getPrivateKey();
while (it.hasNext()) { X500PrivateCredential cred = (X500PrivateCredential)it.next(); if (matchesThumbPrint(Base64.decode(keyIdentifier), cred.getCertificate())) return cred.getPrivateKey();