Example usage for javax.xml.bind DatatypeConverter parseBase64Binary

List of usage examples for javax.xml.bind DatatypeConverter parseBase64Binary

Introduction

In this page you can find the example usage for javax.xml.bind DatatypeConverter parseBase64Binary.

Prototype

public static byte[] parseBase64Binary(String lexicalXSDBase64Binary) 

Source Link

Document

Converts the string argument into an array of bytes.

Usage

From source file:it.geosolutions.geofence.core.model.Base64EncodersTest.java

@Test
public void testEq() {

    String msg1 = "this is the message to encode";

    String output_codec = new String(Base64.encodeBase64(msg1.getBytes()));
    String output_dconv = DatatypeConverter.printBase64Binary(msg1.getBytes());

    System.out.println("apache commons:    " + output_codec);
    System.out.println("DatatypeConverter: " + output_dconv);
    assertEquals(output_codec, output_dconv);

    byte[] back_codec = Base64.decodeBase64(output_dconv);
    byte[] back_dconv = DatatypeConverter.parseBase64Binary(output_dconv);

    Assert.assertTrue(Arrays.equals(msg1.getBytes(), back_codec));
    Assert.assertTrue(Arrays.equals(msg1.getBytes(), back_dconv));

}

From source file:com.openshift.restclient.utils.Base64Coder.java

/**
 * Decodes the given base64 encoded string. Returns <code>null</code> if the
 * given string is <code>null</code>.
 * //  w  w  w .j  av  a2  s.  co m
 * @param encoded
 *            the base64 encoded string
 * @return the decoded binary data
 */
public static byte[] decodeBinary(String encoded) {
    if (StringUtils.isEmpty(encoded)) {
        return null;
    }
    return DatatypeConverter.parseBase64Binary(encoded);
}

From source file:fr.inria.oak.paxquery.pact.operators.binary.ThetaLNOJoinOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    this.nullRecord = RecordOperations.createNullRecord(this.inputRecordsSignature2);

    String predEncoded = parameters.getString(PACTOperatorsConfiguration.PRED_BINARY.toString(), null);
    byte[] predBytes = DatatypeConverter.parseBase64Binary(predEncoded);
    this.pred = (BasePredicate) SerializationUtils.deserialize(predBytes);
}

From source file:fr.inria.oak.paxquery.pact.operators.unary.DuplicateEliminationOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    String dupElimColumnsEncoded = parameters
            .getString(PACTOperatorsConfiguration.DUP_ELIM_COLUMNS_BINARY.toString(), null);
    byte[] dupElimColumnsBytes = DatatypeConverter.parseBase64Binary(dupElimColumnsEncoded);
    final int[] dupElimColumns = (int[]) SerializationUtils.deserialize(dupElimColumnsBytes);
    this.dupElimColumns = dupElimColumns;
}

From source file:fr.inria.oak.paxquery.pact.operators.unary.GroupByOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    String groupByColumnsEncoded = parameters
            .getString(PACTOperatorsConfiguration.GROUP_BY_COLUMNS_BINARY.toString(), null);
    byte[] groupByColumnsBytes = DatatypeConverter.parseBase64Binary(groupByColumnsEncoded);
    final int[] groupByColumns = (int[]) SerializationUtils.deserialize(groupByColumnsBytes);
    this.groupByColumns = groupByColumns;

    String nestColumnsEncoded = parameters.getString(PACTOperatorsConfiguration.NEST_COLUMNS_BINARY.toString(),
            null);//from   w  w  w .ja  v  a  2s  .  c  o m
    byte[] nestColumnsBytes = DatatypeConverter.parseBase64Binary(nestColumnsEncoded);
    final int[] nestColumns = (int[]) SerializationUtils.deserialize(nestColumnsBytes);
    this.nestColumns = nestColumns;
}

From source file:com.vexsoftware.votifier.crypto.RSAIO.java

/**
 * Loads an RSA key pair from a directory. The directory must have the files
 * "public.key" and "private.key".//from w  w w  .  ja va  2 s. c  om
 * 
 * @param directory
 *            The directory to load from
 * @return The key pair
 * @throws Exception
 *             If an error occurs
 */
public static KeyPair load(File directory) throws Exception {
    // Read the public key file.
    File publicKeyFile = new File(directory + "/public.key");
    byte[] encodedPublicKey = FileUtils.readFileToByteArray(publicKeyFile);
    encodedPublicKey = DatatypeConverter.parseBase64Binary(new String(encodedPublicKey));

    // Read the private key file.
    File privateKeyFile = new File(directory + "/private.key");
    byte[] encodedPrivateKey = FileUtils.readFileToByteArray(privateKeyFile);
    encodedPrivateKey = DatatypeConverter.parseBase64Binary(new String(encodedPrivateKey));

    // Instantiate and return the key pair.
    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(encodedPublicKey);
    PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);
    PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedPrivateKey);
    PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);
    return new KeyPair(publicKey, privateKey);
}

From source file:fr.inria.oak.paxquery.pact.operators.binary.DisjLNOEquiJoinOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    this.nullRecord = RecordOperations.createNullRecord(this.inputRecordsSignature2);

    String predEncoded = parameters.getString(PACTOperatorsConfiguration.PRED_BINARY.toString(), null);
    byte[] predBytes = DatatypeConverter.parseBase64Binary(predEncoded);
    this.pred = (DisjunctivePredicate) SerializationUtils.deserialize(predBytes);

    this.predNumber = parameters.getInteger(PACTOperatorsConfiguration.PRED_INT.toString(), -1);
}

From source file:fr.inria.oak.paxquery.pact.operators.unary.FlattenOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    String unnestPathEncoded = parameters.getString(PACTOperatorsConfiguration.UNNEST_PATH_BINARY.toString(),
            null);//from  ww  w .j a  v  a  2 s.com
    byte[] unnestPathBytes = DatatypeConverter.parseBase64Binary(unnestPathEncoded);
    final int[] unnestPath = (int[]) SerializationUtils.deserialize(unnestPathBytes);
    this.unnestPath = unnestPath;
}

From source file:fr.inria.oak.paxquery.pact.operators.unary.PostLNOJoinWithAggregationOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    this.combinationColumn = parameters.getInteger(PACTOperatorsConfiguration.COMBINATION_COLUMN_INT.toString(),
            -1);//from  www  .j a  v  a2s. c  o m

    String aggregationTypeEncoded = parameters
            .getString(PACTOperatorsConfiguration.AGGREGATION_TYPE_BINARY.toString(), null);
    byte[] aggregationTypeBytes = DatatypeConverter.parseBase64Binary(aggregationTypeEncoded);
    final AggregationType aggregationType = (AggregationType) SerializationUtils
            .deserialize(aggregationTypeBytes);
    this.aggregationType = aggregationType;

    this.excludeNestedField = parameters
            .getBoolean(PACTOperatorsConfiguration.EXCLUDE_NESTED_FIELD_BOOLEAN.toString(), false);
}

From source file:fr.inria.oak.paxquery.pact.operators.binary.DisjEquiJoinOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    String predEncoded = parameters.getString(PACTOperatorsConfiguration.PRED_BINARY.toString(), null);
    byte[] predBytes = DatatypeConverter.parseBase64Binary(predEncoded);
    this.pred = (DisjunctivePredicate) SerializationUtils.deserialize(predBytes);

    this.predNumber = parameters.getInteger(PACTOperatorsConfiguration.PRED_INT.toString(), -1);
}