Hi guys!

I'm trying to make Jetspeed to get usernames from NTLM with jcifs.

Here is my class that overrides TurbineAuthentication:
----
package kz.alb.portal;

import org.apache.jetspeed.services.security.turbine.TurbineAuthentication;
import org.apache.jetspeed.services.security.*;
import org.apache.jetspeed.services.JetspeedUserManagement;
import org.apache.jetspeed.services.JetspeedSecurity;
import org.apache.jetspeed.services.resources.JetspeedResources;
import org.apache.jetspeed.services.rundata.JetspeedRunDataService;
import org.apache.jetspeed.om.security.JetspeedUser;
import org.apache.jetspeed.om.security.UserNamePrincipal;

import java.util.Date;


/** * $Id:$ */ public class NTLMPortalAuthentication extends TurbineAuthentication { /** The JetspeedRunData Service. */ private JetspeedRunDataService runDataService = null;

    private final static String CONFIG_ANONYMOUS_USER = "user.anonymous";
    String anonymousUser = "anon";
    private final static String CACHING_ENABLE = "caching.enable";
    private boolean cachingEnable = true;


/**
* Given a public credential(username) and private credential(password),
* perform authentication. If authentication succeeds, a <code>JetspeedUser</code>
* is returned representing the authenticated subject.
*
* @param username a public credential of the subject to be authenticated.
* @param password a private credentialof the subject to be authenticated.
* @return a <code>JetspeedUser</code> object representing the authenticated subject.
* @exception LoginException when general security provider failure.
* @exception FailedLoginException when the authentication failed.
* @exception AccountExpiredException when the subject's account is expired.
* @exception CredentialExpiredException when the subject's credential is expired.
*/
public JetspeedUser login(String username, String password)
throws LoginException {
JetspeedUser user = null;


username = getRunData().getRequest().getRemoteUser();

System.out.println("USERNAME1: " + username);

username = username.substring(username.indexOf('\\') + 1);// Cut off NT domain name
System.out.println("USERNAME2: " + username);


        username = JetspeedSecurity.convertUserName(username);
        System.out.println("USERNAME3: " + username);

try {
user = JetspeedUserManagement.getUser(new UserNamePrincipal(username));
System.out.println("user found! " + user.getName());
} catch(UnknownUserException e) { // If user not in database then add it.
try {
System.out.println("user not found, creating");
if(username != null && !username.equals("")) {
JetspeedUser newUser = JetspeedSecurity.getUserInstance();
newUser.setLastLogin(new Date(0));
newUser.setUserName(username);
newUser.setCreateDate(new Date());
newUser.setConfirmed(JetspeedResources.CONFIRM_VALUE);
System.out.println("user created: " + newUser.toString());


JetspeedSecurity.addUser(newUser);

System.out.println("user added: " + newUser.toString());
}
} catch(JetspeedSecurityException e1) {
throw new LoginException(e.toString());
}
} catch(JetspeedSecurityException e) {
throw new LoginException(e.toString());
}


        // Mark the user as being logged in.
        user.setHasLoggedIn(new Boolean(true));


System.out.println("Finishing"); // Set the last_login date in the database. try { user.updateLastLogin(); putUserIntoContext(user); if(cachingEnable) { JetspeedSecurityCache.load(username); } } catch(Exception e) { putUserIntoContext(JetspeedSecurity.getAnonymousUser()); throw new LoginException("Failed to update last login ", e); }

return user;

}

}
----

When I input any username that is already in database, everything works fine. When I log in under some user that is not exists in database I expect that user will be created in db, but it is not happening.

Here is the log:

----
[23 ??? 2003 17:49:49 INFO] - USERNAME1: ALB\Stealthy
[23 ??? 2003 17:49:49 INFO] - USERNAME2: Stealthy
[23 ??? 2003 17:49:49 INFO] - USERNAME3: Stealthy
[23 ??? 2003 17:49:49 INFO] - user not found, creating
[23 ??? 2003 17:49:49 INFO] - user created: [EMAIL PROTECTED]
[23 ??? 2003 17:49:49 DEBUG] - JetspeedRunDataService: accessing rundata [EMAIL PROTECTED] for thread: Thread[Thread-8,5,jboss]
[23 ??? 2003 17:49:49 DEBUG] - CapabilityMap: User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) mapped to
----


I have no idea what is happening inside of JetspeedSecurity.addUser(newUser) but where is no output for next debug line: "user added" and the user is not added in database.

Can anybody halp me with this issue?..

--
 With best regards, Dmitry



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to