no.ks.fiks.io.asice.crypto.DecryptionStreamServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fiks-io-asice-handler Show documentation
Show all versions of fiks-io-asice-handler Show documentation
Bibliotek som inneholder funksjonalitet for streaming av ASIC-E pakker
The newest version!
package no.ks.fiks.io.asice.crypto;
import com.google.common.base.Preconditions;
import lombok.NonNull;
import no.ks.fiks.io.asice.util.CMSKrypteringHandler;
import java.io.InputStream;
import java.security.PrivateKey;
import java.util.List;
public class DecryptionStreamServiceImpl implements DecryptionStreamService {
private final CMSKrypteringHandler cmsKrypteringHandler = new CMSKrypteringHandler();
static final String ERROR_MISSING_PRIVATE_KEY = "Privatnøkkel er ikke definert. Kan ikke dekryptere";
@Override
public InputStream decrypterStream(@NonNull InputStream encryptedStream, @NonNull List privateKeys) {
if(privateKeys.isEmpty()){
throw new IllegalStateException(ERROR_MISSING_PRIVATE_KEY);
}
privateKeys.forEach(Preconditions::checkNotNull);
return cmsKrypteringHandler.handleEncryptedStream(encryptedStream,privateKeys);
}
}