Error with 1.4.5 - Null

View: New views
8 Messages — Rating Filter:   Alert me  

Error with 1.4.5 - Null

by Doychi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I'm currently trying to run a piece of software I developed last year, but I'm getting a null pointer exception (show at the end of this post).  Last year I was running with Java 1.4, but this year I need to run under Java 5.  Does any one have any suggestions on what might be wrong?

java.lang.NullPointerException
        at java.util.HashSet.<init>(Unknown Source)
        at org.skife.jdbi.Args.setArgument(Args.java:76)
        at org.skife.jdbi.StaticStatementEnvelope.prepare(StaticStatementEnvelope.java:52)
        at org.skife.jdbi.StatementCache.findInternal(StatementCache.java:194)
        at org.skife.jdbi.StatementCache.find(StatementCache.java:145)
        at org.skife.jdbi.ConnectionHandle.query(ConnectionHandle.java:287)
        at net.ozgamer.pheno.security.db.DbSecurity.authenticate(DbSecurity.java:127)
        at net.ozgamer.pheno.fds.pages.Index.onOkClick(Index.java:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at net.sf.click.util.ClickUtils.invokeListener(ClickUtils.java:539)
        at net.sf.click.control.Field.invokeListener(Field.java:794)
        at net.sf.click.control.Submit.onProcess(Submit.java:172)
        at net.sf.click.control.Form.onProcess(Form.java:1445)
        at net.sf.click.ClickServlet.processPage(ClickServlet.java:457)
        at net.sf.click.ClickServlet.handleRequest(ClickServlet.java:332)
        at net.sf.click.ClickServlet.doPost(ClickServlet.java:275)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at net.ozgamer.pheno.fds.DBIFilter.doFilter(DBIFilter.java:30)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Unknown Source)

Thanks,

Re: Error with 1.4.5 - Null

by brianm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Do you have the code that lead to the error?


net.ozgamer.pheno.security.db.DbSecurity.authenticate(DbSecurity.java:127)
at net.ozgamer.pheno.fds.pages.Index.onOkClick(Index.java:73)


-Brian

On Apr 18, 2007, at 5:41 AM, Doychi wrote:


Hi All,

I'm currently trying to run a piece of software I developed last year, but
I'm getting a null pointer exception (show at the end of this post).  Last
year I was running with Java 1.4, but this year I need to run under Java 5. 
Does any one have any suggestions on what might be wrong?

java.lang.NullPointerException
at java.util.HashSet.<init>(Unknown Source)
at org.skife.jdbi.Args.setArgument(Args.java:76)
at
org.skife.jdbi.StaticStatementEnvelope.prepare(StaticStatementEnvelope.java:52)
at org.skife.jdbi.StatementCache.findInternal(StatementCache.java:194)
at org.skife.jdbi.StatementCache.find(StatementCache.java:145)
at org.skife.jdbi.ConnectionHandle.query(ConnectionHandle.java:287)
at
net.ozgamer.pheno.security.db.DbSecurity.authenticate(DbSecurity.java:127)
at net.ozgamer.pheno.fds.pages.Index.onOkClick(Index.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sf.click.util.ClickUtils.invokeListener(ClickUtils.java:539)
at net.sf.click.control.Field.invokeListener(Field.java:794)
at net.sf.click.control.Submit.onProcess(Submit.java:172)
at net.sf.click.control.Form.onProcess(Form.java:1445)
at net.sf.click.ClickServlet.processPage(ClickServlet.java:457)
at net.sf.click.ClickServlet.handleRequest(ClickServlet.java:332)
at net.sf.click.ClickServlet.doPost(ClickServlet.java:275)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at net.ozgamer.pheno.fds.DBIFilter.doFilter(DBIFilter.java:30)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Unknown Source)

Thanks,
-- 
Sent from the jdbi - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:




Re: Error with 1.4.5 - Null

by Doychi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Brian McCallister said the following on 19/04/2007 7:24 AM:
Do you have the code that lead to the error?


net.ozgamer.pheno.security.db.DbSecurity.authenticate(DbSecurity.java:127)
at net.ozgamer.pheno.fds.pages.Index.onOkClick(Index.java:73)


-Brian
Yep, the code is below.  I should also mention out I am using MySQL 5.0 and the MySQL JDBC 5.0.5 driver.  The same problem occurs whether I use either com.mysql.jdbc.Driver or org.gjt.mm.mysql.Driver.


