com.fitbur.bouncycastle.cms.RecipientOperator Maven / Gradle / Ivy
package com.fitbur.bouncycastle.cms;
import java.io.InputStream;
import com.fitbur.bouncycastle.asn1.x509.AlgorithmIdentifier;
import com.fitbur.bouncycastle.operator.InputDecryptor;
import com.fitbur.bouncycastle.operator.MacCalculator;
import com.fitbur.bouncycastle.util.io.TeeInputStream;
public class RecipientOperator
{
private final AlgorithmIdentifier algorithmIdentifier;
private final Object operator;
public RecipientOperator(InputDecryptor com.fitburcryptor)
{
this.algorithmIdentifier = com.fitburcryptor.getAlgorithmIdentifier();
this.operator = com.fitburcryptor;
}
public RecipientOperator(MacCalculator macCalculator)
{
this.algorithmIdentifier = macCalculator.getAlgorithmIdentifier();
this.operator = macCalculator;
}
public InputStream getInputStream(InputStream dataIn)
{
if (operator instanceof InputDecryptor)
{
return ((InputDecryptor)operator).getInputStream(dataIn);
}
else
{
return new TeeInputStream(dataIn, ((MacCalculator)operator).getOutputStream());
}
}
public boolean isMacBased()
{
return operator instanceof MacCalculator;
}
public byte[] getMac()
{
return ((MacCalculator)operator).getMac();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy