score:0
Here is what I modified:
def verify(data: File): Boolean = {
val signedData = new CMSSignedData(new CMSProcessableFile(data), Base64.decode(this.value))
val certStore = signedData.getCertificates.asInstanceOf[Store[X509CertificateHolder]]
val signers = signedData.getSignerInfos.getSigners
val signer = signers.iterator.next
val certs = certStore.getMatches(signer.getSID.asInstanceOf[Selector[X509CertificateHolder]])
val cert = certs.iterator.next
signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert))
}
Now, the code compile without problem!
Thanks a lot.
Kind Regards,
score:1
If you look at https://www.bouncycastle.org/docs/pkixdocs1.5on/org/bouncycastle/cms/CMSSignedData.html, getCertificates
returns a raw Store
object instead of Store<Something>
. Scala doesn't support working with raw types, generally speaking (they only exist in Java to interoperate with pre-Java-5 code). It's documented as
Return any X.509 certificate objects in this SignedData structure as a Store of X509CertificateHolder objects.
So you can try
val certStore = signedData.getCertificates.asInstanceOf[Store[X509CertificateHolder]]
and you'll also need casts in any other places where raw Store
or Selector
are returned.
Source: stackoverflow.com
Related Query
- Scala compilation issue when using Java library with interface using generic type
- implementing java interface with scala class - type issue
- Compilation issue with enum in Scala using type with value
- Using a Java library with Scala reserved words
- Scala - Injecting Generic type using guice when dependency class is also using same generic type
- Implement Java Interface with Raw type from Scala
- Scala compilation error with Java parametrized constructor and parametrized interface
- Using Java annotations with Java interface implementations in Scala
- Scala - how come using a super-type with two generic parameters cause the scala type checker to treat the child-type differently?
- Scala Type Mismatch issue when using import from different scope
- Using lambda with generic type in Scala
- How to ensure type safety with Scala's Refined library when using the same predicate for refinement
- How to call a function on an object with a generic type parameter using scala macros?
- Using Java generic class with raw types in Scala
- Need to specify type explicitly when using match type with enum - Scala 3
- Type parameter issue in Scala with generic function
- Type issue with Scala when dealing with timestamps
- Compilation error with bounded wildcards using Java classes in Scala
- how match mixed type of scala higher-kinder types feature with java generic type?
- Using Java generic class in Scala throws wrong number of type arguments error
- Unable to override java generic function with scala parameterized type
- How to make covariant in scala a java generic method with a parameterized return type
- Defining a Generic Method in a Trait When Using Algebraic Data Type in Scala
- Type mismatch, found Unit, required Int. Using pattern matching, Scala with Java libraries
- Issue with HashMap ordering on generic type in Scala
- Using generic type with PureConfig in Scala
- Type mismatch when call java generic Java method from Scala code
- scala implicit conversion error on java generic type while using thirdparty java package
- How to update a mongo record using Rogue with MongoCaseClassField when case class contains a scala Enumeration
- Using Scala traits with implemented methods in Java
More Query from same tag
- Lift: Sending notifications to the client from within a Future
- Can sealed trait contain Tuples?
- How to list all files from resources folder with scala
- future built from by-name parameter not executed in parallel
- How is off heap memory read/written in Java?
- Parse JSON in Scala using JSON4S
- Gap in the concept of implicit Ordering of a type used to create a Collection
- scala convert String to generic type
- Scala service on windows
- Kafka consumer in Scala
- Scala: SPARK UDAF for polynomial curve fitting in Scala, got " type (char[]) cannot be converted to the string type" error
- Specify a nested object in scala's play json
- How to set Hadoop fs.s3a.acl.default on AWS EMR?
- Play 2.0 Comet using a persistant connection
- Scala generic cast from String function
- reactivemongo : How to println a TraversableBSONDocument content?
- Scala How to avoid reading the file twice
- What's the purpose of these Java files in scala.runtime?
- Boot timeout when deploying an sbt project to heroku
- Usage of _ in Scala lambdas
- How to extend object properties with other in Scala?
- Spark Streaming With JDBC Source and Redis Stream
- Type Mismatch on Scala For Comprehension: scala.concurrent.Future
- "java.lang.IllegalAccessError" while reading multiline json file in Spark2.0
- scala implicit ordering on generic Option[Any] types
- How can I use map and receive an index as well in Scala?
- Scala Data Modeling and Generics
- Scala: Read an excel file and create output according to different templates methodology/pattern
- How to run method in object - beginner
- Shapeless - Generic Repr Type manipulation