-------------- net.ozgamer.pheno.security.db.DbSecurity -----------------------------
/**
 * This implementation of {@link Security} authenticates clients from a database
 * (Pheno 06).
 *
 * @author doychi
 *
 */
public class DbSecurity implements Security {
...
    /**
     * {@inheritDoc}
     */
    public AuthenticatedClient authenticate(UnauthenticatedClient client) { // Line 106
        AuthenticatedClientImpl authClient = null;
        Handle handle = null;
        List userList = null;
        Map user = null;                                            // Line 110
        Map unAuth = null;
        long nextTicketId = -1;
        long thisTicketId = -1;
        String ticket = null;
        StringBuffer ticketBuffer = null;
        IMessageDigest md = null;
        byte[] ticketStringBytes = null;
        byte[] ticketBytes = null;
        //ClickLogger log = ClickLogger.getInstance();
                                                                    // Line 120
        unAuth = new HashedMap();
        unAuth.put(USERNAME, client.getIdentifier());
        unAuth.put(PASSWORD, client.getAuthToken().getToken());

        handle = SessionHandle.getHandle();

        userList = handle.query("security/userCheck", unAuth);      // Line 127

        if ((userList != null) && (userList.size() > 0)) {
            user = (Map) userList.get(0);
            authClient = new AuthenticatedClientImpl();
            authClient.setIdentifier((String) user.get(USERNAME));

            if (user.containsKey(ORGANISER_ID)
                    && dbBoolean(user.get(ORGANISER_ID))) {
                authClient.addGroup(ORGANISER_ID);
                // System.out.println("set organiser on client");
            }
            if (user.containsKey(STAFF_ID) && dbBoolean(user.get(STAFF_ID))) {
                // System.out.println("set staff on client");
                authClient.addGroup(STAFF_ID);
            }
            authClient.addGroup(OTHER_ID);
            /*
             * Generate the ticket for the client.
             */
            synchronized (tokenId) {
                /*
                 * Get this ticket's ID and the set the next ticket's ID.
                 */
                thisTicketId = tokenId.longValue();
                nextTicketId = thisTicketId;
                nextTicketId++;
                tokenId = new Long(nextTicketId);
            }

            /*
             * The ticket string consists of the ticket ID, User ID and a random
             * number.
             */
            ticketBuffer = new StringBuffer(1024);
            ticketBuffer.append(thisTicketId);
            ticketBuffer.append(authClient.getIdentifier());
            ticketBuffer.append(RandomUtils.nextInt());

            md = HashFactory.getInstance("SHA-256");
            ticketStringBytes = Util
                    .toBytesFromUnicode(ticketBuffer.toString());
            md.update(ticketStringBytes, 0, ticketStringBytes.length);
            ticketBytes = md.digest();
            ticket = Util.toString(ticketBytes);
            authClient.setTicket(ticket);
        }
        return authClient;
    }
...
}

-------------- net.ozgamer.pheno.fds.pages.Index -----------------------------

/**
 * Allow the user to login.
 *
 * @author doychi
 *
 */
public class Index extends Template {

    private static final String PASSWORD = "password";

    private static final String USERNAME = "username";

    private Form form = new Form("form");

