下面列出了org.apache.commons.lang3.ArrayUtils#clone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
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()});
}
}
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()});
}
}
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;
}
public void setVolumes(Volume[] volumes) {
this.volumes = ArrayUtils.clone(volumes);
}
@SuppressWarnings("PMD")
public Object[] getArgs() {
return ArrayUtils.clone(args);
}
public void setDefaultValues(double[] defaultValues)
{
this.defaultValues = ArrayUtils.clone(defaultValues);
}
public ServiceCallInput(String methodName, Object[] args, Class apiType) {
this.apiType = apiType;
this.methodName = methodName;
this.args = ArrayUtils.clone(args);
}
public void setReceiver(String[] receiver) {
this.receiver = ArrayUtils.clone(receiver);
}
public void setIaasConfigs(IaasConfig[] iaasConfigs) {
this.iaasConfigs = ArrayUtils.clone(iaasConfigs);
}
public double[] getDefaultValues()
{
return ArrayUtils.clone(defaultValues);
}
public BytesColumn(byte[] bytes) {
super(ArrayUtils.clone(bytes), Column.Type.BYTES, null == bytes ? 0
: bytes.length);
}
/**
* <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);
}
/**
* 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);
}
/**
* 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);
}
/**
* 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);
}
/**
* <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);
}
/**
* Specify the translators to be used at creation time.
*
* @param translators CharSequenceTranslator array to aggregate
*/
public AggregateTranslator(CharSequenceTranslator... translators) {
this.translators = ArrayUtils.clone(translators);
}
/**
* 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;
}