Exemplo n.º 1
0
  protected MocamResult launchDeleteAppSdOrNext(
      LocalTransaction localTransaction, int sessionStatus) {
    CardInfo card = cardInfoManager.getByCardNo(localTransaction.getCardNo());
    Application application = applicationManager.getByAid(localTransaction.getAid());
    SecurityDomain sd = application.getSd();
    CardApplication cardApplication =
        cardApplicationManager.getByCardNoAid(
            localTransaction.getCardNo(), localTransaction.getAid());

    MocamResult result;

    Integer currentStatus = cardApplication.getStatus(); // 保存当前卡上应用状态
    cardApplication.setStatus(
        CardApplication.STATUS_UNDOWNLOAD); // 将卡上应用状态设置为“未下载”,防止干扰判断应用所属安全域是否自动删除

    if (transactionHelper.isSdNeedAutoDelete(card, sd)) { // 如果需要删除应用所属安全域,执行删除安全域子流程
      buildSubTransaction(localTransaction, sd.getAid(), null, Operation.DELETE_SD);
      localTransaction.setSessionStatus(sessionStatus);
      result = process(localTransaction);
      cardApplication.setStatus(currentStatus); // 恢复卡上应用状态
    } else { // 否则同步卡空间
      cardApplication.setStatus(currentStatus); // 如果当前运行环境为cms2ac,同步安全域的空间信息
      if (SystemConfigUtils.isCms2acRuntimeEnvironment()) { //
        localTransaction.setSessionStatus(SessionStatus.SYN_CAED_SPACE_START);
        result = processTrans(localTransaction);
      } else { // 如果当前运行环境不是cms2ac,通知业务平台操作结果
        result = launchOperationNotify(localTransaction);
      }
    }

    return result;
  }
Exemplo n.º 2
0
  @Override
  protected void check(LocalTransaction localTransaction) {
    String cardNo = localTransaction.getCardNo();
    String aid = localTransaction.getAid();
    Application app = applicationManager.getByAid(aid);

    CardInfo card = cardInfoManager.getByCardNo(cardNo);
    validateCard(card);

    // 校验应用的状态
    if (app == null) {
      throw new PlatformException(PlatformErrorCode.APPLICATION_AID_NOT_EXIST);
    }

    // 校验卡上应用状态
    CardApplication cardApplication = cardApplicationManager.getByCardNoAid(cardNo, aid);
    if (cardApplication == null) {
      throw new PlatformException(PlatformErrorCode.INVALID_CARD_APP_STATUS);
    }
    if (cardApplication.getApplicationVersion().getApplication().needSubscribe()
        && CardApplication.STATUS_AVAILABLE.intValue()
            == cardApplication.getStatus().intValue()) { // 如果应用需要退订,但卡上应用状态为“可用”,抛出异常
      throw new PlatformException(PlatformErrorCode.TRANS_DELETE_APP_UNSUBSCRIBE);
    }

    // 校验完成,设置卡上应用的版本号
    localTransaction.setAppVersion(cardApplication.getApplicationVersion().getVersionNo());
  }
Exemplo n.º 3
0
  protected MocamResult endSuccessProcess(LocalTransaction localTransaction) {
    CardInfo card = cardInfoManager.getByCardNo(localTransaction.getCardNo());
    ApplicationVersion applicationVersion =
        applicationVersionManager.getByAidAndVersionNo(
            localTransaction.getAid(), localTransaction.getAppVersion());

    if (null != applicationVersion
        && (null == applicationVersion.getApplication().getNeedSubscribe()
            || !applicationVersion
                .getApplication()
                .getNeedSubscribe())) { // 如果应用不需要单独订购/退订,则删除使用即为退订,添加退订记录
      subscribeHistoryManager.unsubscribeApplication(card, applicationVersion);
    }

    // 删除终端上客户端记录
    List<CardClient> cardClients =
        cardClientManager.getByCardAndApplication(card, applicationVersion.getApplication());
    if (null != cardClients) {
      for (CardClient cardClient : cardClients) {
        cardClientManager.remove(cardClient);
      }
    }

    return super.endSuccessProcess(localTransaction);
  }
Exemplo n.º 4
0
  protected MocamResult synCardSpace(LocalTransaction localTransaction) {
    Application application = applicationManager.getByAid(localTransaction.getAid());
    SecurityDomain sd = application.getSd();
    CardSecurityDomain cardSecurityDomain =
        cardSecurityDomainManager.getByCardNoAid(
            localTransaction.getCardNo(), application.getSd().getAid());

    if (CardSecurityDomain.STATUS_PERSO
        == cardSecurityDomain.getStatus().intValue()) { // 如果应用所属安全域没有被自动删除,同步应用所属安全域空间
      return launchSelectSdForSynCardSpace(
          localTransaction, sd, SessionStatus.SYNC_CARD_SELECT_ISD_CMD);
    } else {
      localTransaction.setSessionStatus(SessionStatus.OPERATE_NOTIFY);
      return processTrans(localTransaction);
    }
  }
Exemplo n.º 5
0
 protected MocamResult startDelApp(LocalTransaction localTransaction) {
   MocamResult result = new MocamResult();
   if (isAllLoadFileDelete(localTransaction)) { // 所有文件都删除,进入后续流程
     localTransaction.setSessionStatus(SessionStatus.DELETE_APP_END_DELETE_LOAD_FILE);
     result = processTrans(localTransaction);
   } else {
     CardInfo card = cardInfoManager.getByCardNo(localTransaction.getCardNo());
     LoadFileVersion loadFileVersion =
         transactionHelper.getCurrentLoadFileVersionToDelete(localTransaction);
     if (transactionHelper.isLoadFileVersionExistOnCard(card, loadFileVersion)) { // 当前加载文件在卡上
       return launchDealCurrentLoadFile(localTransaction);
     } else { // 当前加载文件没在卡上,删除下一个文件
       return launchDealNextLoadFile(localTransaction);
     }
   }
   return result;
 }