    public Index() {
        setTitle("Login");
        setDescription("Login to the FDS.");
        form.add(new TextField(USERNAME, true));
        form.add(new PasswordField(PASSWORD, true));
        form.add(new Submit("ok", "   OK   ", this, "onOkClick"));
        addControl(form);
    }
                                                                     // Line 40
    public boolean onOkClick() {
        boolean success = false;
        String username = null;
        String password = null;
        Security security = null;
        UnauthenticatedClient unAuthClient = null;
        AuthenticatedClient client = null;
        ResourceManager manager = null;
        boolean authorised = false;
        TokenImpl token = null;                                      // Line 50
        Page forwardPage = null;
        StringBuffer logMsg = null;

        if (form.isValid()) {
            username = form.getFieldValue(USERNAME);
            password = form.getFieldValue(PASSWORD);
            if (log.isDebugEnabled()) {
                logMsg = new StringBuffer(1024);
                logMsg.append("logging in username: ");
                logMsg.append(username);                             // Line 60
                logMsg.append("  password: ");
                logMsg.append(password.length());
                log.debug(logMsg.toString());
            }

            unAuthClient = new UnauthenticatedClientImpl();
            unAuthClient.setIdentifier(username);
            token = new TokenImpl();
            token.setToken(password);
            unAuthClient.setAuthToken(token);                        // Line 70

            security = SimpleSecurityFactory.getSecurity();
            client = security.authenticate(unAuthClient);            // Line 73
            if (client != null) {
                if (log.isDebugEnabled()) {
                    logMsg = new StringBuffer(1024);
                    logMsg.append("authenticated ");
                    logMsg.append(client.getIdentifier());
                    log.debug(logMsg.toString());
                }
                manager = new DbResourceManager();
                authorised = manager.isAccessable(client, "pheno.fds", "read");
                if (authorised) {
                    forwardPage = getContext().createPage(Welcome.class);
                    getContext().setSessionAttribute("client", client);
                    setForward(forwardPage);
                } else {
                    addModel("message", "<p style=\"color: red;\">"
                            + "You are not authorised to access this site."
                            + "</p>");
                    getContext().getSession().invalidate();
                    if (log.isDebugEnabled()) {
                        logMsg = new StringBuffer(1024);
                        logMsg.append("removed authentication ");
                        logMsg.append(client.getIdentifier());
                        log.debug(logMsg.toString());
                    }
                }
            } else {
                form.add(new Label("failedLogin",
                        "<span style=\"color: red;\">"
                                + "Your password or username was incorrect."
                                + "</span>"));
            }
        }

        return success;
    }
}


-- 
Doychi
spdoychiam@...


-- 
Doychi
spdoychiam@...



avast! Antivirus: Outbound message clean.

Virus Database (VPS): 000734-2, 04/18/2007
Tested on: 4/19/2007 7:50:53 AM
avast! - copyright (c) 1988-2007 ALWIL Software.



Re: Error with 1.4.5 - Null

by brianm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Looks like it is a problem with some metadata detection magic. I have a fix which I am testing now.

Once you switch to 1.5, I strongly recommend switching to the 2.0 line (which  looks like it is stable enough now to get a 2.0 final release when I get a chance), though it is not straightforward as it could be as 2.0 is not API compatible with 1.4 (hence the version number bump).

1.4.6 should appear shortly...

-Brian


On Apr 18, 2007, at 2:50 PM, Doychi wrote:

Brian McCallister said the following on 19/04/2007 7:24 AM:
Do you have the code that lead to the error?


net.ozgamer.pheno.security.db.DbSecurity.authenticate(DbSecurity.java:127)
at net.ozgamer.pheno.fds.pages.Index.onOkClick(Index.java:73)


-Brian
Yep, the code is below.  I should also mention out I am using MySQL 5.0 and the MySQL JDBC 5.0.5 driver.  The same problem occurs whether I use either com.mysql.jdbc.Driver or org.gjt.mm.mysql.Driver.


-------------- net.ozgamer.pheno.security.db.DbSecurity -----------------------------
/**
 * This implementation of {@link Security} authenticates clients from a database
 * (Pheno 06).
 *
 * @author doychi
 *
 */
public class DbSecurity implements Security {
...
    /**
     * {@inheritDoc}
     */
    public AuthenticatedClient authenticate(UnauthenticatedClient client) { // Line 106
        AuthenticatedClientImpl authClient = null;
        Handle handle = null;
        List userList = null;
        Map user = null;                                            // Line 110
        Map unAuth = null;
        long nextTicketId = -1;
        long thisTicketId = -1;
        String ticket = null;
        StringBuffer ticketBuffer = null;
        IMessageDigest md = null;
        byte[] ticketStringBytes = null;
        byte[] ticketBytes = null;
        //ClickLogger log = ClickLogger.getInstance();
                                                                    // Line 120
        unAuth = new HashedMap();
        unAuth.put(USERNAME, client.getIdentifier());
        unAuth.put(PASSWORD, client.getAuthToken().getToken());

        handle = SessionHandle.getHandle();

        userList = handle.query("security/userCheck", unAuth);      // Line 127

        if ((userList != null) && (userList.size() > 0)) {
            user = (Map) userList.get(0);
            authClient = new AuthenticatedClientImpl();
            authClient.setIdentifier((String) user.get(USERNAME));

            if (user.containsKey(ORGANISER_ID)
                    && dbBoolean(user.get(ORGANISER_ID))) {
                authClient.addGroup(ORGANISER_ID);
                // System.out.println("set organiser on client");
            }
            if (user.containsKey(STAFF_ID) && dbBoolean(user.get(STAFF_ID))) {
                // System.out.println("set staff on client");
                authClient.addGroup(STAFF_ID);
            }
            authClient.addGroup(OTHER_ID);
            /*
             * Generate the ticket for the client.
             */
            synchronized (tokenId) {
                /*
                 * Get this ticket's ID and the set the next ticket's ID.
                 */
                thisTicketId = tokenId.longValue();
                nextTicketId = thisTicketId;
                nextTicketId++;
                tokenId = new Long(nextTicketId);
            }

            /*
             * The ticket string consists of the ticket ID, User ID and a random
             * number.
             */
            ticketBuffer = new StringBuffer(1024);
            ticketBuffer.append(thisTicketId);
            ticketBuffer.append(authClient.getIdentifier());
            ticketBuffer.append(RandomUtils.nextInt());

            md = HashFactory.getInstance("SHA-256");
            ticketStringBytes = Util
                    .toBytesFromUnicode(ticketBuffer.toString());
            md.update(ticketStringBytes, 0, ticketStringBytes.length);
            ticketBytes = md.digest();
            ticket = Util.toString(ticketBytes);
            authClient.setTicket(ticket);
        }
        return authClient;
    }
...
}

