Java Code Examples for org.apache.commons.lang3.ArrayUtils#clone()

The following examples show how to use org.apache.commons.lang3.ArrayUtils#clone() . 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: MrsPyramidMetadata.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
public String[][] getCategories()
{
  if (categories == null)
  {
    return null;
  }


  String[][] c = new String[categories.length][];
  for (int i = 0; i < categories.length; i++)
  {
    if (categories[i] != null)
    {
      c[i] = ArrayUtils.clone(categories[i]);
    }
  }

  return c;
}
 
Example 2
Source File: CmsSignatureBuilder.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public SignatureVerificationResult verify(byte[] content, byte[] signature, Map<String, Object> options) throws TechnicalConnectorException {
   SignatureVerificationResult result = new SignatureVerificationResult();

   try {
      CMSSignedData signedContent = new CMSSignedData(signature);
      byte[] signedData;
      if (signedContent.getSignedContent() == null) {
         LOG.info("Signature has no ecapsulated signature. Adding content.");
         signedData = (new CMSSignedData(new CMSProcessableByteArray(content), signature)).getEncoded();
      } else {
         signedData = ArrayUtils.clone(signature);
      }

      return this.verify(signedData, options);
   } catch (CMSException var7) {
      LOG.error("Unable to verify signature", var7);
      result.getErrors().add(SignatureVerificationError.SIGNATURE_COULD_NOT_BE_VERIFIED);
   } catch (IOException var8) {
      LOG.error("Unable to verify signature", var8);
      result.getErrors().add(SignatureVerificationError.SIGNATURE_COULD_NOT_BE_VERIFIED);
   }

   return result;
}
 
Example 3
Source File: CmsSignatureBuilder.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public byte[] sign(Credential signatureCredential, byte[] byteToSign, Map<String, Object> options) throws TechnicalConnectorException {
   byte[] contentToSign = ArrayUtils.clone(byteToSign);
   Map<String, Object> optionMap = new HashMap();
   if (options != null) {
      optionMap.putAll(options);
   }

   this.validateInput(signatureCredential, contentToSign);

   try {
      CMSTypedData content = new CMSProcessableByteArray(contentToSign);
      CMSSignedDataGenerator generator = new CMSSignedDataGenerator();
      String signatureAlgorithm = (String)SignatureUtils.getOption("signatureAlgorithm", optionMap, "Sha1WithRSA");
      JcaSignerInfoGeneratorBuilder signerInfoGeneratorBuilder = new JcaSignerInfoGeneratorBuilder((new JcaDigestCalculatorProviderBuilder()).build());
      ContentSigner contentSigner = (new JcaContentSignerBuilder(signatureAlgorithm)).build(signatureCredential.getPrivateKey());
      CMSAttributeTableGenerator cmsAttributeTableGenerator = (CMSAttributeTableGenerator)SignatureUtils.getOption("signedAttributeGenerator", optionMap, new DefaultSignedAttributeTableGenerator());
      signerInfoGeneratorBuilder.setSignedAttributeGenerator(cmsAttributeTableGenerator);
      generator.addSignerInfoGenerator(signerInfoGeneratorBuilder.build(contentSigner, signatureCredential.getCertificate()));
      Certificate[] certificateChain = signatureCredential.getCertificateChain();
      if (certificateChain != null && certificateChain.length > 0) {
         generator.addCertificates(new JcaCertStore(Arrays.asList(certificateChain)));
      }

      boolean encapsulate = (Boolean)SignatureUtils.getOption("encapsulate", optionMap, Boolean.FALSE);
      return generator.generate(content, encapsulate).getEncoded();
   } catch (Exception var14) {
      LOG.error(var14.getMessage(), var14);
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE, var14, new Object[]{var14.getClass().getSimpleName() + " : " + var14.getMessage()});
   }
}
 
Example 4
Source File: Config.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
public Config(String id, String parentId, String name, Type type, Condition condition, Data data, Item[] items,
        String root, Map<String, Object> params) {
    super();
    this.id = id;
    this.parentId = parentId;
    this.name = name;
    this.type = type;
    this.condition = condition;
    this.data = data;
    this.items = ArrayUtils.clone(items);
    this.root = root;
    this.params = params;
}
 
Example 5
Source File: CmsSignatureBuilder.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public byte[] sign(Credential signatureCredential, byte[] byteToSign, Map<String, Object> options) throws TechnicalConnectorException {
   byte[] contentToSign = ArrayUtils.clone(byteToSign);
   Map<String, Object> optionMap = new HashMap();
   if (options != null) {
      optionMap.putAll(options);
   }

   this.validateInput(signatureCredential, contentToSign);

   try {
      CMSTypedData content = new CMSProcessableByteArray(contentToSign);
      CMSSignedDataGenerator generator = new CMSSignedDataGenerator();
      String signatureAlgorithm = (String)SignatureUtils.getOption("signatureAlgorithm", optionMap, "Sha1WithRSA");
      JcaSignerInfoGeneratorBuilder signerInfoGeneratorBuilder = new JcaSignerInfoGeneratorBuilder((new JcaDigestCalculatorProviderBuilder()).build());
      ContentSigner contentSigner = (new JcaContentSignerBuilder(signatureAlgorithm)).build(signatureCredential.getPrivateKey());
      CMSAttributeTableGenerator cmsAttributeTableGenerator = (CMSAttributeTableGenerator)SignatureUtils.getOption("signedAttributeGenerator", optionMap, new DefaultSignedAttributeTableGenerator());
      signerInfoGeneratorBuilder.setSignedAttributeGenerator(cmsAttributeTableGenerator);
      generator.addSignerInfoGenerator(signerInfoGeneratorBuilder.build(contentSigner, signatureCredential.getCertificate()));
      Certificate[] certificateChain = signatureCredential.getCertificateChain();
      if (certificateChain != null && certificateChain.length > 0) {
         generator.addCertificates(new JcaCertStore(Arrays.asList(certificateChain)));
      }

      boolean encapsulate = (Boolean)SignatureUtils.getOption("encapsulate", optionMap, Boolean.FALSE);
      return generator.generate(content, encapsulate).getEncoded();
   } catch (Exception var14) {
      LOG.error(var14.getMessage(), var14);
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE, var14, new Object[]{var14.getClass().getSimpleName() + " : " + var14.getMessage()});
   }
}
 
