On 4/20/12 4:41 PM, Trejkaz wrote:
On Sat, Apr 21, 2012 at 1:50 AM, Rick Hillegas<rick.hille...@oracle.com>  wrote:
3) ...or something else?
Possibly something else.

Specifically, the only thing that doesn't really "work" with the way
we're doing it now is that if you provide valid credentials but can't
access the database, the error Derby passes back to the user is along
the lines of "invalid user ID or password. UserAuthenticator only has
a boolean return value so it isn't possible to pass the reason for
being rejected using solely a UserAuthenticator.
Hi Trejkaz,

UserAuthenticator.authenticateUser() can throw a SQLException which explains that the user doesn't have access to the given database. I find that SQLExceptions raised by the following code reach the application:

import java.sql.SQLException;
import java.util.Properties;

import org.apache.derby.authentication.UserAuthenticator;

public class Z implements UserAuthenticator
{
    public Z() {}

    public boolean authenticateUser
        (
         String userName,
         String userPassword,
         String databaseName,
         Properties info
         )
       throws SQLException
    {
        throw new SQLException( "I can't do that, Dave.", "ZZZZZ" );
    }
}

Hope this helps,
-Rick

Reply via email to