Custom login authentication

Hi,

I have a requirement where the directory system is not an industry standard directory system .It is not a LDAP or Database ,it is a custom directory system which cannot be configured in the MWS directory services.
We are providing a userid and password to the directory system by webservice call and it will return the status message.
Based on the status message , we have to go the landing page which is a task inbox screen.

Task can be assigned only if the users are configured in the MWS. If any one has faced this kind of situation.Please guide me.

Regards
Saravanan G

Login using a generic user:

	    IDirectorySession session = DirectorySystemFactory.getDirectorySystem().createSession(); 
	    
	    IDirectoryUser userlogin = session.authenticateUser(getDomainUser(), getDomainUserPassword());			
		
	    javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest)com.webmethods.portal.framework.impl.PortalServlet.getCurrentRequest(); 
	    
        AuthInfo authInfo = AuthInfo.getAuthInfo(request.getSession());
        authInfo.setUserName(getDomainUser());
        authInfo.setInfo(getDomainUser(), getDomainUserPassword(), "", "");
        authInfo.setIsAnonymous(false);
        authInfo.setIsPrivilegedInfo(false);

and impersonate with the user of your choice:

	    IContext context;			
		context = ContextFactory.acquireContext(true);

	    IBizPolicyManager bpm = (IBizPolicyManager) PortalSystem.getBizPolicyProvider(); 
	    IDirSystemBizPolicy dirSystemPolicy = (IDirSystemBizPolicy) bpm.getBizPolicy(IBizPolicyNames.DIRECTORY_SYSTEM); 

	    // lookup user by UID 
	    		    
	    IDirUser user = (IDirUser) dirSystemPolicy.lookupPrincipalByID(context, userID, IDirSystem.TYPE_USER); 
	    IThingID userThingID = user.getDirectoryPrincipalID();		    
	     
	    boolean currentIsAdmin = context.isAdminSession();
	    
	    context.impersonate(userThingID, currentIsAdmin );

regards

Hi Norberto,

I have created a custom login page and made it as default login page.
After authentication i have used the code given by you with some modification.

Please find below the my code

public String submit() throws PortalException, ServletException, IOException {
resolveDataBinding(SUBMIT_PROPERTY_BINDINGS, this, “submit.this”, true, false);

    String Loginsuccess = getLdapAuthentication().getResult().getStatus().toString();
    	        
    System.out.println(Loginsuccess);

    RequestDispatcher rd = null;
    

    IDirectorySession session = DirectorySystemFactory.getDirectorySystem().createSession(); 

if (Loginsuccess.equalsIgnoreCase(“ok”) )

 {
  javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest)com.webmethods.portal.framework.impl.PortalServlet.getCurrentRequest(); 
    javax.servlet.http.HttpServletResponse response=(javax.servlet.http.HttpServletResponse)com.webmethods.portal.framework.impl.PortalServlet.getCurrentResponse();

  
    	   	
    	//IDirectoryUser userlogin = session.authenticateUser(getDomainUser(), getDomainUserPassword()); 

    	IDirectoryUser userlogin = session.authenticateUser("Administrator", "manage"); 

    	AuthInfo authInfo = AuthInfo.getAuthInfo(request.getSession()); 
    	authInfo.setUserName("Administrator"); 
    	authInfo.setInfo("Administrator", "manage", "", ""); 
    	authInfo.setIsAnonymous(false); 
    	authInfo.setIsPrivilegedInfo(false); 

    	//and impersonate with the user of your choice: 
    	IContext context; 
    	context = ContextFactory.acquireContext(true); 

    	IBizPolicyManager bpm = (IBizPolicyManager) PortalSystem.getBizPolicyProvider(); 
    	IDirSystemBizPolicy dirSystemPolicy = (IDirSystemBizPolicy) bpm.getBizPolicy(IBizPolicyNames.DIRECTORY_SYSTEM); 

    	// lookup user by UID 
       // String LdapUserid = getLdapAuthentication().getParameters().getLdapAuthentication().getUserid();
    	IDirUser user = (IDirUser) dirSystemPolicy.lookupPrincipalByID(context,"Administrator", IDirSystem.TYPE_USER); 
    	IThingID userThingID = user.getDirectoryPrincipalID(); 

    	boolean currentIsAdmin = context.isAdminSession(); 

    	context.impersonate(userThingID, currentIsAdmin);	
    	
    	String redirectURL = "http://10.100.10.100:8585/portlet/sampleproject___landingpage";
    		    	
	    response.sendRedirect(redirectURL);

   	return "success";
    		    	  
  }
  else {
	  //javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest)com.webmethods.portal.framework.impl.PortalServlet.getCurrentRequest(); 
	    javax.servlet.http.HttpServletResponse response=(javax.servlet.http.HttpServletResponse)com.webmethods.portal.framework.impl.PortalServlet.getCurrentResponse();

  	
 	String redirectURL = "http://www.avajava.com/tutorials/lessons/what-is-a-request-dispatcher-and-how-do-i-use-it.html";
    response.sendRedirect(redirectURL);
   	return "fail";
    }

}

But on click of submit button , no action is taking place. Only the URL is changing . It is not going to the page mentioned in the URL.It is showing only the custom login.

Try to use

getFacesContext().getExternalContext().redirect(String url);

regards.

Hi Norberto,

I am getting session time out error after one minute, if i use the above code

Any idea how to increase the session time .

Regards
Saravanan G

This may be help you:

regards

Application can be made web application, webMethods 8.x support tasks on webapps. If its webapp, we can maintain custom login page/login action makes your work simple and maintainable etc. As Directory service cannot be configured in MWS, i guess this would be a better and easy approach.

Also you can use Task API wherever needed as java/webservice calls.

I leave it to CAF gurus.