Exemplo n.º 6
0
  protected MocamResult launchReadPesoDataOrStartDeleteApp(LocalTransaction localTransaction) {
    localTransaction.setSessionStatus(SessionStatus.DELETE_APP_READ_PERSO_DATA);

    CardApplication cardApplication =
        cardApplicationManager.getByCardNoAid(
            localTransaction.getCardNo(), localTransaction.getAid());
    if (CardApplication.STATUS_PERSO_DATA_READABLE.contains(cardApplication.getStatus())
        && localTransaction.hasPersonalizationsToExecute()) { // 如果有个人化数据且业务平台需要读取,读取数据
      LocalTransaction subTransaction =
          buildSubTransaction(
              localTransaction, localTransaction.getAid(), Operation.DELETE_APP_READ_PERSO_DATA);

      transactionHelper.buildSubPersonalizedAppTransaction(localTransaction, subTransaction);

      subTransaction.setSessionStatus(SessionStatus.PRE_OPERATION_SUCCESS);
    }

    return process(localTransaction);
  }
Exemplo n.º 7
0
 private List<Map<String, Object>> localTransactionResult(List<LocalTransaction> requistionList) {
   List<Map<String, Object>> mappedApplications =
       new ArrayList<Map<String, Object>>(requistionList.size());
   List<PropertyFilter> propertyFilters = new ArrayList<PropertyFilter>();
   List<Application> apps = new ArrayList<Application>();
   List<SecurityDomain> sds = new ArrayList<SecurityDomain>();
   for (LocalTransaction localTransaction : requistionList) {
     propertyFilters.clear();
     apps.clear();
     sds.clear();
     Map<String, Object> mappedLocalTransaction = localTransaction.toMap(null, null);
     String formatValue = "";
     if (localTransaction.getBeginTime() != null) {
       formatValue =
           DateFormatUtils.format(
               (Calendar) localTransaction.getBeginTime(), "yyyy-MM-dd HH:mm:ss");
     }
     mappedLocalTransaction.put("beginTime", formatValue);
     formatValue = "";
     if (localTransaction.getEndTime() != null) {
       formatValue =
           DateFormatUtils.format((Calendar) localTransaction.getEndTime(), "yyyy-MM-dd HH:mm:ss");
     }
     mappedLocalTransaction.put("endTime", formatValue);
     mappedLocalTransaction.put(
         "failMessage",
         localTransaction.getFailMessage() == null ? "" : localTransaction.getFailMessage());
     // propertyFilters.add(new PropertyFilter("aid", MatchType.EQ,
     // PropertyType.S, localTransaction.getAid()));
     if (localTransaction.getProcedureName().equals(Operation.CREATE_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.DELETE_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.LOCK_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.UNLOCK_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.SYNC_CARD_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.UPDATE_KEY.toString())) {
       propertyFilters.add(
           new PropertyFilter("aid", MatchType.EQ, PropertyType.S, localTransaction.getAid()));
       sds = securityDomainManager.find(propertyFilters);
       if (sds != null && sds.size() != 0) {
         mappedLocalTransaction.put("appName", sds.get(0).getSdName());
         mappedLocalTransaction.put("showType", "sd");
       }
     } else if (localTransaction.getProcedureName().equals("LOCK_CARD")
         || localTransaction.getProcedureName().equals("UNLOCK_CARD")) {
       propertyFilters.add(
           new PropertyFilter(
               "mobileNo", MatchType.EQ, PropertyType.S, localTransaction.getMobileNo()));
       List<CustomerCardInfo> ccis = this.customerCardInfoManager.find(propertyFilters);
       CustomerCardInfo cci = null;
       for (CustomerCardInfo _cci : ccis) {
         if (_cci.getCard()
             .getCardNo()
             .equals(localTransaction.getCardNo())) { // 根据卡号和手机号查找CustomerCardInfo,并且列出最新的终端名
           if (cci == null || cci.getId() < _cci.getId()) {
             cci = _cci;
           }
         }
       }
       if (null != cci) {
         mappedLocalTransaction.put("appName", cci.getName());
         mappedLocalTransaction.put("cciIconId", cci.getMobileType().getId());
         mappedLocalTransaction.put("showType", "termial");
       }
     } else {
       propertyFilters.add(
           new PropertyFilter("aid", MatchType.EQ, PropertyType.S, localTransaction.getAid()));
       apps = applicationManager.find(propertyFilters);
       if (apps != null && apps.size() != 0) {
         mappedLocalTransaction.put("appName", apps.get(0).getName());
         mappedLocalTransaction.put("application_id", apps.get(0).getId());
         mappedLocalTransaction.put("showType", "app");
       }
     }
     if (PlatformMessage.SUCCESS.getCode().equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.SUCCESS.getMessage());
     } else if (PlatformMessage.TRANS_EXCESSIVING.getCode().equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.TRANS_EXCESSIVING.getMessage());
     } else if (PlatformMessage.TRANS_EXCEPTION_CLOSED
         .getCode()
         .equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.TRANS_EXCEPTION_CLOSED.getMessage());
     } else {
       //				for (PlatformErrorCode pe : PlatformErrorCode.values()) {
       //					if (pe.getErrorCode().equals(localTransaction.getResult())) {
       //						mappedLocalTransaction.put("result", pe.getDefaultMessage());
       //					}
       //				}
       mappedLocalTransaction.put("result", localTransaction.getFailMessage());
     }
     mappedApplications.add(mappedLocalTransaction);
   }
   return mappedApplications;
 }