List of usage examples for org.apache.commons.codec.binary Base64 isBase64
public static boolean isBase64(final byte[] arrayOctet)
From source file:org.sonar.process.AesCipherTest.java
@Test public void encrypt() { AesCipher cipher = new AesCipher(pathToSecretKey()); String encryptedText = cipher.encrypt("this is a secret"); assertThat(StringUtils.isNotBlank(encryptedText)).isTrue(); assertThat(Base64.isBase64(encryptedText.getBytes())).isTrue(); }
From source file:org.springframework.cloud.aws.messaging.support.converter.ObjectMessageConverter.java
@Override public Object convertFromInternal(Message<?> message, Class<?> targetClass) { String messagePayload = message.getPayload().toString(); byte[] rawContent = messagePayload.getBytes(this.encoding); if (!(Base64.isBase64(rawContent))) { throw new MessageConversionException("Error converting payload '" + messagePayload + "' because it is not a valid base64 encoded stream!", null); }/* w w w . j a v a 2 s.c om*/ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(rawContent); Base64InputStream base64InputStream = new Base64InputStream(byteArrayInputStream); Serializable result = null; ObjectInputStream objectInputStream = null; try { objectInputStream = new ObjectInputStream(base64InputStream); result = (Serializable) objectInputStream.readObject(); } catch (ClassNotFoundException e) { throw new MessageConversionException( "Error loading class from message payload, make sure class is in classpath!", e); } catch (IOException e) { throw new MessageConversionException("Error reading payload from binary representation", e); } finally { if (objectInputStream != null) { try { objectInputStream.close(); } catch (IOException e) { LOGGER.warn("Error closing object output stream while reading message payload", e); } } } return result; }
From source file:org.springframework.cloud.aws.messaging.support.converter.ObjectMessageConverterTest.java
@Test public void testToMessageAndFromMessage() throws Exception { String content = "stringwithspecialcharsa8"; MySerializableClass sourceMessage = new MySerializableClass(content); MessageConverter messageConverter = new ObjectMessageConverter(); Message<?> message = messageConverter.toMessage(sourceMessage, getMessageHeaders("UTF-8")); assertTrue(Base64.isBase64(message.getPayload().toString().getBytes("UTF-8"))); MySerializableClass result = (MySerializableClass) messageConverter.fromMessage(message, MySerializableClass.class); assertEquals(content, result.getContent()); }
From source file:org.springframework.cloud.aws.messaging.support.converter.ObjectMessageConverterTest.java
@Test public void testToMessageAndFromMessageWithCustomEncoding() throws Exception { String content = "stringwithspecialcharsa8"; MySerializableClass sourceMessage = new MySerializableClass(content); MessageConverter messageConverter = new ObjectMessageConverter("ISO-8859-1"); Message<?> message = messageConverter.toMessage(sourceMessage, getMessageHeaders("ISO-8859-1")); assertTrue(Base64.isBase64(message.getPayload().toString().getBytes("ISO-8859-1"))); MySerializableClass result = (MySerializableClass) messageConverter.fromMessage(message, MySerializableClass.class); assertEquals(content, result.getContent()); }
From source file:org.torproject.collector.bridgedescs.SanitizedBridgesWriter.java
/** * Sanitizes a network status and writes it to disk. *///from w ww. j a va2 s . c o m public void sanitizeAndStoreNetworkStatus(byte[] data, String publicationTime, String authorityFingerprint) throws ConfigurationException { if (this.persistenceProblemWithSecrets) { /* There's a persistence problem, so we shouldn't scrub more IP * addresses in this execution. */ return; } if (publicationTime.compareTo(maxNetworkStatusPublishedTime) > 0) { maxNetworkStatusPublishedTime = publicationTime; } if (this.bridgeSanitizingCutOffTimestamp.compareTo(publicationTime) > 0) { String text = "Sanitizing and storing network status with " + "publication time outside our descriptor sanitizing " + "interval."; if (this.haveWarnedAboutInterval) { logger.debug(text); } else { logger.warn(text); this.haveWarnedAboutInterval = true; } } /* Parse the given network status line by line. */ StringBuilder header = new StringBuilder(); SortedMap<String, String> scrubbedLines = new TreeMap<String, String>(); try { StringBuilder scrubbed = new StringBuilder(); BufferedReader br = new BufferedReader(new StringReader(new String(data, "US-ASCII"))); String line = null; String mostRecentDescPublished = null; byte[] fingerprintBytes = null; String descPublicationTime = null; String hashedBridgeIdentityHex = null; while ((line = br.readLine()) != null) { /* Use publication time from "published" line instead of the * file's last-modified time. Don't copy over the line, because * we're going to write a "published" line below. */ if (line.startsWith("published ")) { publicationTime = line.substring("published ".length()); /* Additional header lines don't have to be cleaned up. */ } else if (line.startsWith("flag-thresholds ")) { header.append(line + "\n"); /* r lines contain sensitive information that needs to be removed * or replaced. */ } else if (line.startsWith("r ")) { /* Clear buffer from previously scrubbed lines. */ if (scrubbed.length() > 0) { String scrubbedLine = scrubbed.toString(); scrubbedLines.put(hashedBridgeIdentityHex, scrubbedLine); scrubbed = new StringBuilder(); } /* Parse the relevant parts of this r line. */ String[] parts = line.split(" "); if (parts.length < 9) { logger.warn( "Illegal line '" + line + "' in bridge network " + "status. Skipping descriptor."); return; } if (!Base64.isBase64(parts[2])) { logger.warn("Illegal base64 character in r line '" + parts[2] + "'. Skipping descriptor."); return; } fingerprintBytes = Base64.decodeBase64(parts[2] + "=="); descPublicationTime = parts[4] + " " + parts[5]; String address = parts[6]; String orPort = parts[7]; String dirPort = parts[8]; /* Determine most recent descriptor publication time. */ if (descPublicationTime.compareTo(publicationTime) <= 0 && (mostRecentDescPublished == null || descPublicationTime.compareTo(mostRecentDescPublished) > 0)) { mostRecentDescPublished = descPublicationTime; } /* Write scrubbed r line to buffer. */ byte[] hashedBridgeIdentity = DigestUtils.sha(fingerprintBytes); String hashedBridgeIdentityBase64 = Base64.encodeBase64String(hashedBridgeIdentity).substring(0, 27); hashedBridgeIdentityHex = Hex.encodeHexString(hashedBridgeIdentity); String descriptorIdentifier = parts[3]; String hashedDescriptorIdentifier = Base64 .encodeBase64String(DigestUtils.sha(Base64.decodeBase64(descriptorIdentifier + "=="))) .substring(0, 27); String scrubbedAddress = scrubIpv4Address(address, fingerprintBytes, descPublicationTime); String nickname = parts[1]; String scrubbedOrPort = this.scrubTcpPort(orPort, fingerprintBytes, descPublicationTime); String scrubbedDirPort = this.scrubTcpPort(dirPort, fingerprintBytes, descPublicationTime); scrubbed.append("r " + nickname + " " + hashedBridgeIdentityBase64 + " " + hashedDescriptorIdentifier + " " + descPublicationTime + " " + scrubbedAddress + " " + scrubbedOrPort + " " + scrubbedDirPort + "\n"); /* Sanitize any addresses in a lines using the fingerprint and * descriptor publication time from the previous r line. */ } else if (line.startsWith("a ")) { String scrubbedOrAddress = scrubOrAddress(line.substring("a ".length()), fingerprintBytes, descPublicationTime); if (scrubbedOrAddress != null) { scrubbed.append("a " + scrubbedOrAddress + "\n"); } else { logger.warn( "Invalid address in line '" + line + "' in bridge network status. Skipping line!"); } /* Nothing special about s, w, and p lines; just copy them. */ } else if (line.startsWith("s ") || line.equals("s") || line.startsWith("w ") || line.equals("w") || line.startsWith("p ") || line.equals("p")) { scrubbed.append(line + "\n"); /* There should be nothing else but r, a, w, p, and s lines in the * network status. If there is, we should probably learn before * writing anything to the sanitized descriptors. */ } else { logger.debug("Unknown line '" + line + "' in bridge " + "network status. Not writing to disk!"); return; } } br.close(); if (scrubbed.length() > 0) { String scrubbedLine = scrubbed.toString(); scrubbedLines.put(hashedBridgeIdentityHex, scrubbedLine); scrubbed = new StringBuilder(); } /* Check if we can tell from the descriptor publication times * whether this status is possibly stale. */ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); if (formatter.parse(publicationTime).getTime() - formatter.parse(mostRecentDescPublished).getTime() > 60L * 60L * 1000L) { logger.warn("The most recent descriptor in the bridge " + "network status published at " + publicationTime + " was " + "published at " + mostRecentDescPublished + " which is " + "more than 1 hour before the status. This is a sign for " + "the status being stale. Please check!"); } } catch (ParseException e) { logger.warn("Could not parse timestamp in " + "bridge network status.", e); return; } catch (IOException e) { logger.warn("Could not parse bridge network " + "status.", e); return; } /* Write the sanitized network status to disk. */ try { String syear = publicationTime.substring(0, 4); String smonth = publicationTime.substring(5, 7); String sday = publicationTime.substring(8, 10); String stime = publicationTime.substring(11, 13) + publicationTime.substring(14, 16) + publicationTime.substring(17, 19); File tarballFile = new File( this.sanitizedBridgesDirectory.getAbsolutePath() + "/" + syear + "/" + smonth + "/statuses/" + sday + "/" + syear + smonth + sday + "-" + stime + "-" + authorityFingerprint); File rsyncFile = new File(recentPathName, "statuses/" + tarballFile.getName()); File[] outputFiles = new File[] { tarballFile, rsyncFile }; for (File outputFile : outputFiles) { outputFile.getParentFile().mkdirs(); BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile)); bw.write(Annotation.Status.toString()); bw.write("published " + publicationTime + "\n"); bw.write(header.toString()); for (String scrubbed : scrubbedLines.values()) { bw.write(scrubbed); } bw.close(); } } catch (IOException e) { logger.warn("Could not write sanitized bridge " + "network status to disk.", e); return; } }
From source file:org.torproject.collector.bridgedescs.SanitizedBridgesWriter.java
/** * Sanitizes a bridge server descriptor and writes it to disk. *///from ww w . j av a 2 s.c o m public void sanitizeAndStoreServerDescriptor(byte[] data) { if (this.persistenceProblemWithSecrets) { /* There's a persistence problem, so we shouldn't scrub more IP * addresses in this execution. */ return; } /* Parse descriptor to generate a sanitized version. */ String scrubbedDesc = null; String published = null; String masterKeyEd25519FromIdentityEd25519 = null; try { BufferedReader br = new BufferedReader(new StringReader(new String(data, "US-ASCII"))); StringBuilder scrubbed = new StringBuilder(); String line = null; String hashedBridgeIdentity = null; String address = null; String routerLine = null; String scrubbedRouterLine = null; String scrubbedAddress = null; String masterKeyEd25519 = null; List<String> orAddresses = null; List<String> scrubbedOrAddresses = null; boolean skipCrypto = false; while ((line = br.readLine()) != null) { /* Skip all crypto parts that might be used to derive the bridge's * identity fingerprint. */ if (skipCrypto && !line.startsWith("-----END ")) { continue; /* Store the router line for later processing, because we may need * the bridge identity fingerprint for replacing the IP address in * the scrubbed version. */ } else if (line.startsWith("router ")) { String[] parts = line.split(" "); if (parts.length != 6) { logger.warn("Invalid router line: '" + line + "'. Skipping."); return; } address = parts[2]; routerLine = line; /* Store or-address parts in a list and sanitize them when we have * read the fingerprint. */ } else if (line.startsWith("or-address ")) { if (orAddresses == null) { orAddresses = new ArrayList<String>(); } orAddresses.add(line.substring("or-address ".length())); /* Parse the publication time to see if we're still inside the * sanitizing interval. */ } else if (line.startsWith("published ")) { published = line.substring("published ".length()); if (published.compareTo(maxServerDescriptorPublishedTime) > 0) { maxServerDescriptorPublishedTime = published; } if (this.bridgeSanitizingCutOffTimestamp.compareTo(published) > 0) { String text = "Sanitizing and storing " + "server descriptor with publication time outside our " + "descriptor sanitizing interval."; if (this.haveWarnedAboutInterval) { logger.debug(text); } else { logger.warn(text); this.haveWarnedAboutInterval = true; } } scrubbed.append(line + "\n"); /* Parse the fingerprint to determine the hashed bridge * identity. */ } else if (line.startsWith("opt fingerprint ") || line.startsWith("fingerprint ")) { String fingerprint = line .substring( line.startsWith("opt ") ? "opt fingerprint".length() : "fingerprint".length()) .replaceAll(" ", "").toLowerCase(); byte[] fingerprintBytes = Hex.decodeHex(fingerprint.toCharArray()); hashedBridgeIdentity = DigestUtils.shaHex(fingerprintBytes).toLowerCase(); try { scrubbedAddress = scrubIpv4Address(address, fingerprintBytes, published); if (orAddresses != null) { scrubbedOrAddresses = new ArrayList<String>(); for (String orAddress : orAddresses) { String scrubbedOrAddress = scrubOrAddress(orAddress, fingerprintBytes, published); if (scrubbedOrAddress != null) { scrubbedOrAddresses.add(scrubbedOrAddress); } else { logger.warn("Invalid address in line " + "'or-address " + orAddress + "' in bridge server " + "descriptor. Skipping line!"); } } } String[] routerLineParts = routerLine.split(" "); String nickname = routerLineParts[1]; String scrubbedOrPort = this.scrubTcpPort(routerLineParts[3], fingerprintBytes, published); String scrubbedDirPort = this.scrubTcpPort(routerLineParts[4], fingerprintBytes, published); String scrubbedSocksPort = this.scrubTcpPort(routerLineParts[5], fingerprintBytes, published); scrubbedRouterLine = String.format("router %s %s %s %s %s%n", nickname, scrubbedAddress, scrubbedOrPort, scrubbedDirPort, scrubbedSocksPort); } catch (IOException e) { /* There's a persistence problem, so we shouldn't scrub more * IP addresses in this execution. */ this.persistenceProblemWithSecrets = true; return; } scrubbed.append((line.startsWith("opt ") ? "opt " : "") + "fingerprint"); for (int i = 0; i < hashedBridgeIdentity.length() / 4; i++) { scrubbed.append(" " + hashedBridgeIdentity.substring(4 * i, 4 * (i + 1)).toUpperCase()); } scrubbed.append("\n"); /* Replace the contact line (if present) with a generic one. */ } else if (line.startsWith("contact ")) { scrubbed.append("contact somebody\n"); /* When we reach the signature, we're done. Write the sanitized * descriptor to disk below. */ } else if (line.startsWith("router-signature")) { scrubbedDesc = scrubbedRouterLine; if (scrubbedOrAddresses != null) { for (String scrubbedOrAddress : scrubbedOrAddresses) { scrubbedDesc += "or-address " + scrubbedOrAddress + "\n"; } } scrubbedDesc += scrubbed.toString(); break; /* Replace extra-info digest with the hashed digest of the * non-scrubbed descriptor. */ } else if (line.startsWith("opt extra-info-digest ") || line.startsWith("extra-info-digest ")) { String[] parts = line.split(" "); if (line.startsWith("opt ")) { scrubbed.append("opt "); parts = line.substring(4).split(" "); } if (parts.length > 3) { logger.warn("extra-info-digest line contains more arguments than" + "expected: '" + line + "'. Skipping descriptor."); return; } scrubbed.append("extra-info-digest " + DigestUtils.shaHex(Hex.decodeHex(parts[1].toCharArray())).toUpperCase()); if (parts.length > 2) { if (!Base64.isBase64(parts[2])) { logger.warn("Illegal base64 character in extra-info-digest line '" + line + "'. Skipping descriptor."); return; } scrubbed.append( " " + Base64.encodeBase64String(DigestUtils.sha256(Base64.decodeBase64(parts[2]))) .replaceAll("=", "")); } scrubbed.append("\n"); /* Possibly sanitize reject lines if they contain the bridge's own * IP address. */ } else if (line.startsWith("reject ")) { if (address != null && line.startsWith("reject " + address)) { scrubbed.append("reject " + scrubbedAddress + line.substring("reject ".length() + address.length()) + "\n"); } else { scrubbed.append(line + "\n"); } /* Extract master-key-ed25519 from identity-ed25519. */ } else if (line.equals("identity-ed25519")) { StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null && !line.equals("-----END ED25519 CERT-----")) { if (line.equals("-----BEGIN ED25519 CERT-----")) { continue; } sb.append(line); } masterKeyEd25519FromIdentityEd25519 = this .parseMasterKeyEd25519FromIdentityEd25519(sb.toString()); if (masterKeyEd25519FromIdentityEd25519 == null) { logger.warn("Could not parse master-key-ed25519 from " + "identity-ed25519. Skipping descriptor."); return; } String sha256MasterKeyEd25519 = Base64 .encodeBase64String(DigestUtils .sha256(Base64.decodeBase64(masterKeyEd25519FromIdentityEd25519 + "="))) .replaceAll("=", ""); scrubbed.append("master-key-ed25519 " + sha256MasterKeyEd25519 + "\n"); if (masterKeyEd25519 != null && !masterKeyEd25519.equals(masterKeyEd25519FromIdentityEd25519)) { logger.warn("Mismatch between identity-ed25519 and " + "master-key-ed25519. Skipping."); return; } /* Verify that identity-ed25519 and master-key-ed25519 match. */ } else if (line.startsWith("master-key-ed25519 ")) { masterKeyEd25519 = line.substring(line.indexOf(" ") + 1); if (masterKeyEd25519FromIdentityEd25519 != null && !masterKeyEd25519FromIdentityEd25519.equals(masterKeyEd25519)) { logger.warn("Mismatch between identity-ed25519 and " + "master-key-ed25519. Skipping."); return; } /* Write the following lines unmodified to the sanitized * descriptor. */ } else if (line.startsWith("accept ") || line.startsWith("platform ") || line.startsWith("opt protocols ") || line.startsWith("protocols ") || line.startsWith("proto ") || line.startsWith("uptime ") || line.startsWith("bandwidth ") || line.startsWith("opt hibernating ") || line.startsWith("hibernating ") || line.startsWith("ntor-onion-key ") || line.equals("opt hidden-service-dir") || line.equals("hidden-service-dir") || line.equals("opt caches-extra-info") || line.equals("caches-extra-info") || line.equals("opt allow-single-hop-exits") || line.equals("allow-single-hop-exits") || line.startsWith("ipv6-policy ") || line.equals("tunnelled-dir-server")) { scrubbed.append(line + "\n"); /* Replace node fingerprints in the family line with their hashes * and leave nicknames unchanged. */ } else if (line.startsWith("family ")) { StringBuilder familyLine = new StringBuilder("family"); for (String s : line.substring(7).split(" ")) { if (s.startsWith("$")) { familyLine.append(" $" + DigestUtils.shaHex(Hex.decodeHex(s.substring(1).toCharArray())) .toUpperCase()); } else { familyLine.append(" " + s); } } scrubbed.append(familyLine.toString() + "\n"); /* Skip the purpose line that the bridge authority adds to its * cached-descriptors file. */ } else if (line.startsWith("@purpose ")) { continue; /* Skip all crypto parts that might leak the bridge's identity * fingerprint. */ } else if (line.startsWith("-----BEGIN ") || line.equals("onion-key") || line.equals("signing-key") || line.equals("onion-key-crosscert") || line.startsWith("ntor-onion-key-crosscert ")) { skipCrypto = true; /* Stop skipping lines when the crypto parts are over. */ } else if (line.startsWith("-----END ")) { skipCrypto = false; /* Skip the ed25519 signature; we'll include a SHA256 digest of * the SHA256 descriptor digest in router-digest-sha256. */ } else if (line.startsWith("router-sig-ed25519 ")) { continue; /* If we encounter an unrecognized line, stop parsing and print * out a warning. We might have overlooked sensitive information * that we need to remove or replace for the sanitized descriptor * version. */ } else { logger.warn("Unrecognized line '" + line + "'. Skipping."); return; } } br.close(); } catch (Exception e) { logger.warn("Could not parse server " + "descriptor.", e); return; } /* Determine filename of sanitized server descriptor. */ String descriptorDigest = null; try { String ascii = new String(data, "US-ASCII"); String startToken = "router "; String sigToken = "\nrouter-signature\n"; int start = ascii.indexOf(startToken); int sig = ascii.indexOf(sigToken) + sigToken.length(); if (start >= 0 && sig >= 0 && sig > start) { byte[] forDigest = new byte[sig - start]; System.arraycopy(data, start, forDigest, 0, sig - start); descriptorDigest = DigestUtils.shaHex(DigestUtils.sha(forDigest)); } } catch (UnsupportedEncodingException e) { /* Handle below. */ } if (descriptorDigest == null) { logger.warn("Could not calculate server " + "descriptor digest."); return; } String descriptorDigestSha256Base64 = null; if (masterKeyEd25519FromIdentityEd25519 != null) { try { String ascii = new String(data, "US-ASCII"); String startToken = "router "; String sigToken = "\n-----END SIGNATURE-----\n"; int start = ascii.indexOf(startToken); int sig = ascii.indexOf(sigToken) + sigToken.length(); if (start >= 0 && sig >= 0 && sig > start) { byte[] forDigest = new byte[sig - start]; System.arraycopy(data, start, forDigest, 0, sig - start); descriptorDigestSha256Base64 = Base64 .encodeBase64String(DigestUtils.sha256(DigestUtils.sha256(forDigest))) .replaceAll("=", ""); } } catch (UnsupportedEncodingException e) { /* Handle below. */ } if (descriptorDigestSha256Base64 == null) { logger.warn("Could not calculate server " + "descriptor SHA256 digest."); return; } } String dyear = published.substring(0, 4); String dmonth = published.substring(5, 7); File tarballFile = new File(this.sanitizedBridgesDirectory.getAbsolutePath() + "/" + dyear + "/" + dmonth + "/server-descriptors/" + "/" + descriptorDigest.charAt(0) + "/" + descriptorDigest.charAt(1) + "/" + descriptorDigest); try { File rsyncCatFile = new File(config.getPath(Key.RecentPath).toFile(), "bridge-descriptors/server-descriptors/" + this.rsyncCatString + "-server-descriptors.tmp"); File[] outputFiles = new File[] { tarballFile, rsyncCatFile }; boolean[] append = new boolean[] { false, true }; for (int i = 0; i < outputFiles.length; i++) { File outputFile = outputFiles[i]; boolean appendToFile = append[i]; if (outputFile.exists() && !appendToFile) { /* We already stored this descriptor to disk before, so let's * not store it yet another time. */ break; } outputFile.getParentFile().mkdirs(); BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile, appendToFile)); bw.write(Annotation.BridgeServer.toString()); bw.write(scrubbedDesc); if (descriptorDigestSha256Base64 != null) { bw.write("router-digest-sha256 " + descriptorDigestSha256Base64 + "\n"); } bw.write("router-digest " + descriptorDigest.toUpperCase() + "\n"); bw.close(); } } catch (ConfigurationException | IOException e) { logger.warn("Could not write sanitized server " + "descriptor to disk.", e); return; } }
From source file:org.wso2.security.tools.scanner.dependency.js.preprocessor.ReactFileDownloader.java
/** * Get component version from content of pom file. * * @param encodedContent base64 content of pom file. * @param versionTag version tag of component. * @return version.//from w w w . j a va 2 s.c o m */ private static String getVersion(String encodedContent, String versionTag) { String componentVersion = null; if (Base64.isBase64(encodedContent)) { //get decoded content of pom file byte[] encodedContentBytes = Base64.decodeBase64(encodedContent); String decodedContent = new String(encodedContentBytes, UTF_8); String[] lines = decodedContent.split(System.getProperty("line.separator")); //get component version for (String line : lines) { if (line.contains(versionTag)) { Pattern pattern = Pattern.compile(JSScannerConstants.POM_VERSION_REGEX); Matcher matcher = pattern.matcher(line); if (matcher.find()) { componentVersion = matcher.group(0); } } } } return componentVersion; }
From source file:ren.hankai.cordwood.mobile.MobileAppScannerTest.java
@Test public void testScanAndroidApk() { final URL url = getClass().getClassLoader().getResource("test.apk"); final MobileAppInfo appInfo = MobileAppScanner.scanAndroidApk(url.getPath()); appInfo.setBundlePath("testPath"); Assert.assertEquals("", appInfo.getName()); Assert.assertEquals("cn.com.sparksoft.flfg", appInfo.getBundleId()); Assert.assertEquals("1.0.5#150", appInfo.getVersion()); Assert.assertEquals("res/drawable-xhdpi-v4/app_logo.png", appInfo.getIconName()); Assert.assertNotNull(appInfo.getIcon()); Assert.assertNotNull(appInfo.getBase64Icon()); Assert.assertTrue(Base64.isBase64(appInfo.getBase64Icon())); Assert.assertEquals("testPath", appInfo.getBundlePath()); Assert.assertTrue(appInfo.isValid()); }
From source file:ren.hankai.cordwood.mobile.MobileAppScannerTest.java
@Test public void testScanIosIpa() { final URL url = getClass().getClassLoader().getResource("test.ipa"); final MobileAppInfo appInfo = MobileAppScanner.scanIosIpa(url.getPath()); appInfo.setBundlePath("testPath"); Assert.assertEquals("LAWDICT", appInfo.getName()); Assert.assertEquals("cn.com.sparksoft.flfg", appInfo.getBundleId()); Assert.assertEquals("1.0.6#212", appInfo.getVersion()); Assert.assertEquals("AppIcon60x60", appInfo.getIconName()); Assert.assertNotNull(appInfo.getIcon()); Assert.assertNotNull(appInfo.getBase64Icon()); Assert.assertTrue(Base64.isBase64(appInfo.getBase64Icon())); Assert.assertEquals("testPath", appInfo.getBundlePath()); Assert.assertTrue(appInfo.isValid()); }
From source file:se.dibbler.backend.generics.DibblerImageUtil.java
public static boolean isStringBase64(String data) { return Base64.isBase64(data); }