-------------- net.ozgamer.pheno.fds.pages.Index -----------------------------

/**
 * Allow the user to login.
 *
 * @author doychi
 *
 */
public class Index extends Template {

    private static final String PASSWORD = "password";

    private static final String USERNAME = "username";

    private Form form = new Form("form");

    public Index() {
        setTitle("Login");
        setDescription("Login to the FDS.");
        form.add(new TextField(USERNAME, true));
        form.add(new PasswordField(PASSWORD, true));
        form.add(new Submit("ok", "   OK   ", this, "onOkClick"));
        addControl(form);
    }
                                                                     // Line 40
    public boolean onOkClick() {
        boolean success = false;
        String username = null;
        String password = null;
        Security security = null;
        UnauthenticatedClient unAuthClient = null;
        AuthenticatedClient client = null;
        ResourceManager manager = null;
        boolean authorised = false;
        TokenImpl token = null;                                      // Line 50
        Page forwardPage = null;
        StringBuffer logMsg = null;

        if (form.isValid()) {
            username = form.getFieldValue(USERNAME);
            password = form.getFieldValue(PASSWORD);
            if (log.isDebugEnabled()) {
                logMsg = new StringBuffer(1024);
                logMsg.append("logging in username: ");
                logMsg.append(username);                             // Line 60
                logMsg.append("  password: ");
                logMsg.append(password.length());
                log.debug(logMsg.toString());
            }

            unAuthClient = new UnauthenticatedClientImpl();
            unAuthClient.setIdentifier(username);
            token = new TokenImpl();
            token.setToken(password);
            unAuthClient.setAuthToken(token);                        // Line 70

            security = SimpleSecurityFactory.getSecurity();
            client = security.authenticate(unAuthClient);            // Line 73
            if (client != null) {
                if (log.isDebugEnabled()) {
                    logMsg = new StringBuffer(1024);
                    logMsg.append("authenticated ");
                    logMsg.append(client.getIdentifier());
                    log.debug(logMsg.toString());
                }
                manager = new DbResourceManager();
                authorised = manager.isAccessable(client, "pheno.fds", "read");
                if (authorised) {
                    forwardPage = getContext().createPage(Welcome.class);
                    getContext().setSessionAttribute("client", client);
                    setForward(forwardPage);
                } else {
                    addModel("message", "<p style=\"color: red;\">"
                            + "You are not authorised to access this site."
                            + "</p>");
                    getContext().getSession().invalidate();
                    if (log.isDebugEnabled()) {
                        logMsg = new StringBuffer(1024);
                        logMsg.append("removed authentication ");
                        logMsg.append(client.getIdentifier());
                        log.debug(logMsg.toString());
                    }
                }
            } else {
                form.add(new Label("failedLogin",
                        "<span style=\"color: red;\">"
                                + "Your password or username was incorrect."
                                + "</span>"));
            }
        }

        return success;
    }
}


-- 
Doychi
spdoychiam@...


-- 
Doychi
spdoychiam@...



avast! Antivirus: Outbound message clean.

Virus Database (VPS): 000734-2, 04/18/2007
Tested on: 4/19/2007 7:50:53 AM
avast! - copyright (c) 1988-2007 ALWIL Software.




Re: Error with 1.4.5 - Null

