@isra123
ah by the way the error I got is:
og4j:WARN No appenders could be found for logger (org.apache.com mons.digester.D igester.sax). log4j:WARN Please initialize the log4j system properly. Dec 31, 2008 1:43:57 PM org.apache.cata lina.core.Stand ardContext start INFO: Container org.apache.cata lina.core.Conta inerBase.[Catalina].[localhost].[/Login] has already been started java.lang.NullP ointerException at CRC.AlfrescoSer vices.getServic eRegistry(Alfre scoServices.jav a:52) at CRC.AlfrescoSer vices.getAuthen ticationService (AlfrescoServic es.java:36) at CRC.AlfUserServ ices.login(AlfU serServices.jav a:28) at CRC.CrcLogin.Ch eck_Valid
**************
This is the my code which has the problem :
package CRC;
import java.io.Seriali zable;
import java.beans.Even tHandler;
import java.util.Date;
import javax.faces.con text.FacesConte xt;
import javax.servlet.h ttp.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.prin tln(alfUserServ ices.login(getU serName(),getPa ssWord()));
System.out.prin tln(getUserName ()+" : "+getPassWord() );
FacesContext context =FacesContext.g etCurrentInstan ce();
HttpSession session=(HttpSe ssion) context.getExte rnalContext().g etSession(true) ;
System.out.prin tln(session);
System.out.prin tln(UserName + " has logged in at " + new Date());
System.out.prin tln(alfUserServ ices.login(getU serName(),getPa ssWord()));
return"success" ;
}
/*else
System.out.prin tln(getUserName ()+" : "+getPassWord() );
System.out.prin tln("Invalide User");
return"failed"; */
public String getUserName() {
return UserName;
}
public void setUserName(Str ing UserName) {
this.UserName = UserName;
}
public void setPassWord(Str ing PassWord) {
this.PassWord = PassWord;
}
public String getPassWord() {
return PassWord;
}
}
=============== =============== =============== =============== =============== =============== ===
=============== =============== =============== =============== =============== =============== ===
package CRC;
import org.springframe work.beans.Bean sException;
import org.springframe work.context.Ap plicationContex t;
import org.springframe work.context.Ap plicationContex tAware;
/**
*
* @author SPAREWNMAN
*/
public class ContextAwareCla ss implements ApplicationCont extAware {
private static ApplicationCont ext ctx;
public void setApplicationC ontext(Applicat ionContext applicationCont ext)
throws BeansException {
ctx = applicationCont ext;
}
public static void displayAppConte xt() {
System.out.prin tln(ctx);
}
public static ApplicationCont ext getAppContext() {
return ctx;
}
/** Creates a new instance of ContextAwareCla ss */
public ContextAwareCla ss() {
}
}
=============== =============== =============== =============== =============== =============== ===
=============== =============== =============== =============== =============== =============== ===
package CRC;
import org.alfresco.se rvice.ServiceRe gistry;
import org.alfresco.se rvice.cmr.secur ity.Authenticat ionService;
import org.springframe work.context.Ap plicationContex t;
/**
*
* @author SPAREWNMAN
*/
public class AlfrescoService s {
private ServiceRegistry serviceRegistry ;
private AuthenticationS ervice authenticationS ervice;
/** Creates a new instance of AlfrescoService s */
public AlfrescoService s() {
}
protected void setAuthenticati onService(
AuthenticationS ervice authenticationS ervice) {
this.authentica tionService = authenticationS ervice;
}
protected AuthenticationS ervice getAuthenticati onService() {
if (authentication Service == null)
authenticationS ervice = getServiceRegis try()
.getAuthenticat ionService();
return authenticationS ervice;
}
protected void setServiceRegst ry(ServiceRegis try serviceRegstry) {
this.serviceReg istry = serviceRegstry;
}
protected ServiceRegistry getServiceRegis try() {
if (serviceRegistr y == null) {
ApplicationCont ext ctx = ContextAwareCla ss.getAppContex t();
//ApplicationCont ext ctx = ApplicationCont extHelper
//.getApplication Context();
serviceRegistry = (ServiceRegistr y) ctx
.getBean(Servic eRegistry.SERVI CE_REGISTRY);
}
return serviceRegistry ;
}
}
=============== =============== =============== =============== =============== =============== ===
=============== =============== =============== =============== =============== =============== ===
package CRC;
import org.alfresco.se rvice.cmr.secur ity.Authenticat ionService;
import java.util.Hasht able;
import java.util.Map;
import org.alfresco.mo del.ContentMode l;
/**
*
* @author SPAREWNMAN
*/
public class AlfUserServices extends AlfrescoService s {
/** Creates a new instance of AlfUserServices */
public AlfUserServices () {
}
public boolean login(String username,String password){
try{
AuthenticationS ervice authenticationS ervice = getAuthenticati onService();
authenticationS ervice.authenti cate(username, password.toChar Array());
}
catch(Exception e){e.printStack Trace();
return false;}
return true;
}
}
=============== =============== =============== =============== =============== =============== ===
=============== =============== =============== =============== =============== =============== ===