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

The following examples show how to use org.apache.commons.lang.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: ResponseBuilderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
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);
   }

}
 
Example 2
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
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()});
   }
}
 
Example 3
Source File: OcspRef.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
OcspRef(byte[] inOcspEncoded) {
   this.ocspEncoded = ArrayUtils.clone(inOcspEncoded);

   try {
      this.ocsp = (BasicOCSPResp)(new OCSPResp(this.ocspEncoded)).getResponseObject();
   } catch (Exception var3) {
      throw new IllegalArgumentException(var3);
   }
}
 
Example 4
Source File: BeIDConnectorExternalGui.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
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();
      }
   }
}
 
Example 5
Source File: AbstractConsultationBuilder.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
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;
   }
}
 
Example 6
Source File: Payload.java    From score with Apache License 2.0 5 votes vote down vote up
@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;
	}
}
 
Example 7
Source File: Identity.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setPhotoDigest(byte[] photoDigest) {
   this.photoDigest = ArrayUtils.clone(photoDigest);
}
 
Example 8
Source File: ByteArrayDatasource.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public ByteArrayDatasource(byte[] byteArray) {
   this.contentType = DEFAULT_CONTENT_TYPE;
   this.byteArray = ArrayUtils.clone(byteArray);
   this.contentType = DEFAULT_CONTENT_TYPE;
}
 
Example 9
Source File: ByteArrayDatasource.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getByteArray() {
   return ArrayUtils.clone(this.byteArray);
}
 
Example 10
Source File: Address.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setData(byte[] data) {
   this.data = ArrayUtils.clone(data);
}
 
Example 11
Source File: OcspRef.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getEncoded() {
   return ArrayUtils.clone(this.ocspEncoded);
}
 
Example 12
Source File: ByteArrayDatasource.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public ByteArrayDatasource(byte[] byteArray, String contentType) {
   this.contentType = DEFAULT_CONTENT_TYPE;
   this.byteArray = ArrayUtils.clone(byteArray);
   this.contentType = contentType;
}
 
Example 13
Source File: OcspRef.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getEncoded() {
   return ArrayUtils.clone(this.ocspEncoded);
}
 
Example 14
Source File: Identity.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getData() {
   return ArrayUtils.clone(this.data);
}
 
Example 15
Source File: OcspRef.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getEncoded() {
   return ArrayUtils.clone(this.ocspEncoded);
}
 
Example 16
Source File: UnsealedData.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getSignature() {
   return ArrayUtils.clone(this.signature);
}
 
Example 17
Source File: Identity.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getData() {
   return ArrayUtils.clone(this.data);
}
 
Example 18
Source File: BeIDInfo.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getPhoto() throws TechnicalConnectorException {
   return ArrayUtils.clone(this.photo);
}
 
Example 19
Source File: EncryptionTokenBuilder.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public EncryptionTokenBuilder.BuildStep withChallenge(byte[] challenge) {
   Validate.isTrue(ArrayUtils.isNotEmpty(challenge));
   this.challenge = ArrayUtils.clone(challenge);
   return this;
}
 
Example 20
Source File: Identity.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public byte[] getData() {
   return ArrayUtils.clone(this.data);
}