List of usage examples for org.bouncycastle.util.encoders Base64 encode
public static byte[] encode(byte[] data)
From source file:eu.stork.peps.test.simple.SSETestUtils.java
License:EUPL
/** * Encode SAML token.//from ww w .j ava 2 s.c o m * * @param samlToken the SAML token * * @return the string */ public static String encodeSAMLToken(final byte[] samlToken) { return new String(Base64.encode(samlToken)); }
From source file:ezbake.crypto.TDESCrypto.java
License:Apache License
public String encrypt(byte[] data) throws DataLengthException, IllegalStateException, InvalidCipherTextException { log.debug("TDESCrypto Encrypt {}", data); byte[] encrypted = new byte[data.length + (data.length % 8)]; int p = encryptCipher.processBytes(data, 0, data.length, encrypted, 0); p = encryptCipher.doFinal(encrypted, p); log.debug("Encrypted Data {}", encrypted); String b64Encoded = new String(Base64.encode(encrypted)); return b64Encoded; }
From source file:ezbake.crypto.utils.CryptoUtil.java
License:Apache License
public static String encode(byte[] data) { return new String(Base64.encode(data)); }
From source file:ezbake.protect.ezca.EzCABootstrap.java
License:Apache License
public String getPassPhrase() throws AppPersistCryptoException, NoSuchAlgorithmException, InvalidKeySpecException, PKeyCryptoException { String passcode = ""; String pk = regAppModel.getPrivateKey(); RSAKeyCrypto crypto = new RSAKeyCrypto(pk, true); byte[] cipherData = crypto.sign(SecurityID.ReservedSecurityId.Registration.getCn().getBytes()); passcode = new String(Base64.encode(cipherData)); logger.debug("Generate The Passcode {}", passcode); return passcode; }
From source file:fi.laverca.Pkcs1.java
License:Apache License
/** * Get the MSS Signature value//from w w w .j ava2 s. c o m * @return MSS Signature as a String */ public String getMssSignatureValue() { String signature = null; try { signature = new String(Base64.encode(pkcs1.getSignatureValue()), "ASCII"); } catch (UnsupportedEncodingException e) { log.error("Unable to decode signature: " + e.getMessage()); } return signature; }
From source file:fi.okm.mpass.shibboleth.attribute.resolver.dc.impl.EcaAuthnIdDataConnector.java
License:Open Source License
/** * Calculates the authn ID with the given input. SHA-256 is used as a digest algorithm and UTF-8 as character * encoding./*from w ww . ja v a 2s .c o m*/ * * @param input The input for the calculation. * @return The calculated authn ID. */ protected String calculateAuthnId(@Nonnull @NotEmpty final String input) { MessageDigest md; try { md = MessageDigest.getInstance("SHA-256"); md.update(input.getBytes("UTF-8")); } catch (NoSuchAlgorithmException e) { log.error("Could not use the configured digest algorithm", e); return null; } catch (UnsupportedEncodingException e) { log.error("Could not encode the input for the digest algorithm", e); return null; } byte[] digest = md.digest(); return new String(Base64.encode(digest)); }
From source file:foam.util.Password.java
License:Open Source License
/** * Encodes byte array to base64 string/* ww w .j a v a 2 s .co m*/ * @param input data to encode * @return base64 encoded string */ private static String encode(byte[] input) { return new String(Base64.encode(input)); }
From source file:fr.insalyon.creatis.vip.core.server.business.proxy.ProxyClient.java
License:Open Source License
private void printB64(byte[] data, PrintStream out) { byte[] b64data; b64data = Base64.encode(data); for (int i = 0; i < b64data.length; i += 64) { if ((b64data.length - i) > 64) { out.write(b64data, i, 64);/* w w w . jav a 2 s. c o m*/ } else { out.write(b64data, i, b64data.length - i); } out.println(); } }
From source file:freemail.OutboundContact.java
License:Open Source License
private byte[] getAESParams() { String params = this.contactfile.get("aesparams"); if (params != null) { return Base64.decode(params); }//from w w w. j ava 2s.co m SecureRandom rnd = new SecureRandom(); byte[] retval = new byte[AES_KEY_LENGTH + AES_BLOCK_LENGTH]; rnd.nextBytes(retval); // save them for next time (if insertion fails) so we can // generate the same message, otherwise they'll collide // unnecessarily. this.contactfile.put("aesparams", new String(Base64.encode(retval))); return retval; }
From source file:freemail.smtp.SMTPHandler.java
License:Open Source License
private void handle_auth(SMTPCommand cmd) { String uname;//w w w . j a va 2 s .c o m String password; if (cmd.args.length == 0) { this.ps.print("504 No auth type given\r\n"); return; } else if (cmd.args[0].equalsIgnoreCase("login")) { this.ps.print("334 " + new String(Base64.encode("Username:".getBytes())) + "\r\n"); String b64username; String b64password; try { b64username = this.bufrdr.readLine(); } catch (IOException ioe) { return; } if (b64username == null) return; this.ps.print("334 " + new String(Base64.encode("Password:".getBytes())) + "\r\n"); try { b64password = this.bufrdr.readLine(); } catch (IOException ioe) { return; } if (b64password == null) return; uname = new String(Base64.decode(b64username.getBytes())); password = new String(Base64.decode(b64password.getBytes())); } else if (cmd.args[0].equalsIgnoreCase("plain")) { String b64creds; if (cmd.args.length > 1) { b64creds = cmd.args[1]; } else { this.ps.print("334 \r\n"); try { b64creds = this.bufrdr.readLine(); if (b64creds == null) return; } catch (IOException ioe) { return; } } String creds_plain = new String(Base64.decode(b64creds.getBytes())); String[] creds = creds_plain.split("\0"); if (creds.length < 2) return; // most documents seem to reckon you send the // username twice. Some think only once. // This will work either way. uname = creds[0]; // there may be a null first (is this always the case?) if (uname.length() < 1) { uname = creds[1]; } password = creds[creds.length - 1]; } else { this.ps.print("504 Auth type unimplemented - weren't you listening?\r\n"); return; } account = accountmanager.authenticate(uname, password); if (account != null) { this.ps.print("235 Authenticated\r\n"); } else { this.ps.print("535 Authentication failed\r\n"); } }