hello,

as i already mentioned, please don't use your idea.
in my opinion i got your idea about a base bean, which provides this
functionality. however, as you already saw: it doesn't work.
e.g. if your beans are created within the render response phase you can't
re-navigate.
(further comments about your idea you will find within my previous answers.)

possible solutions:
- use a security extension (such as acegi)
- implement a jsf specific mechanism (you will find some comments below)
- use container based security

do you mean you would like to check if there is already a session or not?
with jsf-based solutions you have to check a custom information within the
session.
reason: jsf automatically starts a session "very early" (within the restore
view phase) - (if it is necessary)
-> e.g. you can use a session scoped bean, which contains the user name (or
whatever you would like to use...)

concerning examples:
all you need to implement a jsf specific mechanism you will find e.g. at the
first link you sent (i just had a quick look...).
both examples (the LoginNavigationHandler and the PhaseLoginEnforcer) will
satisfy your described requirements.
instead of ProxyManagerBean you can use your own session scoped bean, which
contains information you can check (as i mentioned above).
(both solutions have advantages and disadvantages.)

regards,
gerhard



2007/12/6, daniel ccss <[EMAIL PROTECTED]>:
>
> Thank you Gerhard
>
> Ok for you to know more my scenary :)
>
> 1- All the JSPs need to verify is the user is in session (not the login
> JSP obviously)
> 2- All my beans extends from a base bean, so I can have methods in it that
> all the beans can call, lets say that in all my beans the only thing I need
> to do is: if( *userInSession(....)*) where userInSession is one method is
> in the BaseBean
>
> Ok, about the two solutions that I see that can work in my case:
>
> 1-
> BaseBean
> userInSession(context){
> context.getApplication().getNavigationHandler().
>                handleNavigation(FacesContext.getCurrentInstance(),null,"*
> showLoggin*");
>
> }
>
> All the Beans on their init methods
> init()
> {
>     if(userInSession){
>        do the load of the controls
>     }else{
>
>         userInSession(FacesContext.getCurrentInstance())
>     }
> }
>
>
> The problem with this solution, is that it doesn´t work :( when I call the
> handleNavigation nothing happens, the third argument is the navigation rule
> in the faces-config right? Why it doesn´t work. Can you help me with this
>
> 2-
>
> Even do I need a simple solution and the 1 solutions will work for me, I'm
> intersting, and I  in the central/generic solution, do you have an example
> code where I can see this kind of solution.
>
> Thanks!!!
>
>
>
> On Dec 5, 2007 6:30 PM, Gerhard Petracek <[EMAIL PROTECTED]>
> wrote:
>
> > hello,
> >
> > there is no need to use shale to implement a login scenario with jsf -
> > it's just one among many possibilities...
> > concerning your question about navigation rules (within faces-config.xml)
> > to implement a login-scenario:
> > in my opinion: don't use such an approach - in such a case you have to
> > check permissions manually (scattered over the source code/pages).
> > you already mentioned an example (the if-statement), which demonstrates
> > what i'm talking about (in my opinion these if-statements - scattered over
> > the source code/pages - aren't handy - if you use them - you normally use
> > them very frequently -> it isn't a central/generic solution)...
> > - there are some details i didn't mention - just to have a short (&
> > subjective) answer :)
> > -> i prefer a central/generic solution!
> >
> > in view of examples:
> > there are really a lot of possibilities to implement such a login
> > functionality... -> your choice depends on your situation/requirements...
> > -> there is no ultimate solution -> there are many solutions -> i'm
> > confident that there are some examples...
> > e.g. - as i already mentioned: there are also "jsf independent" security
> > extensions such as acegi.
> >
> > i already provided the second link you mentioned + i've already
> > commented it.
> > in view of my previous answers: are there other open questions?
> > if there are further questions, you are welcome to ask them!!!
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2007/12/5, daniel ccss <[EMAIL PROTECTED]>:
> >
> > > I found two others links that can help to my question
> > >
> > > http://www.gorerle.com/vlab-wiki/index.php?title=JSF
> > >
> > > http://www.jsftutorials.net/jsfNavigation/jsf-login-navigation-redirect.html
> > >
> > > But I don´t think that they were clear, even the second link have a
> > > note that says:
> > >
> > > *Note: This is only an example that shows how you can use navigation
> > > handler decorator. Do NOT use it as a ready-to-use solution for login
> > > facility. Use Phase Listener instead.*
> > >
> > > I will search for a Phase Listener example, but still is not clear
> > > which is the better solution and how to implemented it.
> > >
> > > Thanks!
> > >
> > > On Dec 5, 2007 11:10 AM, daniel ccss < [EMAIL PROTECTED]> wrote:
> > >
> > > > Thanks Both of you, i was out for a while.
> > > >
> > > > Ok I think this is a common question, and not a simple question as I
> > > > wrote in my subject, something similar was talked in this thread:
> > > >
> > > >
> > > > http://forum.java.sun.com/thread.jspa?threadID=690288&messageID=4017603
> > > >
> > > > I think the NavigationHandler is the easier and nice solution, but I
> > > > have some questions about it beacause I implemented it but nothing 
> > > > happens:
> > > >
> > > >
> > > > init()
> > > > {
> > > >     if(userInSession){
> > > >        do the load of the controls
> > > >     }else{
> > > >         FacesContext.getCurrentInstance
> > > > ().getApplication().getNavigationHandler().
> > > >                handleNavigation(FacesContext.getCurrentInstance
> > > > (),null,"*showLoggin*");
> > > >
> > > >     }
> > > > }
> > > >
> > > >
> > > > 1- Is necesary to use shale-view?
> > > > 2- The third argument is a navigation rule that is in the
> > > > faces-config.xml??
> > > > 3- Can anyone give a sample code of how to do this? I think its not
> > > > clear how to handdle this, and many people will use it if is clear :).
> > > >
> > > >
> > > > Thanks
> > > >
> > > >
> > > > On Nov 23, 2007 11:40 PM, Gerhard Petracek <
> > > > [EMAIL PROTECTED]> wrote:
> > > >
> > > > > one more supplement to complete the picture of the last two mails
> > > > > - i missed to add these details at my last mail *sorry* for that...
> > > > >
> > > > > in my previous mail i wrote that the NavigationHandler approach
> > > > > doesn't solve your problem, because the init-method gets invoked 
> > > > > before. i
> > > > > missed to add some details to complete this comment because of quick
> > > > > answering. normally it works very well if you navigate to the login 
> > > > > page
> > > > > before you use the bean - which is the case if you use the whole bean 
> > > > > only
> > > > > within your target page(s) (where a successful login is required) (-> 
> > > > > the
> > > > > init-method isn't invoked if you navigate to the login page) -> it's 
> > > > > a valid
> > > > > approach as i mentioned it in my first mail.
> > > > >
> > > > > (i thought about possible scenarios where you have a combination
> > > > > of: a login isn't required for all pages - as it seems to be the case 
> > > > > within
> > > > > our application - and if you use the bean before the 
> > > > > NavigationHandler gets
> > > > > invoked - and the user hasn't logged in -> in such a special case the
> > > > > init-method recognizes that the user isn't logged in but the 
> > > > > navigation to
> > > > > the login page occurs later. i don't know your implementation details 
> > > > > and if
> > > > > such a scenario would lead to a side effect within your 
> > > > > implementation or
> > > > > not - so i skip details here.)
> > > > >
> > > > > summarized: also the NavigationHandler approach works for common
> > > > > cases (e.g. there is no problem if you navigate to the login page
> > > > > before you have the chance to use the bean) - in that case it also 
> > > > > fits into
> > > > > my summary of the first mail.
> > > > >
> > > > >
> > > > > regards,
> > > > > gerhard
> > > > >
> > > > >
> > > > >
> > > > > 2007/11/24, Gerhard Petracek < [EMAIL PROTECTED]>:
> > > > > >
> > > > > > hello daniel,
> > > > > >
> > > > > > some additional information:
> > > > > > just to avoid misunderstandings - the summary of the suggestion
> > > > > > has no reference to the NavigationHandler approach because in that 
> > > > > > case your
> > > > > > init-method would get executed before.
> > > > > >
> > > > > > generally spoken: to implement a custom NavigationHandler is
> > > > > > just an alternative approach (in your case it doesn't solve your 
> > > > > > problem).
> > > > > > if someone is interested in this approach you will find an
> > > > > > example at: 
> > > > > > http://www.jsftutorials.net/jsfNavigation/jsf-login-navigation-redirect.html
> > > > > >
> > > > > > (i didn't look at the details of this specific solution - it's
> > > > > > just an example... - and they also suggest to use a PhaseListener)
> > > > > >
> > > > > > regards,
> > > > > > gerhard
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2007/11/24, Gerhard Petracek < [EMAIL PROTECTED]>:
> > > > > > >
> > > > > > > hello daniel,
> > > > > > >
> > > > > > > i would like to suggest other solutions.
> > > > > > >
> > > > > > > i think you are familiar with the common ways of handling
> > > > > > > navigation
> > > > > > > (summarized - e.g. if you use the "from-outcome" approach an
> > > > > > > action-method returns the outcome or you use a static string 
> > > > > > > within your
> > > > > > > page - with this approach only these outcomes are used for 
> > > > > > > navigation)
> > > > > > > -> if your "init"-method is not an action method (it doesn't
> > > > > > > sound like one) - you should consider alternative solutions.
> > > > > > >
> > > > > > > --- just a general information before we start ---
> > > > > > > with this additional information i don't refer to the solution
> > > > > > > you are having in mind!
> > > > > > > basically you can manually navigate e.g. with:
> > > > > > >         
> > > > > > > FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(
> > > > > > > ... );
> > > > > > > or with:
> > > > > > >             
> > > > > > > FacesContext.getCurrentInstance().getExternalContext().redirect(
> > > > > > > ... );
> > > > > > >
> > > > > > > however, be careful with these mechanisms - they don't work at
> > > > > > > any point of your application and you risk to "break" your 
> > > > > > > application if
> > > > > > > you misuse these mechanisms.
> > > > > > > ---
> > > > > > >
> > > > > > > if you don't like to use security extensions such as Acegi you
> > > > > > > have to implement custom mechanisms to provide login pages and to 
> > > > > > > avoid
> > > > > > > initial actions within your bean. in that case i would suggest 
> > > > > > > more generic
> > > > > > > solutions - e.g. a custom PhaseListener or a custom
> > > > > > > NavigationHandler.
> > > > > > >
> > > > > > > to summarize my suggestion: use/implement a mechanism which
> > > > > > > takes place before your init-method gets executed.
> > > > > > >
> > > > > > > regards,
> > > > > > > gerhard
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2007/11/23, daniel ccss <[EMAIL PROTECTED]>:
> > > > > > > >
> > > > > > > > I have a simple question
> > > > > > > >
> > > > > > > > I have been working with myfaces-tomahawk for 6 months,
> > > > > > > > great, but I
> > > > > > > > have a question, how to call an 'action' from the backing
> > > > > > > > bean, until
> > > > > > > > today I have called all my action methods from the JSP page,
> > > > > > > > on the
> > > > > > > > onClick, onChange, etc events, but now I need to call an
> > > > > > > > action from
> > > > > > > > another method in my backing bean.
> > > > > > > >
> > > > > > > > I have an init method in my backing bean that ask if the
> > > > > > > > user is in
> > > > > > > > session, if yes all the load of the combos etc is make, if
> > > > > > > > not I need
> > > > > > > > to call a method that returns to the login page by returning
> > > > > > > > the
> > > > > > > > navigation rule like this:
> > > > > > > >
> > > > > > > > //init
> > > > > > > > {
> > > > > > > >      if(userInSession){
> > > > > > > >         do the load of the controls
> > > > > > > >      }else{
> > > > > > > >         returnToLogin();
> > > > > > > >      }
> > > > > > > > }
> > > > > > > >
> > > > > > > > private String returnToLogin(){
> > > > > > > >       return "login";
> > > > > > > > }
> > > > > > > >
> > > > > > > > and in faces-config.xml i have the navigation rule:
> > > > > > > >
> > > > > > > > <navigation-rule>
> > > > > > > >   <from-view-id>....
> > > > > > > >
> > > > > > > >   <navigation-case>
> > > > > > > >    <from-outcome>login</from-outcome>
> > > > > > > >    <to-view-id>/JSP/Login.jsp</to-view-id>
> > > > > > > >   </navigation-case>
> > > > > > > > ....
> > > > > > > >
> > > > > > > > But nothing happens, this type of call can be done?, or only
> > > > > > > > I can
> > > > > > > > call an action that returns to a navigation rule from the
> > > > > > > > JSP, if so,
> > > > > > > > how can I send the person to the login page in case he copy
> > > > > > > > the url in
> > > > > > > > the browser and never pass for the login page.
> > > > > > > >
> > > > > > > > Thanks all
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > http://www.irian.at
> > > > > > >
> > > > > > > Your JSF powerhouse -
> > > > > > > JSF Consulting, Development and
> > > > > > > Courses in English and German
> > > > > > >
> > > > > > > Professional Support for Apache MyFaces
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> > > > > > http://www.irian.at
> > > > > >
> > > > > > Your JSF powerhouse -
> > > > > > JSF Consulting, Development and
> > > > > > Courses in English and German
> > > > > >
> > > > > > Professional Support for Apache MyFaces
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > > http://www.irian.at
> > > > >
> > > > > Your JSF powerhouse -
> > > > > JSF Consulting, Development and
> > > > > Courses in English and German
> > > > >
> > > > > Professional Support for Apache MyFaces
> > > > >
> > > >
> > > >
> > >
> >
> >
> > --
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
>
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Reply via email to