Java Code Examples for org.apache.commons.net.util.Base64#decodeBase64()

The following examples show how to use org.apache.commons.net.util.Base64#decodeBase64() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SftpClient.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
@Override
public int check( String host, byte[] key ) {

    host = host.replace("[", "").replace("]", "").split(":")[0]; // get only the IP address of the server

    if (knownHostsMap.get(host) == null) {
        log.error("The presented trust store certificates could not match any of the server provided ones");
        return HostKeyRepository.NOT_INCLUDED;
    }
    Set<byte[]> keys = knownHostsMap.get(host);
    for (byte[] key1 : keys) {
        key1 = Base64.decodeBase64(key1); // we must decode the key from the client trust store first
        if (Arrays.equals(key, key1)) {
            log.info("Server certificate trusted.");
            return HostKeyRepository.OK;
        }
    }
    log.error("The presented trust store certificates could not match any of the server provided ones");
    return HostKeyRepository.NOT_INCLUDED;

}
 
Example 2
Source File: AbstractStorageManager.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
/**
 * Get Disk Ids by Volume Bytes
 */
private int[] getDiskIds(VolumeId[] volumeIds) {
  int[] diskIds = new int[volumeIds.length];
  for (int i = 0; i < volumeIds.length; i++) {
    int diskId = -1;
    if (volumeIds[i] != null && volumeIds[i].isValid()) {
      String volumeIdString = volumeIds[i].toString();
      byte[] volumeIdBytes = Base64.decodeBase64(volumeIdString);

      if (volumeIdBytes.length == 4) {
        diskId = Bytes.toInt(volumeIdBytes);
      } else if (volumeIdBytes.length == 1) {
        diskId = (int) volumeIdBytes[0];  // support hadoop-2.0.2
      }
    }
    diskIds[i] = diskId;
  }
  return diskIds;
}
 
Example 3
Source File: UpdateVMCmd.java    From cosmic with Apache License 2.0 5 votes vote down vote up
public OptimiseFor getOptimiseFor() {
    if (optimiseFor != null) {
        if (getHttpMethod() == HTTPMethod.POST) {
            optimiseFor = new String(Base64.decodeBase64(this.optimiseFor));
        }
        return OptimiseFor.valueOf(optimiseFor);
    } else {
        return OptimiseFor.Generic;
    }
}
 
Example 4
Source File: UpdateVMCmd.java    From cosmic with Apache License 2.0 5 votes vote down vote up
public ComplianceStatus getComplianceStatus() {
    if (complianceStatus == null || complianceStatus.isEmpty()) {
        return null;
    }

    if (getHttpMethod() == HTTPMethod.POST) {
        complianceStatus = new String(Base64.decodeBase64(this.complianceStatus));
    }

    return ComplianceStatus.valueOf(complianceStatus);
}
 
Example 5
Source File: UpdateVPCCmd.java    From cosmic with Apache License 2.0 5 votes vote down vote up
public ComplianceStatus getComplianceStatus() {
    if (complianceStatus == null || complianceStatus.isEmpty()) {
        return null;
    }

    if (getHttpMethod() == HTTPMethod.POST) {
        complianceStatus = new String(Base64.decodeBase64(this.complianceStatus));
    }

    return ComplianceStatus.valueOf(complianceStatus);
}
 
Example 6
Source File: Nd4jBase64.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a set of arrays
 * from base 64 that is tab delimited.
 * @param base64 the base 64 that's tab delimited
 * @return the set of arrays
 */
public static INDArray[] arraysFromBase64(String base64) throws IOException {
    String[] base64Arr = base64.split("\t");
    INDArray[] ret = new INDArray[base64Arr.length];
    for (int i = 0; i < base64Arr.length; i++) {
        byte[] decode = Base64.decodeBase64(base64Arr[i]);
        ByteArrayInputStream bis = new ByteArrayInputStream(decode);
        DataInputStream dis = new DataInputStream(bis);
        INDArray predict = Nd4j.read(dis);
        ret[i] = predict;
    }
    return ret;
}
 
Example 7
Source File: Nd4jBase64.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * Create an ndarray from a base 64
 * representation
 * @param base64 the base 64 to convert
 * @return the ndarray from base 64
 * @throws IOException
 */
public static INDArray fromBase64(String base64) throws IOException {
    byte[] arr = Base64.decodeBase64(base64);
    ByteArrayInputStream bis = new ByteArrayInputStream(arr);
    DataInputStream dis = new DataInputStream(bis);
    INDArray predict = Nd4j.read(dis);
    return predict;
}
 
Example 8
Source File: Nd4jBase64.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * Create an ndarray from a base 64
 * representation
 * @param base64 the base 64 to convert
 * @return the ndarray from base 64
 */
public static INDArray fromBase64(String base64) {
    byte[] arr = Base64.decodeBase64(base64);
    ByteArrayInputStream bis = new ByteArrayInputStream(arr);
    DataInputStream dis = new DataInputStream(bis);
    return Nd4j.read(dis);
}
 
Example 9
Source File: HiveKuduTableInputFormat.java    From HiveKudu-Handler with Apache License 2.0 4 votes vote down vote up
@Override
public void setConf(Configuration entries) {
    LOG.warn("I was called : setConf");
    this.conf = new Configuration(entries);

    String tableName = conf.get(INPUT_TABLE_KEY);
    String masterAddresses = conf.get(MASTER_ADDRESSES_KEY);
    this.operationTimeoutMs = conf.getLong(OPERATION_TIMEOUT_MS_KEY,
            AsyncKuduClient.DEFAULT_OPERATION_TIMEOUT_MS);
    this.nameServer = conf.get(NAME_SERVER_KEY);
    this.cacheBlocks = conf.getBoolean(SCAN_CACHE_BLOCKS, false);

    LOG.warn(" the master address here is " + masterAddresses);

    this.client = new KuduClient.KuduClientBuilder(masterAddresses)
            .defaultOperationTimeoutMs(operationTimeoutMs)
            .build();
    try {
        this.table = client.openTable(tableName);
    } catch (Exception ex) {
        throw new RuntimeException("Could not obtain the table from the master, " +
                "is the master running and is this table created? tablename=" + tableName + " and " +
                "master address= " + masterAddresses, ex);
    }

    //String projectionConfig = conf.get(COLUMN_PROJECTION_KEY);
    String projectionConfig = "id,name";
    if (projectionConfig == null || projectionConfig.equals("*")) {
        this.projectedCols = null; // project the whole table
    } else if ("".equals(projectionConfig)) {
        this.projectedCols = new ArrayList<>();
    } else {
        this.projectedCols = Lists.newArrayList(Splitter.on(',').split(projectionConfig));

        // Verify that the column names are valid -- better to fail with an exception
        // before we submit the job.
        Schema tableSchema = table.getSchema();
        for (String columnName : projectedCols) {
            if (tableSchema.getColumn(columnName) == null) {
                throw new IllegalArgumentException("Unknown column " + columnName);
            }
        }
    }

    String encodedPredicates = conf.get(ENCODED_COLUMN_RANGE_PREDICATES_KEY, "");
    rawPredicates = Base64.decodeBase64(encodedPredicates);
}
 
Example 10
Source File: EagleBase64Wrapper.java    From Eagle with Apache License 2.0 4 votes vote down vote up
public static byte[] decode(String input){
	return Base64.decodeBase64(input);
}
 
Example 11
Source File: EagleBase64Wrapper.java    From eagle with Apache License 2.0 4 votes vote down vote up
public static byte[] decode(String input) {
    return Base64.decodeBase64(input);
}