You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Stepan Mishura <st...@gmail.com> on 2006/04/10 08:14:03 UTC

Re: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.

Hi Mark,

Basing on the bug description I assume that RI checks provider parameter
first. In all your examples this parameter is invalid. The spec. for method
javax.crypto.Cipher.getInstance(String transformation,
                                String provider)
says:
"Throws:
    NoSuchAlgorithmException - if transformation is null, empty, in an
invalid format, or not available from the specified provider.
    NoSuchProviderException - if the specified provider has not been
configured.
    NoSuchPaddingException - if transformation contains a padding scheme
that is not available.
    IllegalArgumentException - if the provider is null."

So IllegalArgumentException can be thrown only if the provider parameter is
null. But IMHO in case of empty string NoSuchProviderException should be
thrown.

What do you think?

Thanks,
Stepan

>From: Mark Hindess (JIRA)
>Sent: Friday, April 07, 2006 1:31 AM
>To: harmony-commits@incubator.apache.org
>Subject: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance
>doesn't match RI exception behaviour.
>
>javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.
>---------------------------------------------------------------------
>
>         Key: HARMONY-315
>         URL: http://issues.apache.org/jira/browse/HARMONY-315
>     Project: Harmony
>        Type: Bug
>
>  Components: Classlib
>    Reporter: Mark Hindess
>    Priority: Trivial
>
>
>javax.crypto.getInstance methods doesn't match reference behaviour.  It
>throws NoSuchProvideExceptions when it should be throwing
>IllegalArgumentExceptions.  See log below for details.
>
>RI is Sun Microsystems Inc. 1.5.0_06
>Test is harmony classlib
>
>javax.crypto.Cipher.getInstance("",""):
>  RI throws java.lang.IllegalArgumentException: Missing provider
>  Test throws java.security.NoSuchProviderException: Provider  is not
>available
>
>javax.crypto.Cipher.getInstance("",(java.lang.String)null):
>  RI throws java.lang.IllegalArgumentException: Missing provider
>  Test throws java.security.NoSuchProviderException: Provider null is not
>available
>
>javax.crypto.Cipher.getInstance((java.lang.String)null,""):
>  RI throws java.lang.IllegalArgumentException: Missing provider
>  Test throws java.security.NoSuchProviderException: Provider  is not
>available
>
>javax.crypto.Cipher.getInstance((java.lang.String)null,(java.lang.String)nu
>ll):
>  RI throws java.lang.IllegalArgumentException: Missing provider
>  Test throws java.security.NoSuchProviderException: Provider null is not
>available
>
>
>--
>This message is automatically generated by JIRA.
>-
>If you think it was sent incorrectly contact one of the administrators:
>   http://issues.apache.org/jira/secure/Administrators.jspa
>-
>For more information on JIRA, see:
>   http://www.atlassian.com/software/jira


--
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Thanks,
Stepan Mishura
Intel Middleware Products Division

Re: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.

Posted by Stepan Mishura <st...@gmail.com>.
Mark, IMHO in this case we shouldn't follow RI because Harmony
implementation corresponds to the spec. and it is consistent. I'm not OK
with introducing confusing behavior to our users. Why only "" string was
selected as invalid? Why not to check "   " string also (RI rejects such
string with NoSuchProviderException)?

Thanks,
Stepan.