Example 6
Source File: BytesColumn.java    From DataLink with Apache License 2.0 4 votes vote down vote up
public BytesColumn(byte[] bytes) {
	super(ArrayUtils.clone(bytes), Column.Type.BYTES, null == bytes ? 0
			: bytes.length);
}
 
Example 7
Source File: ServiceCallInput.java    From Ratel with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("PMD")
public Object[] getArgs() {

    return ArrayUtils.clone(args);
}
 
Example 8
Source File: MrsPyramidMetadata.java    From mrgeo with Apache License 2.0 4 votes vote down vote up
public void setDefaultValues(double[] defaultValues)
{
  this.defaultValues = ArrayUtils.clone(defaultValues);
}
 
Example 9
Source File: ServiceCallInput.java    From Ratel with Apache License 2.0 4 votes vote down vote up
public ServiceCallInput(String methodName, Object[] args, Class apiType) {
    this.apiType = apiType;
    this.methodName = methodName;
    this.args = ArrayUtils.clone(args);
}
 
Example 10
Source File: RevokeMessageRO.java    From xechat with MIT License 4 votes vote down vote up
public void setReceiver(String[] receiver) {
    this.receiver = ArrayUtils.clone(receiver);
}
 
Example 11
Source File: Cartridge.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
public void setIaasConfigs(IaasConfig[] iaasConfigs) {
    this.iaasConfigs = ArrayUtils.clone(iaasConfigs);
}
 
Example 12
Source File: MrsPyramidMetadata.java    From mrgeo with Apache License 2.0 4 votes vote down vote up
public double[] getDefaultValues()
{
  return ArrayUtils.clone(defaultValues);
}
 
Example 13
Source File: InstanceContext.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
public void setVolumes(Volume[] volumes) {
    this.volumes = ArrayUtils.clone(volumes);
}
 
Example 14
Source File: ExceptionUtils.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * <p>Returns the default names used when searching for the cause of an exception.</p>
 *
 * <p>This may be modified and used in the overloaded getCause(Throwable, String[]) method.</p>
 *
 * @return cloned array of the default method names
 * @since 3.0
 * @deprecated This feature will be removed in Lang 4.0
 */
@Deprecated
public static String[] getDefaultCauseMethodNames() {
    return ArrayUtils.clone(CAUSE_METHOD_NAMES);
}
 
Example 15
Source File: StrTokenizer.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Reset this tokenizer, giving it a new input string to parse.
 * In this manner you can re-use a tokenizer with the same settings
 * on multiple input lines.
 *
 * @param input  the new character array to tokenize, not cloned, null sets no text to parse
 * @return this, to enable chaining
 */
public StrTokenizer reset(char[] input) {
    reset();
    this.chars = ArrayUtils.clone(input);
    return this;
}
 
Example 16
Source File: AggregateTranslator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Specify the translators to be used at creation time. 
 *
 * @param translators CharSequenceTranslator array to aggregate
 */
public AggregateTranslator(CharSequenceTranslator... translators) {
    this.translators = ArrayUtils.clone(translators);
}
 
Example 17
Source File: AggregateTranslator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Specify the translators to be used at creation time. 
 *
 * @param translators CharSequenceTranslator array to aggregate
 */
public AggregateTranslator(final CharSequenceTranslator... translators) {
    this.translators = ArrayUtils.clone(translators);
}
 
Example 18
Source File: StrTokenizer.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a tokenizer splitting on space, tab, newline and formfeed
 * as per StringTokenizer.
 *
 * @param input  the string which is to be parsed, not cloned
 */
public StrTokenizer(char[] input) {
    super();
    this.chars = ArrayUtils.clone(input);
}
 
Example 19
Source File: StrTokenizer.java    From scheduling with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Constructs a tokenizer splitting on space, tab, newline and formfeed
 * as per StringTokenizer.
 *
 * @param input  the string which is to be parsed, not cloned
 */
public StrTokenizer(final char[] input) {
    super();
    this.chars = ArrayUtils.clone(input);
}
 
Example 20
Source File: ExceptionUtils.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * <p>Returns the default names used when searching for the cause of an exception.</p>
 *
 * <p>This may be modified and used in the overloaded getCause(Throwable, String[]) method.</p>
 *
 * @return cloned array of the default method names
 * @since 3.0
 * @deprecated This feature will be removed in Lang 4.0
 */
@Deprecated
public static String[] getDefaultCauseMethodNames() {
    return ArrayUtils.clone(CAUSE_METHOD_NAMES);
}