@isra123
ah by the way the error I got is:
og4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax). log4j:WARN Please initialize the log4j system properly. Dec 31, 2008 1:43:57 PM org.apache.catalina.core.StandardContext start INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Login] has already been started java.lang.NullPointerException at CRC.AlfrescoServices.getServiceRegistry(AlfrescoSe rvices.java:52) at CRC.AlfrescoServices.getAuthenticationService(Alfr escoServices.java:36) at CRC.AlfUserServices.login(AlfUserServices.java:28) at CRC.CrcLogin.Check_Valid
**************
This is the my code which has the problem :
package CRC;
import java.io.Serializable;
import java.beans.EventHandler;
import java.util.Date;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
/*
* CrcLogin.java
*
* Created on November 30, 2008, 12:30 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author SPAREWNMAN
*/
public class CrcLogin {
/** Creates a new instance of CrcLogin */
public CrcLogin() {
}
private String UserName;
private String PassWord;
public String Check_Validate()
{
AlfUserServices alfUserServices=new AlfUserServices();
System.out.println(alfUserServices.login(getUserNa me(),getPassWord()));
System.out.println(getUserName()+" : "+getPassWord());
FacesContext context =FacesContext.getCurrentInstance();
HttpSession session=(HttpSession) context.getExternalContext().getSession(true);
System.out.println(session);
System.out.println(UserName + " has logged in at " + new Date());
System.out.println(alfUserServices.login(getUserNa me(),getPassWord()));
return"success";
}
/*else
System.out.println(getUserName()+" : "+getPassWord());
System.out.println("Invalide User");
return"failed";*/
public String getUserName() {
return UserName;
}
public void setUserName(String UserName) {
this.UserName = UserName;
}
public void setPassWord(String PassWord) {
this.PassWord = PassWord;
}
public String getPassWord() {
return PassWord;
}
}
================================================== ===========================================
================================================== ===========================================
package CRC;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAwar e;
/**
*
* @author SPAREWNMAN
*/
public class ContextAwareClass implements ApplicationContextAware {
private static ApplicationContext ctx;
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
ctx = applicationContext;
}
public static void displayAppContext() {
System.out.println(ctx);
}
public static ApplicationContext getAppContext() {
return ctx;
}
/** Creates a new instance of ContextAwareClass */
public ContextAwareClass() {
}
}
================================================== ===========================================
================================================== ===========================================
package CRC;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthenticationSe rvice;
import org.springframework.context.ApplicationContext;
/**
*
* @author SPAREWNMAN
*/
public class AlfrescoServices {
private ServiceRegistry serviceRegistry;
private AuthenticationService authenticationService;
/** Creates a new instance of AlfrescoServices */
public AlfrescoServices() {
}
protected void setAuthenticationService(
AuthenticationService authenticationService) {
this.authenticationService = authenticationService;
}
protected AuthenticationService getAuthenticationService() {
if (authenticationService == null)
authenticationService = getServiceRegistry()
.getAuthenticationService();
return authenticationService;
}
protected void setServiceRegstry(ServiceRegistry serviceRegstry) {
this.serviceRegistry = serviceRegstry;
}
protected ServiceRegistry getServiceRegistry() {
if (serviceRegistry == null) {
ApplicationContext ctx = ContextAwareClass.getAppContext();
//ApplicationContext ctx = ApplicationContextHelper
//.getApplicationContext();
serviceRegistry = (ServiceRegistry) ctx
.getBean(ServiceRegistry.SERVICE_REGISTRY);
}
return serviceRegistry;
}
}
================================================== ===========================================
================================================== ===========================================
package CRC;
import org.alfresco.service.cmr.security.AuthenticationSe rvice;
import java.util.Hashtable;
import java.util.Map;
import org.alfresco.model.ContentModel;
/**
*
* @author SPAREWNMAN
*/
public class AlfUserServices extends AlfrescoServices {
/** Creates a new instance of AlfUserServices */
public AlfUserServices() {
}
public boolean login(String username,String password){
try{
AuthenticationService authenticationService = getAuthenticationService();
authenticationService.authenticate(username, password.toCharArray());
}
catch(Exception e){e.printStackTrace();
return false;}
return true;
}
}
================================================== ===========================================
================================================== ===========================================