Closed Bug 10314 Opened 21 years ago Closed 20 years ago

Error in JDAPMessage. processResponse

Categories

(Directory :: LDAP Java SDK, defect, P3, critical)

Other
AIX
defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: Toshirou.Morisaki, Assigned: miodrag)

Details

I am using Netscape Directory SDK 3.1 for Java .
The error occurs when running a first connect.

The following message is displaied when the error occured
It must be correspond restart  process for recovery  when This message occurs

 java.lang.IncompatibleClassChangeError: Unimplemented interface method
         at netscape.ldap.client.JDAPMessage.<init>(JDAPMessage.java)
         at netscape.ldap.LDAPConnThread.run(LDAPConnection.java)


This environment is JDK 1.1.6.
I don't know that caused and correspond  for the error.

The following is java source code.

/**  サーバーの業務処理クラス
*       SYSTEM            : 拡売費処理システム
*       業務処理ファイル名: AuthSrvProc.java
*       説明              : 入力者認証
*       作成日            : 1999.03.27
*       作成者            : JDI
*/
// AWK is partly used to generate this program

package nsipac.srv;

import java.util.*;
import java.text.*;
import java.sql.*;
import jp.co.jdi.*;
import COM.odi.*;
import COM.odi.coll.*;
import nsipac.ipc.*;
import nsipac.sql.*;
import netscape.ldap.*;

public class AuthSrvProc implements ConstantValues{

// クラス名
    private static final String CLASS_NAME = "AuthSrvProc";

// JDBCセッションハンドル
    private Connection cn;
    private boolean connectionFlag;

// RDBアクセスクラス用変数

// インスタンス変数
    LDAPConnection ld   = null;
    LDAPAttribute  attr = null;
    String         attrName = "userpassword";
    LDAPEntry findEntry = null;
    LDAPModificationSet mods = null;

