} catch (UnknownServicePrincipalException failure) { fail("UnknownServicePrincipalException should not be caught");
    public void testAttemptLogin() throws MoriaControllerException {        final String validSSOTicketId = "1234";        final String validLoginTicketId = "4321";        final boolean denySSO = false;        /* Check controller initialization */        controllerInitialization();        /* Illegal arguments */        try {            MoriaController.attemptLogin(null, validSSOTicketId, validUsername, validPassword, denySSO);            fail("IllegalInputException should be raised, loginTicketId is null");        } catch (IllegalInputException success) {        }        try {            MoriaController.attemptLogin("", validSSOTicketId, validUsername, validPassword, denySSO);            fail("IllegalInputException should be raised, loginTicketId is an empty string");        } catch (IllegalInputException success) {        }        try {            MoriaController.attemptLogin(validLoginTicketId, validSSOTicketId, null, validPassword, denySSO);            fail("IllegalInputException should be raised, username is null");        } catch (IllegalInputException success) {        }        try {            MoriaController.attemptLogin(validLoginTicketId, validSSOTicketId, "", validPassword, denySSO);            fail("IllegalInputException should be raised, username is an empty string");        } catch (IllegalInputException success) {        }        try {            MoriaController.attemptLogin(validLoginTicketId, validSSOTicketId, validUsername, null, denySSO);            fail("IllegalInputException should be raised, username is null");        } catch (IllegalInputException success) {        }        try {            MoriaController.attemptLogin(validLoginTicketId, validSSOTicketId, validUsername, "", denySSO);            fail("IllegalInputException should be raised, username is an empty string");        } catch (IllegalInputException success) {        }        /* SSO ticket can be empty */        String loginTicketId = MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false,                                                                      validPrincipal);        MoriaController.attemptLogin(loginTicketId, null, validUsername, validPassword, denySSO);        loginTicketId = MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false,                                                               validPrincipal);        MoriaController.attemptLogin(loginTicketId, "", validUsername, validPassword, denySSO);        /* Non-existing login ticket */        try {            MoriaController.attemptLogin("doesNotExist", validSSOTicketId, validUsername, validPassword, denySSO);            fail("UnknownTicketException should be raised, non-existing ticket");        } catch (UnknownTicketException success) {        }        /* Non-existing SSO ticket (allowed) */        loginTicketId = MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false,                                                               validPrincipal);        MoriaController.attemptLogin(loginTicketId, "doesNotExist", validUsername, validPassword, denySSO);        /* Removal of existing SSO ticket */        loginTicketId = MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false,                                                               validPrincipal);        Map tickets = MoriaController.attemptLogin(loginTicketId, "doesNotExist", validUsername, validPassword, denySSO);        final String ssoTicketId = (String) tickets.get(MoriaController.SSO_TICKET);        loginTicketId = MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false,                                                               validPrincipal);        MoriaController.attemptLogin(loginTicketId, ssoTicketId, validUsername, validPassword, denySSO);        loginTicketId = MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false,                                                               validPrincipal);        try {            MoriaController.attemptSingleSignOn(loginTicketId, ssoTicketId);            fail("UnknownTicketException should be raised, SSO ticket should be removed from the store");        } catch (UnknownTicketException success) {        }        /* Use of same login ticket twice, authentication failure = OK */        loginTicketId =        MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false, validPrincipal);        try {            MoriaController.attemptLogin(loginTicketId, null, validUsername, "wrongPassword", denySSO);        } catch (AuthenticationException success) {        }        MoriaController.attemptLogin(loginTicketId, null, validUsername, validPassword, denySSO);        /* Use of same login ticket twice when authentication was OK first time = ERROR */        loginTicketId =        MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false, validPrincipal);        MoriaController.attemptLogin(loginTicketId, null, validUsername, validPassword, denySSO);        try {            MoriaController.attemptLogin(loginTicketId, null, validUsername, validPassword, denySSO);        } catch (UnknownTicketException success) {        }        /* Wrong username */        loginTicketId = MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false,                                                               validPrincipal);        try {            MoriaController.attemptLogin(loginTicketId, null, "wrong", validPassword, denySSO);            fail("AuthenticationFailedException should be raised, wrong username");        } catch (AuthenticationException success) {        }        /* Wrong password */        try {            MoriaController.attemptLogin(loginTicketId, null, validUsername, "wrong", denySSO);            fail("AuthenticationFailedException should be raised, wrong username");        } catch (AuthenticationException success) {        }                /* Userorg test */        loginTicketId=MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false, validPrincipal);        try {            MoriaController.attemptLogin(loginTicketId, null, validUsername2, validPassword, denySSO);            fail("AuthorizationFailedException should be raised, userorg is not allowed");        }catch (AuthorizationException success) {        }                /* Normal use */        loginTicketId =        MoriaController.initiateAuthentication(validAttrs, validPrefix, validPostfix, false, validPrincipal);        tickets = MoriaController.attemptLogin(loginTicketId, null, validUsername, validPassword, denySSO);        final Map actualAttrs = MoriaController.getUserAttributes((String) tickets.get(MoriaController.SERVICE_TICKET),                                                            validPrincipal);        validateMaps(expectedAttrs, actualAttrs);    }