Example usage for org.apache.commons.codec.digest DigestUtils md5

List of usage examples for org.apache.commons.codec.digest DigestUtils md5

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest DigestUtils md5.

Prototype

public static byte[] md5(String data) 

Source Link

Usage

From source file:org.artifactory.message.ArtifactoryUpdatesServiceImpl.java

/**
 * Generate unique message id./*from   ww w.  ja v  a2 s.c om*/
 *
 * @param body message body
 * @return unique message id
 */
private String messageId(String body) {
    return new String(Base64.encodeBase64(DigestUtils.md5(body)), Charsets.UTF_8).replaceAll("=", "")
            .replaceAll("\\+", "-").replaceAll("/", "_");
}

From source file:org.bigmouth.nvwa.utils.degist.NativeAesUtils.java

public static void main(String[] args) {
    try {/*from   w  w  w  .jav a 2  s.c  o  m*/
        System.out.println(encryptAES(DigestUtils.md5(
                "CardCode=714&CardValue=100&ChannelId=3000054&ChannelOrderId=O20150623174253414&OpenType=1&OrderTime=2015-06-23 09:42:53&PhoneNum=078A429726BCA0B49781ADF31B52EFCA&RealFee=0&SaleDiscount=0.75&TransactionId=3000054002015062317425353415"),
                "3LBx;8G-bq-l#@nk"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.bonitasoft.engine.bpm.bar.ProcessDefinitionBARContribution.java

protected String getProcessInfos(final String infos) {
    return Base64.encodeBase64String(DigestUtils.md5(infos)).trim();
}

From source file:org.bonitasoft.engine.identity.impl.MD5CredentialsEncrypter.java

@Override
public String hash(final String password) {
    final byte[] hash = DigestUtils.md5(password);
    return Base64.encodeBase64String(hash);
}

From source file:org.callimachusproject.auth.CookieAuthenticationManager.java

private String getPassword(int hour, String username, String iri, String nonce) throws IOException {
    int size = secret.length + username.length() + iri.length() + nonce.length();
    ByteArrayOutputStream baos = new ByteArrayOutputStream(size * 2);
    baos.write(secret);//from  w w  w  .  j ava 2  s  .  co  m
    for (int i = 0, n = Integer.SIZE / Byte.SIZE; i < n; i++) {
        baos.write((byte) hour);
        hour >>= Byte.SIZE;
    }
    baos.write(getIdentifier().getBytes("UTF-8"));
    baos.write(username.getBytes("UTF-8"));
    baos.write(iri.getBytes("UTF-8"));
    baos.write(nonce.getBytes("UTF-8"));
    return new String(Hex.encodeHex(DigestUtils.md5(baos.toByteArray())));
}

From source file:org.callimachusproject.auth.DigestAuthenticationManager.java

private String md5(String text) {
    return new String(Hex.encodeHex(DigestUtils.md5(text)));
}

From source file:org.commonjava.indy.folo.ftest.report.UseChecksumFromTransferDecoratorForTrackingRecord_Sha1FileTest.java

@BMRules(rules = {
        @BMRule(name = "setup_metadata_countdown", targetClass = "^org.commonjava.indy.content.ContentDigester", isInterface = true, targetMethod = "<init>", targetLocation = "ENTRY", action = "System.out.println(\"SETUP COUNTDOWN\"); createCountDown(\"COUNTDOWN\", 1);"),
        @BMRule(name = "prevent_successive_metadata_additions", targetClass = "^org.commonjava.indy.content.ContentDigester", isInterface = true, targetMethod = "addMetadata", targetLocation = "ENTRY", binding = "path:String = $1.getPath();", condition = "path.endsWith(\"path/to/foo.class\") && countDown(\"COUNTDOWN\")", action = "System.out.println(\"RETURN NULL\"); return null;") })
@Test/*from   w  ww  .  jav  a 2 s  .com*/
public void run() throws Exception {
    final String trackingId = newName();
    final String repoId = "repo";
    final String path = "/org/bar/foo/1/foo-1.pom.sha1";

    final InputStream stream = new ByteArrayInputStream(
            DigestUtils.md5("This is a test with the same content each time."));

    server.expect(server.formatUrl(repoId, path), 200, stream);

    RemoteRepository rr = new RemoteRepository(repoId, server.formatUrl(repoId));
    rr = client.stores().create(rr, "adding test remote", RemoteRepository.class);

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final InputStream in = client.module(IndyFoloContentClientModule.class).get(trackingId, remote, repoId,
            path);

    IOUtils.copy(in, baos);
    in.close();

    final byte[] bytes = baos.toByteArray();

    final String md5 = md5Hex(bytes);
    final String sha256 = sha256Hex(bytes);

    assertThat(md5, equalTo(DigestUtils.md5Hex(bytes)));
    assertThat(sha256, equalTo(DigestUtils.sha256Hex(bytes)));

    waitForEventPropagation();

    assertThat(client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(trackingId), equalTo(true));

    final TrackedContentDTO report = client.module(IndyFoloAdminClientModule.class)
            .getTrackingReport(trackingId);
    assertThat(report, notNullValue());

    final Set<TrackedContentEntryDTO> downloads = report.getDownloads();

    assertThat(downloads, notNullValue());
    assertThat(downloads.size(), equalTo(1));

    final TrackedContentEntryDTO entry = downloads.iterator().next();

    System.out.println(entry);

    assertThat(entry, notNullValue());
    assertThat(entry.getStoreKey(), equalTo(new StoreKey(remote, repoId)));
    assertThat(entry.getPath(), equalTo(path));
    assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(remote, repoId, path)));
    assertThat(entry.getOriginUrl(), equalTo(server.formatUrl(repoId, path)));
    assertThat(entry.getMd5(), equalTo(md5));
    assertThat(entry.getSha256(), equalTo(sha256));
}

From source file:org.eclipse.winery.yaml.common.Utils.java

public static byte[] getHashValueOfFile(File file) throws IOException {
    return DigestUtils.md5(new FileInputStream(file));
}

From source file:org.gbif.occurrence.processor.parsing.FragmentParserTest.java

@Test
public void testAbcd206() {
    OccurrenceSchemaType schema = OccurrenceSchemaType.ABCD_2_0_6;
    UUID datasetKey = UUID.randomUUID();
    Fragment frag = new Fragment(datasetKey, abcd206Single.getBytes(),
            DigestUtils.md5(abcd206Single.getBytes()), Fragment.FragmentType.XML, EndpointType.BIOCASE,
            new Date(), 1, schema, null, null);
    frag.setKey(1);/*w w  w  . ja v  a  2 s  .  com*/

    VerbatimOccurrence got = FragmentParser.parse(frag);
    assertNotNull(got);
    assertEquals("BGBM", got.getVerbatimField(DwcTerm.institutionCode));
    assertEquals("AlgaTerra", got.getVerbatimField(DwcTerm.collectionCode));
    assertEquals("5834", got.getVerbatimField(DwcTerm.catalogNumber));
    assertEquals(datasetKey, got.getDatasetKey());
    assertNull(got.getVerbatimField(GbifInternalTerm.unitQualifier));

    assertEquals(1, got.getKey().intValue());
    assertEquals("Tetraedron caudatum (Corda) Hansg.", got.getVerbatimField(DwcTerm.scientificName));
    assertEquals("52.123456", got.getVerbatimField(DwcTerm.decimalLatitude));
    assertEquals("13.123456", got.getVerbatimField(DwcTerm.decimalLongitude));
    assertEquals("50", got.getVerbatimField(DwcTerm.coordinateUncertaintyInMeters));
    assertEquals("400", got.getVerbatimField(DwcTerm.minimumElevationInMeters));
    assertEquals("500", got.getVerbatimField(DwcTerm.maximumElevationInMeters));
    assertEquals("DE", got.getVerbatimField(DwcTerm.country));
    assertEquals("Kusber, W.-H.", got.getVerbatimField(DwcTerm.recordedBy));
    assertEquals("Nikolassee, Berlin", got.getVerbatimField(DwcTerm.locality));
    assertEquals("1987-04-13T00:00:00", got.getVerbatimField(DwcTerm.eventDate));
    assertEquals("HumanObservation", got.getVerbatimField(DwcTerm.basisOfRecord));
    assertEquals("Kusber, W.-H.", got.getVerbatimField(DwcTerm.identifiedBy));
    assertEquals("Holotype", got.getVerbatimField(DwcTerm.typeStatus));
    assertEquals("Tetraedron caudatum (Corda) Hansg.", got.getVerbatimField(GbifTerm.typifiedName));

    assertNotNull(got.getExtensions().get(Extension.MULTIMEDIA));
    List<Map<Term, String>> mediaObjects = got.getExtensions().get(Extension.MULTIMEDIA);
    assertEquals(2, mediaObjects.size());
    Map<Term, String> medium = mediaObjects.get(0);
    assertEquals("http://www.tierstimmenarchiv.de/recordings/Ailuroedus_buccoides_V2010_04_short.mp3",
            medium.get(DcTerm.identifier));
    assertEquals(
            "http://www.tierstimmenarchiv.de/webinterface/contents/showdetails.php?edit=-1&unique_id=TSA:Ailuroedus_buccoides_V_2010_4_1&autologin=true",
            medium.get(DcTerm.references));
    assertEquals("audio/mp3", medium.get(DcTerm.format));
    assertEquals("CC BY-NC-ND (Attribution for non commercial use only and without derivative)",
            medium.get(DcTerm.license));

}

From source file:org.gbif.occurrence.processor.parsing.FragmentParserTest.java

@Test
public void testDwc14() {
    OccurrenceSchemaType schema = OccurrenceSchemaType.DWC_1_4;
    UUID datasetKey = UUID.randomUUID();
    Fragment frag = new Fragment(datasetKey, dwc14.getBytes(), DigestUtils.md5(dwc14.getBytes()),
            Fragment.FragmentType.XML, EndpointType.DIGIR, new Date(), 1, schema, null, null);
    frag.setKey(123);//from   w ww. ja v a  2s . com

    VerbatimOccurrence got = FragmentParser.parse(frag);
    assertNotNull(got);

    assertEquals("UGENT", got.getVerbatimField(DwcTerm.institutionCode));
    assertEquals("vertebrata", got.getVerbatimField(DwcTerm.collectionCode));
    assertEquals("50058", got.getVerbatimField(DwcTerm.catalogNumber));
    assertEquals(datasetKey, got.getDatasetKey());
    assertNull(got.getVerbatimField(GbifInternalTerm.unitQualifier));

    assertEquals("Alouatta villosa Gray, 1845", got.getVerbatimField(DwcTerm.scientificName));
    assertEquals("Gray, 1845", got.getVerbatimField(DwcTerm.scientificNameAuthorship));
    assertEquals("Animalia", got.getVerbatimField(DwcTerm.kingdom));
    assertEquals("Chordata", got.getVerbatimField(DwcTerm.phylum));
    assertEquals("Mammalia", got.getVerbatimField(DwcTerm.class_));
    assertEquals("Primates", got.getVerbatimField(DwcTerm.order));
    assertEquals("Atelidae", got.getVerbatimField(DwcTerm.family));
    assertEquals("Alouatta", got.getVerbatimField(DwcTerm.genus));
    assertEquals("villosa", got.getVerbatimField(DwcTerm.specificEpithet));
    assertEquals("25", got.getVerbatimField(DwcTerm.coordinateUncertaintyInMeters));
    assertEquals("200", got.getVerbatimField(DwcTerm.minimumElevationInMeters));
    assertEquals("400", got.getVerbatimField(DwcTerm.maximumElevationInMeters));
    assertEquals("PreservedSpecimen", got.getVerbatimField(DwcTerm.basisOfRecord));
    assertEquals("123", got.getVerbatimField(GbifTerm.gbifID));
    assertEquals("Holotype", got.getVerbatimField(DwcTerm.typeStatus));
}