List of usage examples for org.bouncycastle.util.encoders UrlBase64 decode
public static byte[] decode(String data)
From source file:com.antisleuthsecurity.asc_api.cryptography.ciphers.asymmetric.RsaCipher.java
License:Apache License
public void setPublicKeyUrlB64(String key) { byte[] encodedKey = UrlBase64.decode(key.getBytes()); try {// www . jav a 2 s . c om PublicKey pKey = null; pKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(encodedKey)); this.publicKey = pKey; } catch (Exception e) { ASLog.error("Could not set public key", e); } }
From source file:com.eucalyptus.auth.CredentialProvider.java
License:Open Source License
public static X509Certificate getCertificate(final String alias) throws GeneralSecurityException { EntityWrapper<X509Cert> db = Credentials.getEntityWrapper(); try {/*www . jav a 2s .c o m*/ X509Cert certInfo = db.getUnique(new X509Cert(alias)); String certString = certInfo.getPemCertificate(); if (certString != null) { byte[] certBytes = UrlBase64.decode(certString.getBytes()); X509Certificate x509 = Hashes.getPemCert(certBytes); db.commit(); return x509; } return null; } catch (EucalyptusCloudException e) { db.rollback(); throw new GeneralSecurityException(e); } }
From source file:com.eucalyptus.auth.crypto.StringCrypto.java
License:Open Source License
public String decrypt(String passwordEncoded) throws GeneralSecurityException { //String withoutPrefix = passwordEncoded.substring(VMwareBrokerProperties.ENCRYPTION_FORMAT.length(), passwordEncoded.length()); byte[] passwordEncrypted = UrlBase64.decode(passwordEncoded); Key pk = keystore.getKey(ALIAS, PASSWORD); Cipher cipher = Cipher.getInstance(this.asymmetricFormat, this.provider); cipher.init(Cipher.DECRYPT_MODE, pk); return new String(cipher.doFinal(passwordEncrypted)); }
From source file:com.eucalyptus.auth.crypto.StringCrypto.java
License:Open Source License
public String decrypt(byte[] stringEncoded, String secret) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { final byte[] keyBytes = makeKey(secret); byte[] stringEncrypted = UrlBase64.decode(stringEncoded); final SecretKey key = new SecretKeySpec(keyBytes, "DESede"); final IvParameterSpec iv = new IvParameterSpec(new byte[8]); final Cipher cipher = Cipher.getInstance(this.symmetricFormat); cipher.init(Cipher.DECRYPT_MODE, key, iv); return new String(cipher.doFinal(stringEncrypted)); }
From source file:com.eucalyptus.auth.util.Hashes.java
License:Open Source License
/** * TODO: Move this up in the dependency tree. * @param o//from w w w .ja v a 2 s .c o m * @return */ @Deprecated public static String base64decode(String input) { return new String(UrlBase64.decode(input.getBytes())); }
From source file:com.eucalyptus.crypto.StringCrypto.java
License:Open Source License
public String decrypt(String passwordEncoded) throws GeneralSecurityException { //String withoutPrefix = passwordEncoded.substring(VMwareBrokerProperties.ENCRYPTION_FORMAT.length(), passwordEncoded.length()); byte[] passwordEncrypted = UrlBase64.decode(passwordEncoded); Key pk = keystore.getKey(ALIAS, PASSWORD); Cipher cipher = Cipher.getInstance(this.asymmetricFormat, this.provider); cipher.init(Cipher.DECRYPT_MODE, pk, Crypto.getSecureRandomSupplier().get()); return new String(cipher.doFinal(passwordEncrypted)); }
From source file:com.github.adanac.framework.sso.common.util.Base64Util.java
License:Apache License
/** * BASE64 decrypt/*from w w w . j av a 2 s . co m*/ * * @param key * @return * @throws Exception */ public static byte[] decryptBASE64(String key) throws Exception { Security.addProvider(new BouncyCastleProvider()); return UrlBase64.decode(key.getBytes(SSOConfig.getEncoding())); }
From source file:edu.ucsb.eucalyptus.keys.Hashes.java
License:Open Source License
public static String base64decode(String input) { return new String(UrlBase64.decode(input.getBytes())); }
From source file:eu.stork.documentservice.utils.GetDSSFileAction.java
License:Open Source License
private static STORKAttrQueryRequest processDocRequest_(String samlRequest) throws STORKSAMLEngineException { // fetch the samlToken from the request final byte[] samlToken = UrlBase64.decode(samlRequest); //System.out.println("SAML Engine DokumentService init"); try {//from w w w. j a v a 2 s . co m Bootstrap.bootstrap(); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } final STORKSAMLEngine engine = STORKSAMLEngine.getInstance(SAML_INSTANCE); final STORKAttrQueryRequest attrData = engine.validateSTORKAttrQueryRequest(samlToken); //SAMLRequest = new String(samlToken); LOG.trace("Processing doc request done. SAML: " + new String(samlToken)); return attrData; }
From source file:eu.stork.peps.auth.commons.PEPSUtil.java
License:Open Source License
/** * Decode URL save base64 saml token//from ww w .j a v a2 s. co m * @param samlToken the SAML toke to decode * @return The decoded bytes */ public static byte[] decodeSAMLTokenUrlSafe(final String samlToken) { return UrlBase64.decode(samlToken); }