List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.xinferin.licensing.LicenceActivator.java
private void initialiseKeys() throws Exception { try {//from ww w . j a v a 2s . co m byte[] publicKeyBytes = Base64.decodeBase64(spublicKey); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKeyBytes); publicKey = keyFactory.generatePublic(publicKeySpec); } catch (InvalidKeySpecException e) { throw new Exception("Invalid Key Specs not valid Key files." + e.getCause()); } catch (NoSuchAlgorithmException e) { throw new Exception("There is no such algorithm. Please check the JDK ver." + e.getCause()); } }
From source file:com.mycompany.securerest.auth.AuthenticationService.java
public boolean authenticate(String authCredentials) { if (null == authCredentials) return false; // header value format will be "Basic encodedstring" for Basic // authentication. Example "Basic YWRtaW46YWRtaW4=" final String encodedUserPassword = authCredentials.replaceFirst("Basic" + " ", ""); String usernameAndPassword = null; try {/* w w w. j av a2 s . co m*/ byte[] decodedBytes = Base64.decodeBase64(encodedUserPassword); usernameAndPassword = new String(decodedBytes, "UTF-8"); } catch (IOException e) { e.printStackTrace(); } final StringTokenizer tokenizer = new StringTokenizer(usernameAndPassword, ":"); final String username = tokenizer.nextToken(); final String password = tokenizer.nextToken(); // we have fixed the userid and password as admin // call some UserService/LDAP here boolean authenticationStatus = "admin".equals(username) && "admin".equals(password); return authenticationStatus; }
From source file:hh.learnj.test.license.test.alps.base64.ApacheBaseCoder.java
@Override public byte[] decode(String src) { try {/*w w w . j a v a2 s . c o m*/ return Base64.decodeBase64(src.getBytes(CODE)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw new UnsupportedOperationException(e.getMessage()); } }
From source file:com.basp.trabajo_al_minuto.model.business.BusinessSecurity.java
/** * Se encarga de desencriptar la contrasea ingresada por el usuario * */// w w w . j a v a 2 s . c o m public static String decrypt(String encryptValue) throws BusinessException { String secretKey = "e-business"; String base64EncryptedString = ""; try { byte[] message = Base64.decodeBase64(encryptValue.getBytes("utf-8")); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digestOfPassword = md.digest(secretKey.getBytes("utf-8")); byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); SecretKey key = new SecretKeySpec(keyBytes, "DESede"); Cipher decipher = Cipher.getInstance("DESede"); decipher.init(Cipher.DECRYPT_MODE, key); byte[] plainText = decipher.doFinal(message); base64EncryptedString = new String(plainText, "UTF-8"); } catch (Exception ex) { throw new BusinessException(ex); } return base64EncryptedString; }
From source file:net.algem.security.CustomPasswordEncoder.java
@Override public String encodePassword(String rawPass, Object salt) throws DataAccessException { byte[] crypted = null; try {//from w w w . j av a2s . com byte[] b64salt = Base64.decodeBase64((String) salt); crypted = service.getEncryptedPassword(rawPass, b64salt); } catch (UserException ex) { return ""; } return Base64.encodeBase64String(crypted); }
From source file:eu.freme.broker.security.tools.PasswordHasher.java
public static boolean check(String password, String stored) throws Exception { String[] saltAndPass = stored.split("\\$"); if (saltAndPass.length != 2) { throw new IllegalStateException("The stored password have the form 'salt$hash'"); }/*from w ww . j av a 2 s.c o m*/ String hashOfInput = hash(password, Base64.decodeBase64(saltAndPass[0])); return hashOfInput.equals(saltAndPass[1]); }
From source file:apm.common.utils.Encodes.java
/** * Base64?. */ public static byte[] decodeBase64(String input) { return Base64.decodeBase64(input); }
From source file:com.koda.common.lcm.Tool.java
private static byte[] undoStuff(String s) { byte[] buffer = null; buffer = Base64.decodeBase64(s.getBytes()); // reverse bytes int lastIndex = buffer.length - 1; for (int i = 0; i < buffer.length / 2; i++) { byte tmp = buffer[i]; buffer[i] = (byte) (buffer[lastIndex - i] ^ xorValue); buffer[lastIndex - i] = (byte) (tmp ^ xorValue); }/* w ww . j ava 2 s. c o m*/ return buffer; }
From source file:com.mirth.connect.server.userutil.FileUtil.java
/** * Decodes a Base64 string into octets.// www . j a v a 2 s.co m * * @param data * The Base64 string to decode. * @return The decoded data, as a byte array.s */ public static byte[] decode(String data) { return Base64.decodeBase64(data.getBytes()); }
From source file:it.unipmn.di.dcs.common.conversion.Convert.java
/** * Converts a Base64 byte array to a byte array. *///from w w w . j ava2 s .c o m public static byte[] Base64ToBytes(byte[] data) { if (data == null) { return null; } return Base64.decodeBase64(data); }