2013-06-04 37 views
0

我正在爲我的Alfresco JLan創建自定義身份驗證器。Alfresco JLan SMB/CIFS自定義身份驗證器錯誤

這裏是我的jlanConfig.xml

<?xml version="1.0" standalone="no"?> 
<!-- <!DOCTYPE jlanserver SYSTEM "jlanserver.dtd"> --> 

<jlanserver> 
    <servers> 
    <SMB/> 
    <noFTP/> 
    <noNFS/> 
    </servers> 

    <SMB> 
    <host name="NUAGESERVER" domain="NUAGE"> 
     <broadcast>255.255.255.0</broadcast> 
     <smbdialects>LanMan,NT</smbdialects> 
     <comment>Alfresco JLAN Server</comment> 

     <Win32NetBIOS/> 
     <Win32Announce interval="5"/> 

     <!-- To run the server using a non-root account on linux, Mac OS X, Solaris --> 

     <netBIOSSMB sessionPort="1139" namePort="1137" datagramPort="1138" platforms="linux,macosx,solaris"/> 
     <tcpipSMB port="1445" platforms="linux,macosx,solaris"/> 


     <hostAnnounce interval="5"/> 
    </host> 
    <sessionDebug flags="Negotiate,Socket,Tree"/> 
    <netbiosDebug/> 
    <announceDebug/> 

     <authenticator> 
      <class>com.ye.nuage.auth.NuageAuthenticator</class> 
     <Debug/> 
     </authenticator> 

    </SMB> 

    <FTP> 
    <port>21</port> 
    <allowAnonymous/> 
    <debug flags="File,Search,Error,DataPort,Directory"/> 
    </FTP> 

    <NFS> 
    <enablePortMapper/> 
    <debug flags="File,FileIO"/> 
    </NFS> 

    <debug> 
    <output> 
     <class>org.alfresco.jlan.debug.ConsoleDebug</class> 
     <logFile>jlansrv.log</logFile> 
     <append/> 
    </output> 
    </debug> 

    <shares> 
    <diskshare name="JLAN" comment="Test share"> 
     <driver> 
     <class>org.alfresco.jlan.smb.server.disk.JavaFileDiskDriver</class> 
     <LocalPath>.</LocalPath> 
     </driver> 
    </diskshare> 
    </shares>  

    <security> 
    <JCEProvider>cryptix.jce.provider.CryptixCrypto</JCEProvider> 
    <authenticator> 
     <class>com.ye.nuage.auth.NuageAuthenticator</class> 
     <mode>USER</mode> 
    </authenticator> 

    <users> 
     <user name="jlansrv"> 
     <password>jlan</password> 
     <comment>System administrator</comment> 
     <administrator/> 
     </user> 
     <user name="normal"> 
     <password>normal</password> 
     </user> 
    </users> 
    </security> 
</jlanserver> 

我NuageAuthenticator是CifsAuthenticator的副本,節選這些方法:

Override 
public int authenticateUser(ClientInfo client, SrvSession sess, int alg) { 

    // Check if the user exists in the user list 
    UserAccount userAcc = null; 
    try { 
     userAcc = getNuageUserDetails(client.getUserName()); 
    } catch (YeException e) { 
     e.printStackTrace(); 
    } 
    if (userAcc != null) { 

     // Validate the password 

     boolean authSts = false; 

     if (client.getPassword() != null) { 

      // Validate using the Unicode password 

      authSts = validateNuagePassword(userAcc, client, sess.getAuthenticationContext(), alg); 
     } else if (client.hasANSIPassword()) { 

      // Validate using the ANSI password with the LanMan encryption 

      authSts = validateNuagePassword(userAcc, client, sess.getAuthenticationContext(), LANMAN); 
     } 

     // Return the authentication status 

     return authSts == true ? AUTH_ALLOW : AUTH_BADPASSWORD; 
    } 

    // Check if this is an SMB/CIFS null session logon. 
    // 
    // The null session will only be allowed to connect to the IPC$ named 
    // pipe share. 

    if (client.isNullSession() && sess instanceof SMBSrvSession) 
     return AUTH_ALLOW; 

    // Unknown user 

    return allowGuest() ? AUTH_GUEST : AUTH_DISALLOW; 
} 

