Program: 48089
Project: 48089
Buggy source:
@Override public DIDAuthenticateResponse perform(DIDAuthenticate didAuthenticate,Map<String,Object> internalData){
  DIDAuthenticateResponse response=new DIDAuthenticateResponse();
  DynamicContext dynCtx=DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
  try {
    ObjectSchemaValidator valid=(ObjectSchemaValidator)dynCtx.getPromise(EACProtocol.SCHEMA_VALIDATOR).deref();
    boolean messageValid=valid.validateObject(didAuthenticate);
    if (!messageValid) {
      String msg="String_Node_Str";
      logger.error(msg);
      dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
      response.setResult(WSHelper.makeResultError(ECardConstants.Minor.App.INCORRECT_PARM,msg));
      return response;
    }
  }
 catch (  ObjectValidatorException ex) {
    String msg="String_Node_Str";
    logger.error(msg,ex);
    dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
    response.setResult(WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR,msg));
    return response;
  }
catch (  InterruptedException ex) {
    String msg="String_Node_Str";
    logger.error(msg,ex);
    dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
    response.setResult(WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR,msg));
    return response;
  }
  byte[] slotHandle=didAuthenticate.getConnectionHandle().getSlotHandle();
  try {
    EAC2InputType eac2Input=new EAC2InputType(didAuthenticate.getAuthenticationProtocolData());
    EAC2OutputType eac2Output=eac2Input.getOutputType();
    TerminalAuthentication ta=new TerminalAuthentication(dispatcher,slotHandle);
    CardVerifiableCertificateChain certificateChain;
    certificateChain=(CardVerifiableCertificateChain)internalData.get(EACConstants.IDATA_CERTIFICATES);
    certificateChain.addCertificates(eac2Input.getCertificates());
    byte[] currentCAR=(byte[])internalData.get(EACConstants.IDATA_CURRENT_CAR);
    certificateChain=certificateChain.getCertificateChainFromCAR(currentCAR);
    ta.verifyCertificates(certificateChain);
    CardVerifiableCertificate terminalCertificate=certificateChain.getTerminalCertificate();
    byte[] key=eac2Input.getEphemeralPublicKey();
    byte[] signature=eac2Input.getSignature();
    internalData.put(EACConstants.IDATA_PK_PCD,key);
    internalData.put(EACConstants.IDATA_SIGNATURE,signature);
    internalData.put(EACConstants.IDATA_TERMINAL_CERTIFICATE,terminalCertificate);
    if (signature != null) {
      logger.trace("String_Node_Str");
      ChipAuthentication ca=new ChipAuthentication(dispatcher,slotHandle);
      AuthenticationHelper auth=new AuthenticationHelper(ta,ca);
      eac2Output=auth.performAuth(eac2Output,internalData);
      DynamicContext ctx=DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
      ctx.put(EACProtocol.AUTHENTICATION_DONE,true);
    }
 else {
      logger.trace("String_Node_Str");
      byte[] rPICC=(byte[])internalData.get(EACConstants.IDATA_CHALLENGE);
      eac2Output.setChallenge(rPICC);
    }
    response.setResult(WSHelper.makeResultOK());
    response.setAuthenticationProtocolData(eac2Output.getAuthDataType());
  }
 catch (  Exception e) {
    logger.error(e.getMessage(),e);
    response.setResult(WSHelper.makeResultUnknownError(e.getMessage()));
    dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
  }
  return response;
}

Fixed version (ground truth):
@Override public DIDAuthenticateResponse perform(DIDAuthenticate didAuthenticate,Map<String,Object> internalData){
  DIDAuthenticateResponse response=new DIDAuthenticateResponse();
  DynamicContext dynCtx=DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
  try {
    ObjectSchemaValidator valid=(ObjectSchemaValidator)dynCtx.getPromise(EACProtocol.SCHEMA_VALIDATOR).deref();
    boolean messageValid=valid.validateObject(didAuthenticate);
    if (!messageValid) {
      String msg="String_Node_Str";
      logger.error(msg);
      dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
      response.setResult(WSHelper.makeResultError(ECardConstants.Minor.App.INCORRECT_PARM,msg));
      return response;
    }
  }
 catch (  ObjectValidatorException ex) {
    String msg="String_Node_Str";
    logger.error(msg,ex);
    dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
    response.setResult(WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR,msg));
    return response;
  }
catch (  InterruptedException ex) {
    String msg="String_Node_Str";
    logger.error(msg,ex);
    dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
    response.setResult(WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR,msg));
    return response;
  }
  byte[] slotHandle=didAuthenticate.getConnectionHandle().getSlotHandle();
  try {
    EAC2InputType eac2Input=new EAC2InputType(didAuthenticate.getAuthenticationProtocolData());
    EAC2OutputType eac2Output=eac2Input.getOutputType();
    TerminalAuthentication ta=new TerminalAuthentication(dispatcher,slotHandle);
    CardVerifiableCertificateChain certificateChain;
    certificateChain=(CardVerifiableCertificateChain)internalData.get(EACConstants.IDATA_CERTIFICATES);
    certificateChain.addCertificates(eac2Input.getCertificates());
    byte[] currentCAR=(byte[])internalData.get(EACConstants.IDATA_CURRENT_CAR);
    certificateChain=certificateChain.getCertificateChainFromCAR(currentCAR);
    if (certificateChain.getCertificates().isEmpty()) {
      String msg="String_Node_Str";
      logger.error(msg);
      response.setResult(WSHelper.makeResultError(ECardConstants.Minor.App.PARM_ERROR,msg));
      return response;
    }
    ta.verifyCertificates(certificateChain);
    CardVerifiableCertificate terminalCertificate=certificateChain.getTerminalCertificate();
    byte[] key=eac2Input.getEphemeralPublicKey();
    byte[] signature=eac2Input.getSignature();
    internalData.put(EACConstants.IDATA_PK_PCD,key);
    internalData.put(EACConstants.IDATA_SIGNATURE,signature);
    internalData.put(EACConstants.IDATA_TERMINAL_CERTIFICATE,terminalCertificate);
    if (signature != null) {
      logger.trace("String_Node_Str");
      ChipAuthentication ca=new ChipAuthentication(dispatcher,slotHandle);
      AuthenticationHelper auth=new AuthenticationHelper(ta,ca);
      eac2Output=auth.performAuth(eac2Output,internalData);
      DynamicContext ctx=DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
      ctx.put(EACProtocol.AUTHENTICATION_DONE,true);
    }
 else {
      logger.trace("String_Node_Str");
      byte[] rPICC=(byte[])internalData.get(EACConstants.IDATA_CHALLENGE);
      eac2Output.setChallenge(rPICC);
    }
    response.setResult(WSHelper.makeResultOK());
    response.setAuthenticationProtocolData(eac2Output.getAuthDataType());
  }
 catch (  Exception e) {
    logger.error(e.getMessage(),e);
    response.setResult(WSHelper.makeResultUnknownError(e.getMessage()));
    dynCtx.put(EACProtocol.AUTHENTICATION_FAILED,true);
  }
  return response;
}