by brianm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just pushed 1.4.6

Could you see if it fixes your problem?


On Apr 18, 2007, at 3:49 PM, Brian McCallister wrote:

Looks like it is a problem with some metadata detection magic. I have a fix which I am testing now.

Once you switch to 1.5, I strongly recommend switching to the 2.0 line (which  looks like it is stable enough now to get a 2.0 final release when I get a chance), though it is not straightforward as it could be as 2.0 is not API compatible with 1.4 (hence the version number bump).

1.4.6 should appear shortly...

-Brian


On Apr 18, 2007, at 2:50 PM, Doychi wrote:

Brian McCallister said the following on 19/04/2007 7:24 AM:
Do you have the code that lead to the error?


net.ozgamer.pheno.security.db.DbSecurity.authenticate(DbSecurity.java:127)
at net.ozgamer.pheno.fds.pages.Index.onOkClick(Index.java:73)


-Brian
Yep, the code is below.  I should also mention out I am using MySQL 5.0 and the MySQL JDBC 5.0.5 driver.  The same problem occurs whether I use either com.mysql.jdbc.Driver or org.gjt.mm.mysql.Driver.


-------------- net.ozgamer.pheno.security.db.DbSecurity -----------------------------
/**
 * This implementation of {@link Security} authenticates clients from a database
 * (Pheno 06).
 *
 * @author doychi
 *
 */
public class DbSecurity implements Security {
...
    /**
     * {@inheritDoc}
     */
    public AuthenticatedClient authenticate(UnauthenticatedClient client) { // Line 106
        AuthenticatedClientImpl authClient = null;
        Handle handle = null;
        List userList = null;
        Map user = null;                                            // Line 110
        Map unAuth = null;
        long nextTicketId = -1;
        long thisTicketId = -1;
        String ticket = null;
        StringBuffer ticketBuffer = null;
        IMessageDigest md = null;
        byte[] ticketStringBytes = null;
        byte[] ticketBytes = null;
        //ClickLogger log = ClickLogger.getInstance();
                                                                    // Line 120
        unAuth = new HashedMap();
        unAuth.put(USERNAME, client.getIdentifier());
        unAuth.put(PASSWORD, client.getAuthToken().getToken());

        handle = SessionHandle.getHandle();

        userList = handle.query("security/userCheck", unAuth);      // Line 127

        if ((userList != null) && (userList.size() > 0)) {
            user = (Map) userList.get(0);
            authClient = new AuthenticatedClientImpl();
            authClient.setIdentifier((String) user.get(USERNAME));

            if (user.containsKey(ORGANISER_ID)
                    && dbBoolean(user.get(ORGANISER_ID))) {
                authClient.addGroup(ORGANISER_ID);
                // System.out.println("set organiser on client");
            }
            if (user.containsKey(STAFF_ID) && dbBoolean(user.get(STAFF_ID))) {
                // System.out.println("set staff on client");
                authClient.addGroup(STAFF_ID);
            }
            authClient.addGroup(OTHER_ID);
            /*
             * Generate the ticket for the client.
             */
            synchronized (tokenId) {
                /*
                 * Get this ticket's ID and the set the next ticket's ID.
                 */
                thisTicketId = tokenId.longValue();
                nextTicketId = thisTicketId;
                nextTicketId++;
                tokenId = new Long(nextTicketId);
            }

            /*
             * The ticket string consists of the ticket ID, User ID and a random
             * number.
             */
            ticketBuffer = new StringBuffer(1024);
            ticketBuffer.append(thisTicketId);
            ticketBuffer.append(authClient.getIdentifier());
            ticketBuffer.append(RandomUtils.nextInt());

            md = HashFactory.getInstance("SHA-256");
            ticketStringBytes = Util
                    .toBytesFromUnicode(ticketBuffer.toString());
            md.update(ticketStringBytes, 0, ticketStringBytes.length);
            ticketBytes = md.digest();
            ticket = Util.toString(ticketBytes);
            authClient.setTicket(ticket);
        }
        return authClient;
    }
...
}

-------------- net.ozgamer.pheno.fds.pages.Index -----------------------------

/**
 * Allow the user to login.
 *
 * @author doychi
 *
 */
public class Index extends Template {

    private static final String PASSWORD = "password";

    private static final String USERNAME = "username";

    private Form form = new Form("form");