private UserAccount getNuageUserDetails(String userName) throws YeException { 
    if (context == null) { 
     context = new ClassPathXmlApplicationContext("/applicationContext-nuage.xml"); 
    } 
    userRepository = context.getBean(UserRepository.class); 
    User u = userRepository.findByUserLogin(userName); // Search the user into my repository 
    if (u != null) { 
     UserAccount ua = new UserAccount(); 
     ua.setMD4Password(u.getUserMd4Password().getBytes()); 
     ua.setUserName(userName); 
     ua.setRealName(u.getUserFirstName() + " " + u.getUserLastName()); 
     return ua; 
    } 
    return null; 
} 

但是,當我嘗試登錄,我收到以下錯誤當我打電話給validatePassword方法。

[T2] Closing session due to exception 
java.lang.ArrayIndexOutOfBoundsException 
    at java.lang.System.arraycopy(Native Method) 
    at com.ye.nuage.auth.NuageAuthenticator.validatePassword(NuageAuthenticator.java:123) 
    at com.ye.nuage.auth.NuageAuthenticator.authenticateUser(NuageAuthenticator.java:60) 
    at org.alfresco.jlan.server.auth.CifsAuthenticator.processSessionSetup(CifsAuthenticator.java:572) 
    at org.alfresco.jlan.smb.server.NTProtocolHandler.procSessionSetup(NTProtocolHandler.java:396) 
    at org.alfresco.jlan.smb.server.NTProtocolHandler.runProtocol(NTProtocolHandler.java:213) 
    at org.alfresco.jlan.smb.server.SMBSrvSession.processPacket(SMBSrvSession.java:1439) 
    at org.alfresco.jlan.smb.server.nio.NIOCIFSThreadRequest.runRequest(NIOCIFSThreadRequest.java:104) 
    at org.alfresco.jlan.server.thread.ThreadRequestPool$ThreadWorker.run(ThreadRequestPool.java:141) 
    at java.lang.Thread.run(Thread.java:722) 
java.lang.ArrayIndexOutOfBoundsException 
    at java.lang.System.arraycopy(Native Method) 
    at com.ye.nuage.auth.NuageAuthenticator.validatePassword(NuageAuthenticator.java:123) 
    at com.ye.nuage.auth.NuageAuthenticator.authenticateUser(NuageAuthenticator.java:60) 
    at org.alfresco.jlan.server.auth.CifsAuthenticator.processSessionSetup(CifsAuthenticator.java:572) 
    at org.alfresco.jlan.smb.server.NTProtocolHandler.procSessionSetup(NTProtocolHandler.java:396) 
    at org.alfresco.jlan.smb.server.NTProtocolHandler.runProtocol(NTProtocolHandler.java:213) 
    at org.alfresco.jlan.smb.server.SMBSrvSession.processPacket(SMBSrvSession.java:1439) 
    at org.alfresco.jlan.smb.server.nio.NIOCIFSThreadRequest.runRequest(NIOCIFSThreadRequest.java:104) 
    at org.alfresco.jlan.server.thread.ThreadRequestPool$ThreadWorker.run(ThreadRequestPool.java:141) 
    at java.lang.Thread.run(Thread.java:722) 

這裏有一個方法剪斷:

if (user.hasMD4Password() && alg != LANMAN) { 

      try { 

       // Generate the encrpyted password 

       if (alg == NTLM1) { 

        // Get the MD4 hashed password 

        byte[] p21 = new byte[21]; 
        System.arraycopy(user.getMD4Password(), 0, p21, 0, user.getMD4Password().length); **//THE ERROR OCCURS HERE!** 

        // Generate an NTLMv1 encrypted password 
` 

這裏出現的錯誤:

System.arraycopy(user.getMD4Password(), 0, p21, 0, user.getMD4Password().length); 

但問題是非常簡單的:爲什麼這個錯誤發生?

回答