Just LDAPUsers.java and LDAPUsersFactory.java should suffice and
setting its name as a 'credentialsmanagerfactory_class' property of a
regular authentication element.
On 16 Apr 2007, at 13:29, Eskil Lauritsen wrote:
Hi, Geert
In addition to LDAPUsers.java and LDAPUsersFactory.java, what more
files do we need? Do we need a LDAPAuthenticatedDeployer.java and
LDAPAuthenticated.java too?
Also, which XML-file do we use for the setting of the properties?
main.xml? Just like any element?
<element id="LDAPUsers" implementation="LDAPUsers" />
etc?
Sincerely
Eskil Lauritsen
On 4/14/07, Geert Bevin <[EMAIL PROTECTED]> wrote:
Hi Eskil,
using the upcoming RIFE 1.6, it's very easy to plug in your own
credentials manager into an authentication element. There are no docs
about that yet, but you can do this by setting the
"credentialsmanagerfactory_class" property to the class of your
CredentialsManagerFactory. This might help you along: https://
svn.rifers.org/rife/trunk/src/framework/com/uwyn/rife/authentication/
elements/DatabaseAuthenticatedDeployer.java
Note that these properties don't have to be set in Java, you can set
like you do for any RIFE element property, in XML for example.
Hope this helps.
Take care,
Geert
On 13 Apr 2007, at 09:35, Eskil Lauritsen wrote:
> We're trying to make a credentials manager for authenticating
against
> LDAP.
>
> We've written some code but we're unsure about what to do next,
> or if the code is correct. Any ideas?
>
>
>
> Code:
>
> package com.uwyn.rife.authentication.credentialsmanagers;
> import com.novell.ldap.*;
> import com.uwyn.rife.authentication.*;
>
> import com.uwyn.rife.authentication.Credentials;
> import com.uwyn.rife.authentication.CredentialsManager;
> import
com.uwyn.rife.authentication.credentials.RoleUserCredentials;
> import
>
com.uwyn.rife.authentication.exceptions.CredentialsManagerException;
> import java.io.UnsupportedEncodingException;
>
> public class LDAPUsers implements CredentialsManager {
>
>
> static long userid;
>
> public long verifyCredentials(Credentials credentials) {
> RoleUserCredentials cred = (RoleUserCredentials)
> credentials;
> String loginDN = "cn=" + cred.getLogin() +
> ",dc=localhost";
> String password = cred.getPassword();
> return authenticate(loginDN, password);
> }
>
> public static long authenticate(String loginDN, String
> password) {
> int ldapPort = LDAPConnection.DEFAULT_PORT;
> int ldapVersion = LDAPConnection.LDAP_V3;
> String ldapHost = "localhost";
> boolean success = false;
>
> LDAPResponseQueue queue = null;
> LDAPConnection lc = new LDAPConnection();
> int rc = 0;
> try {
> lc.connect(ldapHost, ldapPort);
> queue = lc.bind(ldapVersion,
> loginDN,password.getBytes("UTF8"),
> (LDAPResponseQueue)null );
> LDAPResponse rsp = (LDAPResponse)queue.getResponse();
> String msg;
> rc = rsp.getResultCode();
> msg = rsp.getErrorMessage();
>
> if(rc == LDAPException.SUCCESS) {
> success = true;
> } else {
> throw new LDAPException( msg, rc, (String)null );
> };
> lc.disconnect();
> } catch (LDAPException e) {
> if (e.getResultCode() ==
> LDAPException.NO_SUCH_OBJECT) {
> System.err.println("Error: No such
> user name");
> } else if (e.getResultCode() ==
> LDAPException.NO_SUCH_ATTRIBUTE) {
> System.err.println("Error: No such
> attribute");
> } else {
> System.err.println("Error: " +
> e.toString());
> }
> } catch (UnsupportedEncodingException e) {
> System.out.println("Error: " + e.toString());
> }
>
> if(success) {
> return userid++;
> } else {
> return -1;
> }
> }
> }
> _______________________________________________
> Rife-users mailing list
> Rife-users@uwyn.com
> http://lists.uwyn.com/mailman/listinfo/rife-users
>
--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com
_______________________________________________
Rife-users mailing list
Rife-users@uwyn.com
http://lists.uwyn.com/mailman/listinfo/rife-users
_______________________________________________
Rife-users mailing list
Rife-users@uwyn.com
http://lists.uwyn.com/mailman/listinfo/rife-users
--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com
_______________________________________________
Rife-users mailing list
Rife-users@uwyn.com
http://lists.uwyn.com/mailman/listinfo/rife-users