Cancel button to interrupt authentication

Raadush raadush at gmail.com
Wed Dec 11 04:00:00 EST 2013


Hi, I have one question. I have custom authentication class which
authenticate users through mobile phone. It sends request to web service
and then waits in while cycle for user to perform some action on his mobile
phone. Problem is, that I want to implement cancel button so that users can
cancel current authentication session. But I don't have idea how to do it.
My current code is as follows:

String responseString = sendNfcRequest(username, serviceName, messageId);
 //sends request
            ServerResponse wsResponse =
parseServerResponse(responseString); //recieve resopnse

            //initiate wait for user response
            int userResult = 0;
            while (userResult == 0) {
                String userResponseString = getNfcUserResponse(wsResponse);
                userResult = getNfcUserResult(userResponseString);

                if (userResult == 0) {
                    Thread.sleep(2000);
                }
            }

            if (userResult == 1) {             //successfull authentication
on mobile phone
                Subject subj = new Subject();

                Principal principal = new UsernamePrincipal(username);
                subj.getPrincipals().add(principal);

                request.setAttribute(LoginHandler.PRINCIPAL_KEY, principal);
                request.setAttribute(LoginHandler.PRINCIPAL_NAME_KEY,
username);
                request.setAttribute(LoginHandler.SUBJECT_KEY, subj);


Logger.getLogger(ExternalAuthServlet.class.getName()).log(Level.INFO, "Nfc
authentication success", this);

                //add cookies
                Cookie userNameCookie = new Cookie("username", username);
                response.addCookie(userNameCookie);
                Cookie authMethodCookie = new Cookie("authMethod", "2");
                response.addCookie(authMethodCookie);

                AuthenticationEngine.returnToAuthenticationEngine(request,
response);
            }

On my page I have form with one button and I change its label to
"Authenticate" or "Cancel". When "Authenticate" is pressed, it runs code
above and changes label to "Cancel". When "Cancel" is pressed it does
nothing, only changes back to "Authenticate". Problem is, that when I hit
"Authenticate" again I have now two sessions running and user can response
to any of them. So my question is how to throw away previous session and
hold only the curent (last) one?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/users/attachments/20131211/e44589a4/attachment.html 


More information about the users mailing list