SAML1 CheckRequestVersionHandler ClassCastException ?

Cantor, Scott cantor.2 at osu.edu
Tue Jan 21 21:17:03 EST 2014


On 1/21/14, 9:11 PM, "Tom Zeller" <tzeller at dragonacea.biz> wrote:

>> Not sure how best we'll control that. Is the class cast happening
>>because
>> of an actual cast, or a generic declaration causing the cast? We might
>> have to do an instanceof check, and avoid any implicit casting from the
>> use of generics.
>
>Generics. I started typing instanceof, but the target
>IdPInitatedSSORequest class is in the IdP, not OpenSAML.

One option I think is just to leave it typed generically (extends
AbstractMessageHandler) and then do a check for RequestAbstractType in the
body.

The more elegant thing is just to not run the handler, but then we'd have
to have different handler chains based on the inbound binding. Not sure
which is better.

>I added a log statement, but calling getClass() throws the
>ClassCastException :-/ I'm sure there is an explanation...

It's typed AbstractMessageHandler<RequestAbstractType> so as soon as you
call getMessage(), it will throw the exception.

That's how generics work, it's all very odd. The cast happens at the
instant you execute code that was written to assume the type was in fact
what it was coded to be. Until then the type erasure causes it to just hum
along silently even though it's all wrong internally. It's a time bomb
waiting to go off.

-- Scott




More information about the dev mailing list