    // コンストラクタ
    public AuthSrvProc() throws JDIAbend{
      // ユーザ名,パスワード,接続文字列の指定
      String UserName = EnvironmentInfo.getUserName();
      String Password = EnvironmentInfo.getPassword();
      String ConnStr  = EnvironmentInfo.getConnectionString();

      try{
        // JDBCドライバの登録
        Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");

        // データベースへの接続 (セッションの開始)
        System.out.println( "データベースに接続しています...\n");
        cn = DriverManager.getConnection("jdbc:db2:" + ConnStr,
                                          UserName,
                                          Password);
        cn.setAutoCommit(false);
        // 99/01/09 更新処理を待たせないために、dirty read 可能にした。(後藤)
        cn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);

        System.out.println( UserName + "として接続しました。\n");
        connectionFlag = true;
      }catch(SQLException e){
        connectionFlag = false;
        e.printStackTrace();
        String s = "接続エラーが発生しました。\n"
                 + "クラス名:" + CLASS_NAME
                 + "  メソッド名:AuthSrvProc\n"
                 + "SQLException:" + e.getMessage()
                 + " ErrorCode = " + e.getErrorCode();
        throw new JDIAbend(s);
      }catch(Exception e){
        connectionFlag = false;
        e.printStackTrace();
        String s = "接続エラーが発生しました。\n"
                 + "クラス名:" + CLASS_NAME
                 + "  メソッド名:AuthSrvProc\n"
                 + "Exception:" + e.getMessage();
        throw new JDIAbend(s);
      }
    }
    public boolean isAlive(){
      return connectionFlag;
    }
    public void commit() throws JDIAbend{
      try{
        cn.commit();
      }catch(SQLException e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
                 + "クラス名:" + CLASS_NAME
                 + "  メソッド名:commit\n"
                 + "SQLException:" + e.getMessage()
                 + " ErrorCode = " + e.getErrorCode();
        throw new JDIAbend(s);
      }catch(Exception e){
        connectionFlag = false;
        e.printStackTrace();
        String s = "接続エラーが発生しました。\n"
                 + "クラス名:" + CLASS_NAME
                 + "  メソッド名:commit\n"
                 + "Exception:" + e.getMessage();
        throw new JDIAbend(s);
      }
    }
    public void rollback() throws JDIAbend{
      try{
        cn.rollback();
      }catch(SQLException e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
                 + "クラス名:" + CLASS_NAME
                 + "  メソッド名:rollback\n"
                 + "SQLException:" + e.getMessage()
                 + " ErrorCode = " + e.getErrorCode();
        throw new JDIAbend(s);
      }catch(Exception e){
        connectionFlag = false;
        e.printStackTrace();
        String s = "接続エラーが発生しました。\n"
                 + "クラス名:" + CLASS_NAME
                 + "  メソッド名:rollback\n"
                 + "Exception:" + e.getMessage();
        throw new JDIAbend(s);
      }
    }

    public AuthReply authenticate(AuthRequest request)
    throws JDIAbend{
      try{
        AuthReply reply = new AuthReply();
        reply.setResult(true);
        if(!EnvironmentInfo.isLDAPEnabled()){
          if(request.getPassword().equals(
             EnvironmentInfo.getEmergencyPassword())){
            reply.setReplyCode("OK");
          }else{
            reply.setReplyCode("NG");
            reply.setMessage("S006");
          }
          return reply;
        }
        try {
          ld = new LDAPConnection();
          // サーバー接続
          ld.connect(EnvironmentInfo.getLDAPHost()
                    ,EnvironmentInfo.getLDAPPort());
        }catch(LDAPException e){
          e.printStackTrace();
          String s = getLDAPMessage(e) + "\n"
              + "クラス名:" + CLASS_NAME
              + "  メソッド名:authenticate 接続\n"
              + "LDAPException:" + e.getMessage();
          throw new JDIAbend(s);
        }
        String userId = request.getUserId();
        String orgUnit = null;
        String org = null;
        if(JDIUtil.isNumber(userId)){
          userId = EnvironmentInfo.getLDAPUserIdPrefix()
                 + userId;
        }
        userId = userId.toUpperCase();
        if(userId.startsWith(
               EnvironmentInfo.getLDAPUserIdPrefix())){
          orgUnit = EnvironmentInfo.getLDAPInOu();
          org = EnvironmentInfo.getLDAPInO();
        }else{
          orgUnit = EnvironmentInfo.getLDAPOutOu();
          org = EnvironmentInfo.getLDAPOutO();
        }
        try {
          // ユーザー認証
          String userDN;
          String checkDate = JDIUtil.getToday();
          try{
            LDAPSearchResults res = ld.search(
              "o=" + org
              , LDAPConnection.SCOPE_SUB
              , "(&(uid=" + userId + ")(uidexp>="
                   + checkDate.substring(0, 8) + "))"
              , null
              , false);
            if(res.hasMoreElements()){
              userDN = res.next().getDN();
            }else{
              reply.setReplyCode("IDNG");
              reply.setMessage("S005");
              disconnectLDAP();
              return reply;
            }
          }catch(LDAPException e){
            e.printStackTrace();
            String s = getLDAPMessage(e) + "\n"
              + "クラス名:" + CLASS_NAME
              + "  メソッド名:authenticate\n"
              + "LDAPException:" + e.getMessage();
            disconnectLDAP();
            throw new JDIAbend(s);
          }
          ld.authenticate(userDN
                         ,request.getPassword());
          reply.setReplyCode("OK");
        }catch(LDAPException e){
          switch(e.getLDAPResultCode()){
            case LDAPException.NO_SUCH_OBJECT:
              reply.setReplyCode("IDNG");
              reply.setMessage("S005");
              break;
            case LDAPException.INVALID_CREDENTIALS:
              if(e.getLDAPErrorMessage() != null &&
                 e.getLDAPErrorMessage().equals(
                                  "password expired!")){
                reply.setReplyCode("UPD");
                reply.setMessage("S007");
              }else{
                reply.setReplyCode("NG");
                reply.setMessage("S006");
              }
              break;
            case LDAPException.INAPPROPRIATE_AUTHENTICATION:
              if(userId.equals(
                  request.getPassword())){
                reply.setReplyCode("UPD");
                reply.setMessage("S015");
              }else{
                reply.setReplyCode("NG");
                reply.setMessage("S006");
              }
              break;
            case LDAPException.CONSTRAINT_VIOLATION:
               if(e.getLDAPErrorMessage() != null &&
                  e.getLDAPErrorMessage().equals(
                       "Exceed password retry limit. "
                     + "Contact system administrator "
                     + "to reset.")){
                reply.setReplyCode("NG");
                reply.setMessage("S008");
                break;
              }else{
                e.printStackTrace();
                String s = getLDAPMessage(e) + "\n"
                  + "クラス名:" + CLASS_NAME
                  + "  メソッド名:authenticate\n"
                  + "LDAPException:" + e.getMessage();
                disconnectLDAP();
                throw new JDIAbend(s);
              }
            default:
              e.printStackTrace();
              String s = getLDAPMessage(e) + "\n"
                + "クラス名:" + CLASS_NAME
                + "  メソッド名:authenticate\n"
                + "LDAPException:" + e.getMessage();
              disconnectLDAP();
              throw new JDIAbend(s);
          }
        }
        disconnectLDAP();
        return reply;
      }catch (NullPointerException e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "authenticate(AuthRequest request)\n"
        + "NullPointerException:" + e.getMessage();
        throw new JDIAbend(s);
      }catch (Exception e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "authenticate(AuthRequest request)\n"
        + "Exception:" + e.getMessage();
        throw new JDIAbend(s);
      }
    }


    public AuthReply changePassword(AuthRequest request)
    throws JDIAbend{
      try{
        AuthReply reply = new AuthReply();
        reply.setResult(true);
        if(!EnvironmentInfo.isLDAPEnabled()){
          throw new JDIAbend(
              "LDAPサーバー使用不可のため、"
             + "パスワード変更はできません。");
        }
        String pw = request.getNewPassword();
        if(pw.length() < 4){
          reply.setReplyCode("NG");
          reply.setMessage("S012");
          return reply;
        }
        if(pw.length() > 10){
          reply.setReplyCode("NG");
          reply.setMessage("S014");
          return reply;
        }
        for(int i = 0; i < pw.length(); i++){
          if('A' <= pw.charAt(i) && pw.charAt(i) <= 'Z'){
            continue;
          }
          if('a' <= pw.charAt(i) && pw.charAt(i) <= 'z'){
            continue;
          }
          if('0' <= pw.charAt(i) && pw.charAt(i) <= '9'){
            continue;
          }
          reply.setReplyCode("NG");
          reply.setMessage("S013");
          return reply;
        }
        try {
          ld = new LDAPConnection();
          // サーバー接続
          ld.connect(EnvironmentInfo.getLDAPPrimaryHost()
                    ,EnvironmentInfo.getLDAPPort());
        }catch(LDAPException e){
          e.printStackTrace();
          String s = getLDAPMessage(e) + "\n"
              + "クラス名:" + CLASS_NAME
              + "  メソッド名:changePassword 接続\n"
              + "LDAPException:" + e.getMessage();
          throw new JDIAbend(s);
        }
        try {
          // セキュリティ認証
          ld.authenticate(EnvironmentInfo.getLDAPMgrDn()
                         ,EnvironmentInfo.getLDAPMgrPw());
        }catch(LDAPException e){
          e.printStackTrace();
          String s = getLDAPMessage(e) + "\n"
             + "クラス名:" + CLASS_NAME
             + "  メソッド名:changePassword 権限の設定\n"
             + "LDAPException:" + e.getMessage();
          disconnectLDAP();
          throw new JDIAbend(s);
        }
        String userId = request.getUserId();
        String orgUnit = null;
        String org = null;
        if(JDIUtil.isNumber(userId)){
          userId = EnvironmentInfo.getLDAPUserIdPrefix()
                 + userId;
        }
        if(userId.startsWith(
               EnvironmentInfo.getLDAPUserIdPrefix())){
          orgUnit = EnvironmentInfo.getLDAPInOu();
          org = EnvironmentInfo.getLDAPInO();
        }else{
          orgUnit = EnvironmentInfo.getLDAPOutOu();
          org = EnvironmentInfo.getLDAPOutO();
        }
        try {
          String userDN;
          String checkDate = JDIUtil.getToday();
          try{
            LDAPSearchResults res = ld.search(
              "o=" + org
              , LDAPConnection.SCOPE_SUB
              , "(&(uid=" + userId + ")(uidexp>="
                   + checkDate.substring(0, 8) + "))"
              , null
              , false);
            if(res.hasMoreElements()){
              userDN = res.next().getDN();
            }else{
              reply.setReplyCode("NG");
              reply.setMessage("S005");
              disconnectLDAP();
              return reply;
            }
          }catch(LDAPException e){
            e.printStackTrace();
            String s = getLDAPMessage(e) + "\n"
              + "クラス名:" + CLASS_NAME
              + "  メソッド名:changePassword\n"
              + "LDAPException:" + e.getMessage();
            disconnectLDAP();
            throw new JDIAbend(s);
          }
          mods = new LDAPModificationSet();
          attr = new LDAPAttribute(attrName
                    ,request.getNewPassword());
          mods.add(LDAPModification.REPLACE, attr);
          ld.modify(userDN, mods);
          reply.setReplyCode("OK");
        }catch(LDAPException e){
          String s = null;
          switch(e.getLDAPResultCode()){
            case LDAPException.CONSTRAINT_VIOLATION:
              if(e.getLDAPErrorMessage() == null){
                e.printStackTrace();
                s = getLDAPMessage(e) + "\n"
                  + "クラス名:" + CLASS_NAME
                  + "  メソッド名:changePassword\n"
                  + "LDAPException:"
                  + e.getMessage();
                disconnectLDAP();
                throw new JDIAbend(s);
              }
              if(e.getLDAPErrorMessage().equals(
                      "invalid password syntax")){
                reply.setReplyCode("NG");
                reply.setMessage("S009");
                break;
              }else{
                if(e.getLDAPErrorMessage().equals(
                        "trivial password")){
                  reply.setReplyCode("NG");
                  reply.setMessage("S010");
                  break;
                }else{
                  if(e.getLDAPErrorMessage().equals(
                          "password in history")){
                    reply.setReplyCode("NG");
                    reply.setMessage("S011");
                    break;
                  }else{
                    e.printStackTrace();
                    s = getLDAPMessage(e) + "\n"
                      + "クラス名:" + CLASS_NAME
                      + "  メソッド名:changePassword\n"
                      + "LDAPException:"
                      + e.getMessage();
                    disconnectLDAP();
                    throw new JDIAbend(s);
                  }
                }
              }
            default:
              e.printStackTrace();
              s = getLDAPMessage(e) + "\n"
                + "クラス名:" + CLASS_NAME
                + "  メソッド名:changePassword\n"
                + "LDAPException:" + e.getMessage();
              disconnectLDAP();
              throw new JDIAbend(s);
          }
        }
        disconnectLDAP();
        return reply;
      }catch (NullPointerException e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "changePassword(AuthRequest request)\n"
        + "NullPointerException:" + e.getMessage();
        throw new JDIAbend(s);
      }catch (Exception e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "changePassword(AuthRequest request)\n"
        + "Exception:" + e.getMessage();
        throw new JDIAbend(s);
      }
    }


   private void
   disconnectLDAP()
    throws JDIAbend{
      try{
        if(ld != null && ld.isConnected()) {
          try{
            ld.disconnect();
            ld = null;
          }catch(LDAPException e){
            e.printStackTrace();
            String s = getLDAPMessage(e) + "\n"
              + "クラス名:" + CLASS_NAME
              + "  メソッド名:disconnectLDAP\n"
              + "LDAPException:" + e.getMessage();
            throw new JDIAbend(s);
          }
        }
      }catch (NullPointerException e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "disconnectLDAP()"
        + "\n"
        + "NullPointerException:" + e.getMessage();
        throw new JDIAbend(s);
      }catch (Exception e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "disconnectLDAP()"
        + "\n"
        + "Exception:" + e.getMessage();
        throw new JDIAbend(s);
      }
    }

   private String
   getLDAPMessage(LDAPException ex)
    throws JDIAbend{
      try{
        String str
          = "LDAPCode = " + ex.getLDAPResultCode() + " ";
        switch(ex.getLDAPResultCode()){
          case LDAPException.BUSY:
           str = str + "LDAPサーバーがビジーです。";
           break;
          case LDAPException.CONNECT_ERROR:
           str = str + "LDAPサーバーへの接続エラー";
           break;
          case LDAPException.SERVER_DOWN:
           str = str + "LDAPサーバーがダウンしています。";
           break;
          case LDAPException.TIME_LIMIT_EXCEEDED:
           str = str + "LDAPサーバーのタイムオーバー。";
           break;
          case LDAPException.UNAVAILABLE:
           str = str + "LDAPサーバーが稼動していません。";
           break;
          default:
           str = str + "LDAPのその他のエラーです。";
        }
        return str;
      }catch (NullPointerException e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "getLDAPMessage(LDAPException ex)"
        + "\n"
        + "NullPointerException:" + e.getMessage();
        throw new JDIAbend(s);
      }catch (Exception e){
        e.printStackTrace();
        String s = MessageText.getMessage("S001") + "\n"
        + "クラス名:" + CLASS_NAME
        + "  メソッド名:"
        + "getLDAPMessage(LDAPException ex)"
        + "\n"
        + "Exception:" + e.getMessage();
        throw new JDIAbend(s);
      }
    }

}

Best Regards.
Assignee: chuckb → miodrag
Status: NEW → ASSIGNED
This type of error usually happens when there is a mix of old and new (modified)
code, and all of the code was not recompiled after the modification. The
compiler always captures such errors.

Morisaki-san, were you making yourself any changes to the LDAPJDK when this
error occurred? If that's the case, I would suggest that you remove all class
files and recompile. Also, did you have a chance to try the code on any other
platform, except AIX? Is the problem still there?
I am not changed to ldapdk. This error is whenever or not  occured now.
It is no problem when first connect is successful.
If first connect is successful, this error is not occured until Process is shutdown.
If only first connect is unsuccessful then error occured.
Is there a possible of your idea that recompile all code  ?
Also,  Does it needs recompile ldapjdk ?
Closing the bug as it can not be reproduced.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.