users@glassfish.java.net

Re: Glassfish V3 custom realm issue

From: <glassfish_at_javadesktop.org>
Date: Fri, 04 Jun 2010 07:21:32 PDT

Hello,

I have done all you explain in the attached zip file and now this is the CustomerBean backing bean,

public class CustomerBean {
    @EJB
    private AccountController accountController;
    private Long account;
    private Long customerId;
    @EJB
    private TxController txController;
    private CustomerBeanPassiveCallbackHandler ch;
        private String user;
        private String password;
        private boolean succeeded;

    public CustomerBean() {
            /*
            customerId = Long.parseLong(
            FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal().getName());
        */
    }
    
    @SuppressWarnings("static-access")
        public String logon(){
                WorkingDirectory wd = new WorkingDirectory("login.configuration");
                String pathToResource = wd.get().getAbsolutePath();
                System.setProperty("java.security.auth.login.config", pathToResource);
        ch = new CustomerBeanPassiveCallbackHandler(getUser(), getPassword()); //("200", "javaee")
        try {
          InitialContext ic = new InitialContext();
          LoginContext lc = new LoginContext("dukesbankRealm", ch);
          lc.login();
          setSucceeded(true);
        } catch (LoginException e) {
                        // TODO Auto-generated catch block
                setSucceeded(false);
                } catch (NamingException e) {
                        // TODO Auto-generated catch block
                        setSucceeded(false);
                }
                
                if(isSucceeded()) {
                        customerId = Long.parseLong(getUser());
                        return null;
                } else {
                        customerId = null;
                        return "error";
                }
        }
        
        public String getUser() {
                return user;
        }

        public void setUser(String user) {
                this.user = user;
        }

        public String getPassword() {
                return password;
        }

        public void setPassword(String password) {
                this.password = password;
        }

        public void setSucceeded(boolean succeeded) {
                this.succeeded = succeeded;
        }

        public boolean isSucceeded() {
                return succeeded;
        }

        public TxController getTxController() {
        return txController;
    }

    public Long getCustomerId() {
        return customerId;
    }
    
    public void setCustomerId(Long customerId) {
            this.customerId = customerId;
    }

    public void setActiveAccount(Long account) {
        this.account = account;
    }

    public Long getActiveAccount() {
        return this.account;
    }

    public AccountDetails getAccountDetails() {
        AccountDetails ad = null;

        try {
            ad = accountController.getDetails(this.account);
        } catch (InvalidParameterException e) {
            Debug.print(e.getMessage());

            // Not possible
        } catch (AccountNotFoundException e) {
            Debug.print(e.getMessage());

            // Not possible
        }

        if (ad != null) {
            Debug.print(
                "account ID: ",
                ad.getAccountId());
        }

        return ad;
    }

    public List<AccountDetails> getAccounts() {
        List<AccountDetails> accounts = null;

        try {
            accounts = accountController.getAccountsOfCustomer(customerId);
        } catch (InvalidParameterException e) {
            Debug.print(e.getMessage());

            // Not possible
        } catch (CustomerNotFoundException e) {
            Debug.print(e.getMessage());

            // Not possible
        }

        return accounts;
    }

    public Object logout() {
        HttpSession session = (HttpSession) Util.getExternalContext()
                                                .getSession(true);
        session.invalidate();

        return Navigation.main;
    }
}

But when I launch the web app it does the login correctly but there is no transition to the application page with the links and so on.

Do you know the life cycle of the Duke’s Bank web?, or can you indicate me a page where I can understand this life cycle?

Up to date my app does the login but there is no connection between the login action an the rest of the application.

While waiting for your answer I will keep on trying.

Regards,
Jose
[Message sent by forum member 'josealvarezdelara']

http://forums.java.net/jive/thread.jspa?messageID=472762