On 4/10/06, Mark Hindess wrote:
>
> Hmm... I agree that the behaviour is inconsistent.  But I think
> matching the RI behaviour is unlikely to inconvenience our users.  So,
> I'd still say we should match the behaviour of Sun's 5.0
> implementation (which means we'll also match IBM's and BEA's).
>
> Regards,
> Mark.
>
> On 4/10/06, Stepan Mishura < stepan.mishura@gmail.com> wrote:
> > On 4/10/06, Mark Hindess wrote:
> > >
> > > On 4/10/06, Stepan Mishura wrote:
> > > > Hi Mark,
> > > >
> > > > Basing on the bug description I assume that RI checks provider
> parameter
> > > > first.
> > >
> > > Yes.
> > >
> > > > In all your examples this parameter is invalid.
> > >
> > > Yes.  (It was one of the test cases generated by my Perl script - that
>
> > > I've nearly finished tidying up for contribution.)
> > >
> > > > The spec. for method javax.crypto.Cipher.getInstance(String
> > > transformation,
> > > > String provider)
> > > > says:
> > > > "Throws:
> > > >     NoSuchAlgorithmException - if transformation is null, empty, in
> an
> > > > invalid format, or not available from the specified provider.
> > > >     NoSuchProviderException - if the specified provider has not been
> > > > configured.
> > > >     NoSuchPaddingException - if transformation contains a padding
> scheme
> > > > that is not available.
> > > >     IllegalArgumentException - if the provider is null."
> > > >
> > > > So IllegalArgumentException can be thrown only if the provider
> parameter
> > > is
> > > > null. But IMHO in case of empty string NoSuchProviderException
> should be
> > > > thrown.
> > > >
> > > > What do you think?
> > >
> > > So we agree about fixing the two cases where provider is (String)null.
> > > We just need to decide what to do about the other two where provider
> > > is (String)"" ?
> >
> >
> > Yes.
> >
> > I think we should match the RI behaviour.  That means that even in the
> > > two cases where provider is the empty string we should still throw an
> > > IllegalArgumentException.
> > >
> > > I think the wording of the spec for the getInstance method that takes
> > > a String provider is just vague because it was copied from the method
> > > that takes a Provider object.  I think the RI behaviour reflects the
> > > intention of the spec even if the spec is unclear.
> >
> >
> > The problem is that java.security.Security allows such provider name,
> for
> > example, the following code works on RI:
> >
> > =============== SmallProvider.java =================
> > import java.security.Provider;
> > public class SmallProvider extends Provider {
> >
> >     public SmallProvider() {
> >         super("", // name
> >              1.0, // version
> >              "SmallProvider" // info
> >         );
> >     }
> > }
> > =============== test.java ===================
> > import java.security.Security;
> > public class test {
> >     public static void main(String[] args){
> >         Security.addProvider(new SmallProvider());
> >         System.out.println(Security.getProvider("").getInfo());
> >     }
> > }
> >
> > If we will follow RI then it will be possible to access Cipher object
> via:
> > Cipher.getInstance(<some transformation>, Security.getProvider(""));
> >
> > But impossible to do the same via: Cipher.getInstance(<some
> transformation>,
> > "");
> >
> > Thanks,
> > Stepan.
> >
> > Regards,
> > > Mark.
> > >
> > > > Thanks,
> > > > Stepan
> > > >
> > > > >From: Mark Hindess (JIRA)
> > > > >Sent: Friday, April 07, 2006 1:31 AM
> > > > >To: harmony-commits@incubator.apache.org
> > > > >Subject: [jira] Created: (HARMONY-315)
> javax.crypto.Cipher.getInstance
> > > > >doesn't match RI exception behaviour.
> > > > >
> > > > >javax.crypto.Cipher.getInstance doesn't match RI exception
> behaviour.
> > > >
> >---------------------------------------------------------------------
> > > > >
> > > > >         Key: HARMONY-315
> > > > >         URL: http://issues.apache.org/jira/browse/HARMONY-315
> > > > >     Project: Harmony
> > > > >        Type: Bug
> > > > >
> > > > >  Components: Classlib
> > > > >    Reporter: Mark Hindess
> > > > >    Priority: Trivial
> > > > >
> > > > >
> > > > >javax.crypto.getInstance methods doesn't match reference
> behaviour.  It
> > > > >throws NoSuchProvideExceptions when it should be throwing
> > > > >IllegalArgumentExceptions.  See log below for details.
> > > > >
> > > > >RI is Sun Microsystems Inc. 1.5.0_06
> > > > >Test is harmony classlib
> > > > >
> > > > >javax.crypto.Cipher.getInstance("",""):
> > > > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > > > >  Test throws java.security.NoSuchProviderException: Provider  is
> not
> > > > >available
> > > > >
> > > > >javax.crypto.Cipher.getInstance("",(java.lang.String)null):
> > > > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > > > >  Test throws java.security.NoSuchProviderException : Provider null
> is
> > > not
> > > > >available
> > > > >
> > > > >javax.crypto.Cipher.getInstance((java.lang.String)null,""):
> > > > >  RI throws java.lang.IllegalArgumentException : Missing provider
> > > > >  Test throws java.security.NoSuchProviderException: Provider  is
> not
> > > > >available
> > > > >
> > > > >javax.crypto.Cipher.getInstance(( java.lang.String)null,(
> > > java.lang.String)nu
> > > > >ll):
> > > > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > > > >  Test throws java.security.NoSuchProviderException : Provider null
> is
> > > not
> > > > >available
> > > > >
> > > > >
> > > > >--
> > > > >This message is automatically generated by JIRA.
> > > > >-
> > > > >If you think it was sent incorrectly contact one of the
> administrators:
> > > > >   http://issues.apache.org/jira/secure/Administrators.jspa
> > > > >-
> > > > >For more information on JIRA, see:
> > > > >   http://www.atlassian.com/software/jira
> > > >
> > > >
> > > > --
> > > >
> ---------------------------------------------------------------------
> > > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > > For additional commands, e-mail:
> harmony-dev-help@incubator.apache.org
> > > >
> > > > Thanks,
> > > > Stepan Mishura
> > > > Intel Middleware Products Division
> > > >
> > > >
> > >
> > >
> > > --
> > > Mark Hindess <ma...@googlemail.com>
> > > IBM Java Technology Centre, UK.
> > >
> > > ---------------------------------------------------------------------
> > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >
> > >
> >
> >
> > --
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> > Thanks,
> > Stepan Mishura
> > Intel Middleware Products Division
> >
> >
>
>
> --
> Mark Hindess < mark.hindess@googlemail.com>
> IBM Java Technology Centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


--
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Thanks,
Stepan Mishura
Intel Middleware Products Division

Re: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.

Posted by Mark Hindess <ma...@googlemail.com>.
Hmm... I agree that the behaviour is inconsistent.  But I think
matching the RI behaviour is unlikely to inconvenience our users.  So,
I'd still say we should match the behaviour of Sun's 5.0
implementation (which means we'll also match IBM's and BEA's).

Regards,
 Mark.

On 4/10/06, Stepan Mishura <st...@gmail.com> wrote:
> On 4/10/06, Mark Hindess wrote:
> >
> > On 4/10/06, Stepan Mishura wrote:
> > > Hi Mark,
> > >
> > > Basing on the bug description I assume that RI checks provider parameter
> > > first.
> >
> > Yes.
> >
> > > In all your examples this parameter is invalid.
> >
> > Yes.  (It was one of the test cases generated by my Perl script - that
> > I've nearly finished tidying up for contribution.)
> >
> > > The spec. for method javax.crypto.Cipher.getInstance(String
> > transformation,
> > > String provider)
> > > says:
> > > "Throws:
> > >     NoSuchAlgorithmException - if transformation is null, empty, in an
> > > invalid format, or not available from the specified provider.
> > >     NoSuchProviderException - if the specified provider has not been
> > > configured.
> > >     NoSuchPaddingException - if transformation contains a padding scheme
> > > that is not available.
> > >     IllegalArgumentException - if the provider is null."
> > >
> > > So IllegalArgumentException can be thrown only if the provider parameter
> > is
> > > null. But IMHO in case of empty string NoSuchProviderException should be
> > > thrown.
> > >
> > > What do you think?
> >
> > So we agree about fixing the two cases where provider is (String)null.
> > We just need to decide what to do about the other two where provider
> > is (String)"" ?
>
>
> Yes.
>
> I think we should match the RI behaviour.  That means that even in the
> > two cases where provider is the empty string we should still throw an
> > IllegalArgumentException.
> >
> > I think the wording of the spec for the getInstance method that takes
> > a String provider is just vague because it was copied from the method
> > that takes a Provider object.  I think the RI behaviour reflects the
> > intention of the spec even if the spec is unclear.
>
>
> The problem is that java.security.Security allows such provider name, for
> example, the following code works on RI:
>
> =============== SmallProvider.java =================
> import java.security.Provider;
> public class SmallProvider extends Provider {
>
>     public SmallProvider() {
>         super("", // name
>              1.0, // version
>              "SmallProvider" // info
>         );
>     }
> }
> =============== test.java ===================
> import java.security.Security;
> public class test {
>     public static void main(String[] args){
>         Security.addProvider(new SmallProvider());
>         System.out.println(Security.getProvider("").getInfo());
>     }
> }
>
> If we will follow RI then it will be possible to access Cipher object via:
> Cipher.getInstance(<some transformation>, Security.getProvider(""));
>
> But impossible to do the same via: Cipher.getInstance(<some transformation>,
> "");
>
> Thanks,
> Stepan.
>
> Regards,
> > Mark.
> >
> > > Thanks,
> > > Stepan
> > >
> > > >From: Mark Hindess (JIRA)
> > > >Sent: Friday, April 07, 2006 1:31 AM
> > > >To: harmony-commits@incubator.apache.org
> > > >Subject: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance
> > > >doesn't match RI exception behaviour.
> > > >
> > > >javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.
> > > >---------------------------------------------------------------------
> > > >
> > > >         Key: HARMONY-315
> > > >         URL: http://issues.apache.org/jira/browse/HARMONY-315
> > > >     Project: Harmony
> > > >        Type: Bug
> > > >
> > > >  Components: Classlib
> > > >    Reporter: Mark Hindess
> > > >    Priority: Trivial
> > > >
> > > >
> > > >javax.crypto.getInstance methods doesn't match reference behaviour.  It
> > > >throws NoSuchProvideExceptions when it should be throwing
> > > >IllegalArgumentExceptions.  See log below for details.
> > > >
> > > >RI is Sun Microsystems Inc. 1.5.0_06
> > > >Test is harmony classlib
> > > >
> > > >javax.crypto.Cipher.getInstance("",""):
> > > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > > >  Test throws java.security.NoSuchProviderException: Provider  is not
> > > >available
> > > >
> > > >javax.crypto.Cipher.getInstance("",(java.lang.String)null):
> > > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > > >  Test throws java.security.NoSuchProviderException: Provider null is
> > not
> > > >available
> > > >
> > > >javax.crypto.Cipher.getInstance((java.lang.String)null,""):
> > > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > > >  Test throws java.security.NoSuchProviderException: Provider  is not
> > > >available
> > > >
> > > >javax.crypto.Cipher.getInstance((java.lang.String)null,(
> > java.lang.String)nu
> > > >ll):
> > > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > > >  Test throws java.security.NoSuchProviderException: Provider null is
> > not
> > > >available
> > > >
> > > >
> > > >--
> > > >This message is automatically generated by JIRA.
> > > >-
> > > >If you think it was sent incorrectly contact one of the administrators:
> > > >   http://issues.apache.org/jira/secure/Administrators.jspa
> > > >-
> > > >For more information on JIRA, see:
> > > >   http://www.atlassian.com/software/jira
> > >
> > >
> > > --
> > > ---------------------------------------------------------------------
> > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >
> > > Thanks,
> > > Stepan Mishura
> > > Intel Middleware Products Division
> > >
> > >
> >
> >
> > --
> > Mark Hindess <ma...@googlemail.com>
> > IBM Java Technology Centre, UK.
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
> Thanks,
> Stepan Mishura
> Intel Middleware Products Division
>
>


--
Mark Hindess <ma...@googlemail.com>
IBM Java Technology Centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.

Posted by Stepan Mishura <st...@gmail.com>.
On 4/10/06, Mark Hindess wrote:
>
> On 4/10/06, Stepan Mishura wrote:
> > Hi Mark,
> >
> > Basing on the bug description I assume that RI checks provider parameter
> > first.
>
> Yes.
>
> > In all your examples this parameter is invalid.
>
> Yes.  (It was one of the test cases generated by my Perl script - that
> I've nearly finished tidying up for contribution.)
>
> > The spec. for method javax.crypto.Cipher.getInstance(String
> transformation,
> > String provider)
> > says:
> > "Throws:
> >     NoSuchAlgorithmException - if transformation is null, empty, in an
> > invalid format, or not available from the specified provider.
> >     NoSuchProviderException - if the specified provider has not been
> > configured.
> >     NoSuchPaddingException - if transformation contains a padding scheme
> > that is not available.
> >     IllegalArgumentException - if the provider is null."
> >
> > So IllegalArgumentException can be thrown only if the provider parameter
> is
> > null. But IMHO in case of empty string NoSuchProviderException should be
> > thrown.
> >
> > What do you think?
>
> So we agree about fixing the two cases where provider is (String)null.
> We just need to decide what to do about the other two where provider
> is (String)"" ?


Yes.

I think we should match the RI behaviour.  That means that even in the
> two cases where provider is the empty string we should still throw an
> IllegalArgumentException.
>
> I think the wording of the spec for the getInstance method that takes
> a String provider is just vague because it was copied from the method
> that takes a Provider object.  I think the RI behaviour reflects the
> intention of the spec even if the spec is unclear.


The problem is that java.security.Security allows such provider name, for
example, the following code works on RI:

=============== SmallProvider.java =================
import java.security.Provider;
public class SmallProvider extends Provider {

    public SmallProvider() {
        super("", // name
             1.0, // version
             "SmallProvider" // info
        );
    }
}
=============== test.java ===================
import java.security.Security;
public class test {
    public static void main(String[] args){
        Security.addProvider(new SmallProvider());
        System.out.println(Security.getProvider("").getInfo());
    }
}

If we will follow RI then it will be possible to access Cipher object via:
Cipher.getInstance(<some transformation>, Security.getProvider(""));

But impossible to do the same via: Cipher.getInstance(<some transformation>,
"");

Thanks,
Stepan.

Regards,
> Mark.
>
> > Thanks,
> > Stepan
> >
> > >From: Mark Hindess (JIRA)
> > >Sent: Friday, April 07, 2006 1:31 AM
> > >To: harmony-commits@incubator.apache.org
> > >Subject: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance
> > >doesn't match RI exception behaviour.
> > >
> > >javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.
> > >---------------------------------------------------------------------
> > >
> > >         Key: HARMONY-315
> > >         URL: http://issues.apache.org/jira/browse/HARMONY-315
> > >     Project: Harmony
> > >        Type: Bug
> > >
> > >  Components: Classlib
> > >    Reporter: Mark Hindess
> > >    Priority: Trivial
> > >
> > >
> > >javax.crypto.getInstance methods doesn't match reference behaviour.  It
> > >throws NoSuchProvideExceptions when it should be throwing
> > >IllegalArgumentExceptions.  See log below for details.
> > >
> > >RI is Sun Microsystems Inc. 1.5.0_06
> > >Test is harmony classlib
> > >
> > >javax.crypto.Cipher.getInstance("",""):
> > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > >  Test throws java.security.NoSuchProviderException: Provider  is not
> > >available
> > >
> > >javax.crypto.Cipher.getInstance("",(java.lang.String)null):
> > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > >  Test throws java.security.NoSuchProviderException: Provider null is
> not
> > >available
> > >
> > >javax.crypto.Cipher.getInstance((java.lang.String)null,""):
> > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > >  Test throws java.security.NoSuchProviderException: Provider  is not
> > >available
> > >
> > >javax.crypto.Cipher.getInstance((java.lang.String)null,(
> java.lang.String)nu
> > >ll):
> > >  RI throws java.lang.IllegalArgumentException: Missing provider
> > >  Test throws java.security.NoSuchProviderException: Provider null is
> not
> > >available
> > >
> > >
> > >--
> > >This message is automatically generated by JIRA.
> > >-
> > >If you think it was sent incorrectly contact one of the administrators:
> > >   http://issues.apache.org/jira/secure/Administrators.jspa
> > >-
> > >For more information on JIRA, see:
> > >   http://www.atlassian.com/software/jira
> >
> >
> > --
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> > Thanks,
> > Stepan Mishura
> > Intel Middleware Products Division
> >
> >
>
>
> --
> Mark Hindess <ma...@googlemail.com>
> IBM Java Technology Centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


--
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Thanks,
Stepan Mishura
Intel Middleware Products Division

Re: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.

Posted by Mark Hindess <ma...@googlemail.com>.
On 4/10/06, Stepan Mishura <st...@gmail.com> wrote:
> Hi Mark,
>
> Basing on the bug description I assume that RI checks provider parameter
> first.

Yes.

> In all your examples this parameter is invalid.

Yes.  (It was one of the test cases generated by my Perl script - that
I've nearly finished tidying up for contribution.)

> The spec. for method javax.crypto.Cipher.getInstance(String transformation,
> String provider)
> says:
> "Throws:
>     NoSuchAlgorithmException - if transformation is null, empty, in an
> invalid format, or not available from the specified provider.
>     NoSuchProviderException - if the specified provider has not been
> configured.
>     NoSuchPaddingException - if transformation contains a padding scheme
> that is not available.
>     IllegalArgumentException - if the provider is null."
>
> So IllegalArgumentException can be thrown only if the provider parameter is
> null. But IMHO in case of empty string NoSuchProviderException should be
> thrown.
>
> What do you think?

So we agree about fixing the two cases where provider is (String)null.
 We just need to decide what to do about the other two where provider
is (String)"" ?

I think we should match the RI behaviour.  That means that even in the
two cases where provider is the empty string we should still throw an
IllegalArgumentException.

I think the wording of the spec for the getInstance method that takes
a String provider is just vague because it was copied from the method
that takes a Provider object.  I think the RI behaviour reflects the
intention of the spec even if the spec is unclear.

Regards,
 Mark.

> Thanks,
> Stepan
>
> >From: Mark Hindess (JIRA)
> >Sent: Friday, April 07, 2006 1:31 AM
> >To: harmony-commits@incubator.apache.org
> >Subject: [jira] Created: (HARMONY-315) javax.crypto.Cipher.getInstance
> >doesn't match RI exception behaviour.
> >
> >javax.crypto.Cipher.getInstance doesn't match RI exception behaviour.
> >---------------------------------------------------------------------
> >
> >         Key: HARMONY-315
> >         URL: http://issues.apache.org/jira/browse/HARMONY-315
> >     Project: Harmony
> >        Type: Bug
> >
> >  Components: Classlib
> >    Reporter: Mark Hindess
> >    Priority: Trivial
> >
> >
> >javax.crypto.getInstance methods doesn't match reference behaviour.  It
> >throws NoSuchProvideExceptions when it should be throwing
> >IllegalArgumentExceptions.  See log below for details.
> >
> >RI is Sun Microsystems Inc. 1.5.0_06
> >Test is harmony classlib
> >
> >javax.crypto.Cipher.getInstance("",""):
> >  RI throws java.lang.IllegalArgumentException: Missing provider
> >  Test throws java.security.NoSuchProviderException: Provider  is not
> >available
> >
> >javax.crypto.Cipher.getInstance("",(java.lang.String)null):
> >  RI throws java.lang.IllegalArgumentException: Missing provider
> >  Test throws java.security.NoSuchProviderException: Provider null is not
> >available
> >
> >javax.crypto.Cipher.getInstance((java.lang.String)null,""):
> >  RI throws java.lang.IllegalArgumentException: Missing provider
> >  Test throws java.security.NoSuchProviderException: Provider  is not
> >available
> >
> >javax.crypto.Cipher.getInstance((java.lang.String)null,(java.lang.String)nu
> >ll):
> >  RI throws java.lang.IllegalArgumentException: Missing provider
> >  Test throws java.security.NoSuchProviderException: Provider null is not
> >available
> >
> >
> >--
> >This message is automatically generated by JIRA.
> >-
> >If you think it was sent incorrectly contact one of the administrators:
> >   http://issues.apache.org/jira/secure/Administrators.jspa
> >-
> >For more information on JIRA, see:
> >   http://www.atlassian.com/software/jira
>
>
> --
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
> Thanks,
> Stepan Mishura
> Intel Middleware Products Division
>
>


--
Mark Hindess <ma...@googlemail.com>
IBM Java Technology Centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org