In a Scala project, I am using Java livrary (bouncycastle).
I have a compilation issue when using a method that required an object implementing a generic type.
Here is the interface in Java:
public interface Selector<T> extends Cloneable
{
boolean match(T obj);
Object clone();
}
Here is the piece of code that does not compile:
def verify(data: File): Boolean = {
val signedData = new CMSSignedData(new CMSProcessableFile(data), Base64.decode(this.value))
val certStore = signedData.getCertificates
val signers = signedData.getSignerInfos.getSigners
val signer = signers.iterator.next
val certs = certStore.getMatches(signer.getSID)
val cert = certs.iterator.next.asInstanceOf[X509CertificateHolder]
signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert))
}
When I compile the code, I get the following error:
[error] found : org.bouncycastle.cms.SignerId
[error] required: org.bouncycastle.util.Selector[?0]
[error] val certs = certStore.getMatches(signer.getSID)
I tried casting but I does not compile.
Coule you please help?
Regards,
getMatches?