下面列出了org.apache.commons.lang.ArrayUtils#clone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static TimeStampToken getTimeStampToken(byte[] tsToken) throws TechnicalConnectorException {
byte[] cloneTsToken = ArrayUtils.clone(tsToken);
try {
cloneTsToken = ConnectorIOUtils.base64Decode(cloneTsToken, true);
return new TimeStampToken(new CMSSignedData(cloneTsToken));
} catch (TSPException var3) {
LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
} catch (IOException var4) {
LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
} catch (CMSException var5) {
LOG.error(var5.getClass().getSimpleName() + ": " + var5.getMessage());
throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
}
}
private void commonValidateMethod(SendResponseType responseType, Blob blob) throws InvalidBlobContentConnectorException, TechnicalConnectorException {
this.checkIfInitialized();
String neededXadesLevel = this.retrieveResponseXadesProperty();
Base64Binary xades = null;
if (responseType != null && responseType.getReturn() != null) {
xades = responseType.getReturn().getXadesT();
}
if (xades != null && xades.getValue() != null && !ArrayUtils.isEmpty(xades.getValue())) {
byte[] xadesByteArray = ArrayUtils.clone(xades.getValue());
AdvancedElectronicSignatureEnumeration xadesSignatureType = this.convertToSignatureType(neededXadesLevel);
SignatureBuilder builder = SignatureBuilderFactory.getSignatureBuilder(xadesSignatureType);
Element sigElement = ConnectorXmlUtils.toElement(xadesByteArray);
Map<String, Object> optionMap = new HashMap();
SignatureVerificationResult result = builder.verify(this.reassemblyMessage(responseType, sigElement), xadesByteArray, optionMap);
if (result.getErrors().size() != 0) {
this.createInvalidBlobContentConnectorException(blob, result, xades);
}
} else if (!"none".equals(neededXadesLevel)) {
throw new InvalidBlobContentConnectorException(InvalidBlobContentConnectorExceptionValues.XADESVALUE_NULL, blob);
}
}
public char[] obtainPIN(int triesLeft, PINPurpose type) throws UserCancelledException {
if (!this.pincodeMap.containsKey(type)) {
char[] result = this.backup.obtainPIN(triesLeft, type);
try {
this.pincodeMap.put(type, new SecureString(result));
} catch (Exception var5) {
LOG.error(var5.getClass().getSimpleName() + ":" + var5.getMessage(), var5);
}
return ArrayUtils.clone(result);
} else {
SecureString content = (SecureString)this.pincodeMap.get(type);
if (this.triesLeft == null) {
this.triesLeft = triesLeft;
} else if (this.triesLeft.compareTo(triesLeft) != 0) {
LOG.warn("Second attempt detected: reseting pincode.");
this.pincodeMap.remove(type);
throw new UserCancelledException();
}
try {
if (content != null && content.getValue().length != 0) {
return ArrayUtils.clone(content.getValue());
} else {
LOG.error("No pincode detected.");
throw new UserCancelledException();
}
} catch (Exception var6) {
LOG.error(var6.getClass().getSimpleName() + ":" + var6.getMessage(), var6);
throw new UserCancelledException();
}
}
}
protected final byte[] handleAndDecryptIfNeeded(byte[] data, boolean encrypted, AbstractConsultationBuilder.ExceptionContainer<?> container) throws TechnicalConnectorException, EhboxBusinessConnectorException {
if (ArrayUtils.isEmpty(data)) {
return data;
} else {
byte[] byteVal = ArrayUtils.clone(data);
if (ConfigFactory.getConfigValidator().getBooleanProperty("ehboxv3.try.to.base64decode.content", true)) {
byteVal = ConnectorIOUtils.base64Decode(byteVal, false);
}
if (encrypted) {
if (SessionUtil.getEncryptionCrypto() == null) {
throw new EhboxBusinessConnectorException(EhboxBusinessConnectorExceptionValues.CRYPTO_NOT_PROPERLY_INITIALIZED, (Throwable)null, new Object[0]);
}
try {
byteVal = SessionUtil.getEncryptionCrypto().unseal(Crypto.SigningPolicySelector.WITH_NON_REPUDIATION, byteVal).getContentAsByte();
} catch (UnsealConnectorException var8) {
UnsealConnectorException e = var8;
container.exceptions.add(var8);
try {
byteVal = ConnectorExceptionUtils.processUnsealConnectorException(e);
} catch (UnsealConnectorException var7) {
LOG.error("unrecoverable unsealException occurred while decrypting ehbox content , returning null as message , error : " + var7.getMessage());
throw new EhboxCryptoException(var7, (Message)null);
}
}
}
return byteVal;
}
}
@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")
@Override
public Object clone() {
try {
Payload cloned = (Payload) super.clone();
cloned.data = ArrayUtils.clone(data);
return cloned;
} catch (CloneNotSupportedException e) {
System.out.println(e);
return null;
}
}
OcspRef(byte[] inOcspEncoded) {
this.ocspEncoded = ArrayUtils.clone(inOcspEncoded);
try {
this.ocsp = (BasicOCSPResp)(new OCSPResp(this.ocspEncoded)).getResponseObject();
} catch (Exception var3) {
throw new IllegalArgumentException(var3);
}
}
public byte[] getData() {
return ArrayUtils.clone(this.data);
}
public byte[] getData() {
return ArrayUtils.clone(this.data);
}
public EncryptionTokenBuilder.BuildStep withChallenge(byte[] challenge) {
Validate.isTrue(ArrayUtils.isNotEmpty(challenge));
this.challenge = ArrayUtils.clone(challenge);
return this;
}
public byte[] getPhoto() throws TechnicalConnectorException {
return ArrayUtils.clone(this.photo);
}
public byte[] getData() {
return ArrayUtils.clone(this.data);
}
public byte[] getSignature() {
return ArrayUtils.clone(this.signature);
}
public byte[] getEncoded() {
return ArrayUtils.clone(this.ocspEncoded);
}
public void setPhotoDigest(byte[] photoDigest) {
this.photoDigest = ArrayUtils.clone(photoDigest);
}
public byte[] getEncoded() {
return ArrayUtils.clone(this.ocspEncoded);
}
public ByteArrayDatasource(byte[] byteArray, String contentType) {
this.contentType = DEFAULT_CONTENT_TYPE;
this.byteArray = ArrayUtils.clone(byteArray);
this.contentType = contentType;
}
public byte[] getEncoded() {
return ArrayUtils.clone(this.ocspEncoded);
}
public void setData(byte[] data) {
this.data = ArrayUtils.clone(data);
}
public byte[] getByteArray() {
return ArrayUtils.clone(this.byteArray);
}
public ByteArrayDatasource(byte[] byteArray) {
this.contentType = DEFAULT_CONTENT_TYPE;
this.byteArray = ArrayUtils.clone(byteArray);
this.contentType = DEFAULT_CONTENT_TYPE;
}