    public Index() {
        setTitle("Login");
        setDescription("Login to the FDS.");
        form.add(new TextField(USERNAME, true));
        form.add(new PasswordField(PASSWORD, true));
        form.add(new Submit("ok", "   OK   ", this, "onOkClick"));
        addControl(form);
    }
                                                                     // Line 40
    public boolean onOkClick() {
        boolean success = false;
        String username = null;
        String password = null;
        Security security = null;
        UnauthenticatedClient unAuthClient = null;
        AuthenticatedClient client = null;
        ResourceManager manager = null;
        boolean authorised = false;
        TokenImpl token = null;                                      // Line 50
        Page forwardPage = null;
        StringBuffer logMsg = null;

        if (form.isValid()) {
            username = form.getFieldValue(USERNAME);
            password = form.getFieldValue(PASSWORD);
            if (log.isDebugEnabled()) {
                logMsg = new StringBuffer(1024);
                logMsg.append("logging in username: ");
                logMsg.append(username);                             // Line 60
                logMsg.append("  password: ");
                logMsg.append(password.length());
                log.debug(logMsg.toString());
            }

            unAuthClient = new UnauthenticatedClientImpl();
            unAuthClient.setIdentifier(username);
            token = new TokenImpl();
            token.setToken(password);
            unAuthClient.setAuthToken(token);                        // Line 70

            security = SimpleSecurityFactory.getSecurity();
            client = security.authenticate(unAuthClient);            // Line 73
            if (client != null) {
                if (log.isDebugEnabled()) {
                    logMsg = new StringBuffer(1024);
                    logMsg.append("authenticated ");
                    logMsg.append(client.getIdentifier());
                    log.debug(logMsg.toString());
                }
                manager = new DbResourceManager();
                authorised = manager.isAccessable(client, "pheno.fds", "read");
                if (authorised) {
                    forwardPage = getContext().createPage(Welcome.class);
                    getContext().setSessionAttribute("client", client);
                    setForward(forwardPage);
                } else {
                    addModel("message", "<p style=\"color: red;\">"
                            + "You are not authorised to access this site."
                            + "</p>");
                    getContext().getSession().invalidate();
                    if (log.isDebugEnabled()) {
                        logMsg = new StringBuffer(1024);
                        logMsg.append("removed authentication ");
                        logMsg.append(client.getIdentifier());
                        log.debug(logMsg.toString());
                    }
                }
            } else {
                form.add(new Label("failedLogin",
                        "<span style=\"color: red;\">"
                                + "Your password or username was incorrect."
                                + "</span>"));
            }
        }

        return success;
    }
}


-- 
Doychi
spdoychiam@...


-- 
Doychi
spdoychiam@...



avast! Antivirus: Outbound message clean.

Virus Database (VPS): 000734-2, 04/18/2007
Tested on: 4/19/2007 7:50:53 AM
avast! - copyright (c) 1988-2007 ALWIL Software.





Re: Error with 1.4.5 - Null

by Doychi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


brianm wrote:
Just pushed 1.4.6

Could you see if it fixes your problem?
I'll do that tonight after work.

brianm wrote:
On Apr 18, 2007, at 3:49 PM, Brian McCallister wrote:

> Looks like it is a problem with some metadata detection magic. I  
> have a fix which I am testing now.
>
> Once you switch to 1.5, I strongly recommend switching to the 2.0  
> line (which  looks like it is stable enough now to get a 2.0 final  
> release when I get a chance), though it is not straightforward as  
> it could be as 2.0 is not API compatible with 1.4 (hence the  
> version number bump).\
I would but I'm after path of least resistance as we were trying to re-write the application but failed to do so before the convention.

What sort of effort would you expect to make the transition from 1.4 to 2.0?

Re: Error with 1.4.5 - Null

by Doychi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That fixed it.

Thanks.




brianm wrote:
Just pushed 1.4.6

Could you see if it fixes your problem?


Re: Error with 1.4.5 - Null

by brianm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Apr 19, 2007, at 12:51 AM, Doychi wrote:

>
> That fixed it.
>
> Thanks.

You're welcome, thank you for finding the bug!

-Brian

>
>
>
> Doychi wrote:
>>
>>
>>
>> brianm wrote:
>>>
>>> Just pushed 1.4.6
>>>
>>> Could you see if it fixes your problem?
>>>
>>
>
> --  
> View this message in context: http://www.nabble.com/Error- 
> with-1.4.5---Null-tf3600760.html#a10073476
> Sent from the jdbi - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email