You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by bu...@apache.org on 2010/06/22 00:17:41 UTC

DO NOT REPLY [Bug 49483] New: KeyResolver.registerAtStart() leads to ClassCastException

https://issues.apache.org/bugzilla/show_bug.cgi?id=49483

           Summary: KeyResolver.registerAtStart() leads to
                    ClassCastException
           Product: Security
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Encryption
        AssignedTo: security-dev@xml.apache.org
        ReportedBy: Clement_Pellerin@ibi.com


Created an attachment (id=25627)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25627)
source code patch

KeyResolver.registerAtStart() adds a String to KeyResolver._resolverVector.
In ResolverIterator.next(), we expect the items in _resolverVector to be
KeyResolver instances and this causes a ClassCastException.

To reproduce, run this code:
KeyResolver.registerAtStart("org.apache.xml.security.test.encryption.BobKeyResolver");
KeyResolverSpi resolver = (KeyResolverSpi)KeyResolver.iterator().next();

The solution is to call new KeyResolver(className) just like
KeyResolver.register().
Unfortunately, we cannot add the throws clauses. For backwards compatibility, 
we return an unchecked RuntimeException instead. We chose
IllegalArgumentException.

We also modify ResolverIterator.remove() to throw an
UnsupportedOperationException.

I did not add a junit for this bug because there is no way to remove a
KeyResolver once it is registered. This would affect the subsequent tests.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49483] KeyResolver.registerAtStart() leads to ClassCastException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49483

coheigea <co...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |

--- Comment #2 from coheigea <co...@apache.org> 2010-06-30 10:12:28 EDT ---

Hi Clement,

A problem with this patch is that it is not compatible with JDK 1.4:

    [javac] symbol  : constructor IllegalArgumentException
(java.lang.String,java.lang.Exception)
    [javac] location: class java.lang.IllegalArgumentException
    [javac]            throw new IllegalArgumentException("Invalid KeyResolver
class name", ex);
    [javac]                  ^
    [javac] 1 error

Colm.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49483] KeyResolver.registerAtStart() leads to ClassCastException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49483

--- Comment #3 from sean.mullan@oracle.com 2010-07-02 09:11:44 EDT ---
(In reply to comment #2)
> Hi Clement,
> 
> A problem with this patch is that it is not compatible with JDK 1.4:
> 
>     [javac] symbol  : constructor IllegalArgumentException
> (java.lang.String,java.lang.Exception)
>     [javac] location: class java.lang.IllegalArgumentException
>     [javac]            throw new IllegalArgumentException("Invalid KeyResolver
> class name", ex);
>     [javac]                  ^
>     [javac] 1 error
> 
> Colm.

You can make that compatible with 1.4 as follows:

throw (IllegalArgumentException) new 
       IllegalArgumentException("Invalid KeyResolver class
name").initCause(ex);

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49483] KeyResolver.registerAtStart() leads to ClassCastException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49483

coheigea <co...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from coheigea <co...@apache.org> 2010-07-21 13:27:36 EDT ---

Fix applied thanks Sean!

Colm.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49483] KeyResolver.registerAtStart() leads to ClassCastException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49483

coheigea <co...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #1 from coheigea <co...@apache.org> 2010-06-23 13:41:59 EDT ---

Patch applied, thanks.

Colm.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.