List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.cyclopsgroup.tornado.security.entity.User.java
/** * @return Private password//from w ww . j av a2 s. c o m */ public String getPrivatePassword() { String pwd = getPassword(); return new String(Base64.decodeBase64(pwd.getBytes())); }
From source file:com.haulmont.chile.core.datatypes.impl.ByteArrayDatatype.java
@Override public byte[] parse(String value) throws ParseException { if (value == null || value.length() == 0) return null; return Base64.decodeBase64(value.getBytes(StandardCharsets.UTF_8)); }
From source file:com.amazonaws.eclipse.core.ui.preferences.ObfuscatingStringFieldEditor.java
public static String decodeString(String s) { return new String(Base64.decodeBase64(s.getBytes())); }
From source file:easy.api.service.ComponentSocket.java
public String send() throws UnknownHostException, SocketException, IOException { String result = ""; // create socket to IP final InetAddress inetAddress = InetAddress.getByName(this.ipAddress); byte[] base64String = Base64.decodeBase64(this.magicPacketBase64.getBytes()); //byte[] base64String = Base64.decodeBase64(this.magicPacketBase64); DatagramPacket datagramPacket = new DatagramPacket(base64String, base64String.length, inetAddress, this.udpPort); try (DatagramSocket datagramSocket = new DatagramSocket()) { datagramSocket.send(datagramPacket); result += this.magicPacketBase64 + " send successfull!!\n"; } catch (Exception e) { result += e.getMessage();/* w ww. j a va2 s . c om*/ } return result; }
From source file:com.google.gerrit.sshd.SshUtil.java
/** * Parse a public key into its Java type. * * @param key the account key to parse.//w ww .jav a 2 s .c om * @return the valid public key object. * @throws InvalidKeySpecException the key supplied is not a valid SSH key. * @throws NoSuchAlgorithmException the JVM is missing the key algorithm. * @throws NoSuchProviderException the JVM is missing the provider. */ public static PublicKey parse(final AccountSshKey key) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException { try { final String s = key.getEncodedKey(); if (s == null) { throw new InvalidKeySpecException("No key string"); } final byte[] bin = Base64.decodeBase64(Constants.encodeASCII(s)); return new Buffer(bin).getRawPublicKey(); } catch (RuntimeException re) { throw new InvalidKeySpecException("Cannot parse key", re); } catch (SshException e) { throw new InvalidKeySpecException("Cannot parse key", e); } }
From source file:encrypt.algorithms.AESCBC.java
public String decrypt(String key1, String key2, String encrypted) { try {//ww w. ja va2 s . c om IvParameterSpec iv = new IvParameterSpec(key2.getBytes("UTF-8")); SecretKeySpec skeySpec = new SecretKeySpec(key1.getBytes("UTF-8"), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/NOPADDING"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted)); return new String(original); } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:com.evolveum.midpoint.schema.util.ReportTypeUtil.java
public static JasperDesign loadJasperDesign(byte[] template) throws SchemaException { try {//ww w . j a va 2 s .com byte[] reportTemplate = Base64.decodeBase64(template); InputStream inputStreamJRXML = new ByteArrayInputStream(reportTemplate); JasperDesign jasperDesign = JRXmlLoader.load(inputStreamJRXML); // LOGGER.trace("load jasper design : {}", jasperDesign); return jasperDesign; } catch (JRException ex) { throw new SchemaException(ex.getMessage(), ex.getCause()); } }
From source file:eu.earthobservatory.org.StrabonEndpoint.Authenticate.java
/** * Authenticate user/* w w w. j a va2s . c o m*/ * @throws IOException * */ public boolean authenticateUser(String authorization, ServletContext context) throws IOException { Properties properties = new Properties(); if (authorization == null) return false; // no authorization if (!authorization.toUpperCase().startsWith("BASIC ")) return false; // only BASIC authentication // get encoded user and password, comes after "BASIC " String userpassEncoded = authorization.substring(6); // decode String userpassDecoded = new String(Base64.decodeBase64(userpassEncoded)); Pattern pattern = Pattern.compile(":"); String[] credentials = pattern.split(userpassDecoded); // get credentials.properties as input stream InputStream input = new FileInputStream(context.getRealPath(CREDENTIALS_PROPERTIES_FILE)); // load the properties properties.load(input); // close the stream input.close(); // check if the given credentials are allowed if (!userpassDecoded.equals(":") && credentials[0].equals(properties.get("username")) && credentials[1].equals(properties.get("password"))) return true; else return false; }
From source file:aes_encryption.AES_Encryption.java
public static String decrypt(String strToDecrypt) { try {/* w w w.j av a 2 s. co m*/ Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); cipher.init(Cipher.DECRYPT_MODE, secretKey); setDecryptedString(new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt)))); } catch (Exception e) { System.out.println("Error while decrypting: " + e.toString()); } return null; }
From source file:com.jxt.web.filter.AcceptUrlFilter.java
public AcceptUrlFilter(String urlPattern) { if (urlPattern == null) { throw new NullPointerException("urlPattern must not be null"); }/*from ww w .j ava2s. c o m*/ // TODO remove decode this.urlPattern = new String(Base64.decodeBase64(urlPattern), UTF8); }