Resin's Custom Authentication

307 views Asked by At

I'm glad stackoverflow exists at least there is traffic. Sorry for asking these here but posting a question in caucho forums takes weeks to appear apparently.

I was fallowing a guide to have a custom login form for my service, but the guide was written for Resin version 1 I guess, and I'm working on version 4 and there are some custom tags that I don't fully understand and even the documentation for Resin 4 has some errors.

The tags are the next ones:

<login-config> <auth-method>FORM</auth-method> <form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page> </form-login-config>
<authenticator id='MyAuthenticator'/>
</login-config>

Version 4 tags where changed but I don't quite understand the "foo bar" analogy. I did watch Rescuing Soldier Ryan movie so Foobar sounds a little unprofessional and misleading.

<foo:MyAuthenticator>
    <foo:foo>bar</foo:foo>
  </foo:MyAuthenticator>

<resin:FormLogin form-login-page="/" form-error-page="/" />

I'm not totally sure but he getUser() method doesn't exists in the com.caucho.security.AbstractAuthenticator documentation. The method is called getPassworduser(). I know, people make mistakes, at least I have, and a lot.

package com.foo;

    import com.caucho.security.AbstractAuthenticator;
    import com.caucho.security.PasswordUser;

    public class MyAuthenticator extends AbstractAuthenticator {
      private PasswordUser _user;

      public MyAuthenticator()
      {
        _user = new PasswordUser("harry", "quidditch",
                                 new String[] { "user" });
      }

      public PasswordUser getUser(String userName)
      {
        if (userName.equals(_user.getName()))
          return _user;
        else
          return null;
      }
    }

So, can someone be so kind to explain me a little bit the new tag syntax? What if my package is called com.subpackage1.subpackage2? what represents the "bar" element? What comes first? <resin:FormLogin ...> or <foo:MyAuthenticator>...</foo:MyAuthenticator> How can I link my form to the authenticator considering that they are both separate tags?

1

There are 1 answers

3
jigzat On BEST ANSWER

Ok, thank you to those who read it and maybe try to answer. I just found a very useful document on the resin 4 migration. The link is here. Basically I have to set my own path in the web-app tag like these:

<web-app xmlns="http://caucho.com/ns/resin" xmlns:mycustomtag="urn:java:com.my.package">

then I just use the tag like these:

<mycustomtag:MyClass>
  <mycustomtag:customAttribute>someAtributte
  </mycustomtag:customAttribute>
</mycustomtag:MyClass>

I hope this is useful for someone, please show your love and give me a thumbs up by voting my answer.