List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.scistor.tab.auth.licensing.LicenseValidator.java
public License decryptAndVerifyLicense(InputStream inputStream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); StringWriter writer = null;/*from w w w . j a v a 2 s. c o m*/ while (true) { String line = reader.readLine(); if (line.startsWith("------ END")) { break; } if (writer != null) { writer.append(line); } if (line.trim().isEmpty()) { writer = new StringWriter(1024); } } byte[] licenseData = Base64.decodeBase64(writer.toString()); SignedLicense signedLicense = (SignedLicense) new ObjectSerializer().readObject(SignedLicense.class, licenseData); return LicenseManager.getInstance().decryptAndVerifyLicense(signedLicense); }
From source file:be.tutul.naheulcraft.login.Authentification.java
private void check(String msg) { // On vrifie que la demande est complte if (msg.contains("<end>")) { // On enlve la partie inUtile String[] values = msg.split("<end>"); String requete = values[0].trim(); // On rcupre les informations Utiles String[] info = requete.split(":"); this.pseudo = info[0].trim(); String tmp = info[1].trim(); tmp += "=="; String password = new String(Base64.decodeBase64(tmp.getBytes())); //TODO On envoit cela au script Pyton String connect = this.pseudo + ":" + password; String test = this.python.test(connect); if (test.equals("encodage_version")) { // Mauvais encodage this.logger.warning("Mauvais encodage de la part du lanceur"); this.erreur = "encodage"; this.login = false; } else if (test.equals("bad_user")) { this.logger.info("Mauvais peudo"); // Le pseudo n'existe pas this.erreur = "user"; this.login = false; } else if (test.equals("bad_password")) { this.logger.info("Mauvais mot de passe"); // Le mot de passe ne correspond pas au pseudo this.erreur = "pass"; this.login = false; } else if (test.equals("ok")) { this.logger.info("Login verifie avec succes"); // Le login est correcte this.login = true; } else if (test.equals("bad_authorization")) { this.logger.info("Ce pseudo n'a pas le droit de se connecter"); // Le joueur n'a pas les autorisations this.erreur = "statut"; this.login = false; } else {// www.j a v a 2s . co m this.logger.error("Erreur du service de login", test); // Bugs du serveur this.erreur = "serveur"; this.login = false; } } else { this.logger.warning("La requte semble incomplte car elle ne finit pas comme attendu"); this.erreur = "incomplet"; this.login = false; } }
From source file:baggage.hypertoolkit.security.CipherText.java
public CipherText(String base64) { this.bytes = Base64.decodeBase64(base64); }
From source file:com.commander4j.util.JCipher.java
public String decrypt(String encrypted) throws Exception { Cipher cipher = getCipher(Cipher.DECRYPT_MODE); byte[] plainBytes = cipher.doFinal(Base64.decodeBase64(encrypted)); return new String(plainBytes); }
From source file:com.appzone.sim.services.BasicAuthAuthenticationService.java
@Override public boolean authenticate(HttpServletRequest request) { // Autherization header String auth = request.getHeader("Authorization"); logger.debug("Basic Auth header: {}", auth); if (auth == null || auth.trim().length() < 6) return false; auth = auth.substring(6); // remove "BASIC " String decoded = new String(Base64.decodeBase64(auth)); logger.debug("Decoded Basic Auth: {}", decoded); String parts[] = decoded.split(":"); return checkAuthentication(parts[0], parts[1]); }
From source file:com.eviware.loadui.ui.fx.util.NodeUtils.java
public static Image fromBase64Image(String base64) { byte[] ba = Base64.decodeBase64(base64); return new Image(new ByteArrayInputStream(ba)); }
From source file:net.sf.hajdbc.codec.crypto.CipherCodecTest.java
@Before public void before() throws Exception { SecretKeyFactory factory = SecretKeyFactory.getInstance(ALGORITHM); Key key = factory.generateSecret(new DESKeySpec(Base64.decodeBase64(KEY.getBytes()))); this.codec = new CipherCodec(key); }
From source file:com.sshutils.utils.CryptHelper.java
public static String decrypt(String strToDecrypt) { try {/*from w ww. j a v a 2s .co m*/ // for (Provider provider: Security.getProviders()) { // log.info(provider.getName()); // for (String key: provider.stringPropertyNames()) // log.info("\t" + key + "\t" + provider.getProperty(key)); //} Cipher cipher = Cipher.getInstance(ENCRYPT_TYPE, "BC"); final SecretKeySpec secretKey = new SecretKeySpec(key, "AES"); cipher.init(Cipher.DECRYPT_MODE, secretKey); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt))); return decryptedString; } catch (Exception e) { log.error("Error while decrypting", e); } return null; }
From source file:craterdog.utils.Base64Utils.java
/** * This function decodes a base 64 string into its corresponding byte array. * * @param base64 The base 64 encoded string. * @return The corresponding byte array. *//*from w ww .j a va 2s. c o m*/ public static byte[] decode(String base64) { byte[] result = Base64.decodeBase64(base64); return result; }
From source file:cd.go.contrib.elasticagents.dockerswarm.elasticagent.executors.GetPluginSettingsIconExecutorTest.java
@Test public void rendersIconInBase64() throws Exception { GoPluginApiResponse response = new GetPluginSettingsIconExecutor().execute(); HashMap<String, String> hashMap = new Gson().fromJson(response.responseBody(), HashMap.class); assertThat(hashMap.size(), is(2));//from w w w. ja v a2s. com assertThat(hashMap.get("content-type"), is("image/png")); assertThat(Util.readResourceBytes("/docker-swarm.png"), is(Base64.decodeBase64(hashMap.get("data")))); }