This error occurs with release 0.1.11 of the kit.
(Maybe this has already been fixed by another similar
bug since ?).
I construct a simple sequence containing an attribute
type (an OID) and a value (a Set of Any).
The set of any actually only contains one value, which
is an octet string.
When I try to read my sequence's value, I do :
((OctetString)attr.getAttrValues().iterator().next()).
See test case, this throws a ClassCastException.
Something's wrong at re-population of OctetString.
There's the log's output :
[main] INFO AnyIterator.Test - Trace controller starts.
[main] WARN cryptix.asn1.lang.SetOf - Assume a
SEQUENCE OF one component...
[main] INFO AnyIterator.Test - Attribute =
-- Begin AnyIterator.Attribute (SEQUENCE)
-- field #1 (AnyIterator.AttributeType): --
1.2.840.113549.1.9.4
-- field #2 (AnyIterator.SetOfAttrValue):
-- Begin AnyIterator.SetOfAttrValue (SET OF)
-- frame #1 (AnyIterator.AttributeValue): -- -- 0x10205
-- End AnyIterator.SetOfAttrValue (SET OF)
-- End AnyIterator.Attribute (SEQUENCE)
[main] ERROR AnyIterator.Test - Exception caught in
doTest: java.lang.ClassCastE
xception: AnyIterator.AttributeValue
java.lang.ClassCastException:
AnyIterator.AttributeValue
at cryptix.asn1.lang.OctetString.byteArrayValue
(OctetString.java:159)
at cryptix.asn1.lang.OctetString.toString
(OctetString.java:206)
at java.lang.String.valueOf(String.java:1947)
at java.lang.StringBuffer.append
(StringBuffer.java:370)
at AnyIterator.Test.doTest(Test.java:46)
at AnyIterator.Test.main(Test.java:66)
[main] INFO AnyIterator.Test - END
Test case
Logged In: YES
user_id=204539
One precision :
actually, I do not directly cast attr.getAttrValues
().iterator().next() to an OctetString, but
I do construct an OctetString and call the value() method
to fill it up.
Or I could do new OctetString("blabla", the object).
Both methods throw an exception.
am I using it wrong ?
Cheers,
Axelle.
Logged In: YES
user_id=467081
Have you tried doing
System.err.println(x.getClass().getName());
Just before the cast of x goes boom?
Use reflection to your advantage.
Logged In: YES
user_id=204539
Hi,
I really don't see how that could solve the problem.
"System.err.println(x.getClass().getName());"
Can you explain why you want to check that ?
Axelle.