//SPManagedUnlockDigipass public static void UnlockDigipass(ref String dpData, int randomNumber, out int unlockResponse, out string logMessage) { AAL2Wrap wrapper = new AAL2Wrap(); unlockResponse = 0; logMessage = string.Empty; string _unlockResponse = string.Empty; try { string bRandomNumber = padWithZero(randomNumber, UnlockChallangeLength); _unlockResponse = wrapper.AAL2Unlock(ref dpData, bRandomNumber); int.TryParse(_unlockResponse, out unlockResponse); } catch (Exception exception) { logMessage = exception.Message; } }
/// <summary> /// 将DPX文件中的DIGIPASS信息存入数据库 /// </summary> /// <param name="DPXFileNamePath">DPX文件路径</param> /// <param name="InitKey">DPX文件使用的KEY</param> /// <param name="Msg">返回的操作信息</param> /// <returns>操作是否成功</returns> public bool SaveDataFromDPX(string DPXFileNamePath, string InitKey, ref string Msg) { DatabaseAccess.BeginTransaction(); AAL2Wrap dp = null; try { dp = new AAL2Wrap(); int appCount = 0, digiPassCount = 0; string[] AppliNames = dp.AAL2DPXInit(DPXFileNamePath, InitKey, ref appCount, ref digiPassCount); if (AppliNames == null) { Msg = string.Format("DPX Import Error:{0}", dp.getLastError()); return(false); } AAL2Wrap.TDigipass[] AppliBlobs; AppliBlobs = new AAL2Wrap.TDigipass[appCount]; for (int j = 0; j < (digiPassCount * appCount);) { AppliBlobs = dp.AAL2DPXGetTokenBlobs(ref appCount); for (int l = 0; l < appCount; l++) { SaveDigiPass(AppliBlobs[l].SerialNumber, AppliBlobs[l].Type, AppliBlobs[l].Mode, AppliBlobs[l].bDpData); j++; } } Msg = string.Format("AppCount:{0},DigiPassCount:{1} Saved", appCount, digiPassCount); return(true); } catch (SqlException ex) { Msg = ex.Message; DatabaseAccess.RollbackTransaction(); return(false); } finally { dp.AAL2DPXClose(); DatabaseAccess.CommitTransaction(); } }
//SPManagedGetChallange public static int ManagedGetChallange(ref String dpData, out string challange, out string logMessage) { int result = 0; challange = string.Empty; logMessage = string.Empty; try { AAL2Wrap aal2Wrapper = new AAL2Wrap(); challange = aal2Wrapper.AAL2GenerateChallenge(ref dpData); } catch (Exception exception) { logMessage = exception.Message; } return(result); }
/// <summary> /// 将DPX文件中的DIGIPASS信息存入数据库 /// </summary> /// <param name="DPXFileNamePath">DPX文件路径</param> /// <param name="InitKey">DPX文件使用的KEY</param> /// <param name="Msg">返回的操作信息</param> /// <returns>操作是否成功</returns> public bool SaveDataFromDPX(string DPXFileNamePath, string InitKey, ref string Msg) { DatabaseAccess.BeginTransaction(); AAL2Wrap dp = null; try { dp = new AAL2Wrap(); int appCount = 0, digiPassCount = 0; string[] AppliNames = dp.AAL2DPXInit(DPXFileNamePath, InitKey, ref appCount, ref digiPassCount); if (AppliNames == null) { Msg = string.Format("DPX Import Error:{0}", dp.getLastError()); return false; } AAL2Wrap.TDigipass[] AppliBlobs; AppliBlobs = new AAL2Wrap.TDigipass[appCount]; for (int j = 0; j < (digiPassCount * appCount); ) { AppliBlobs = dp.AAL2DPXGetTokenBlobs(ref appCount); for (int l = 0; l < appCount; l++) { SaveDigiPass(AppliBlobs[l].SerialNumber, AppliBlobs[l].Type, AppliBlobs[l].Mode, AppliBlobs[l].bDpData); j++; } } Msg = string.Format("AppCount:{0},DigiPassCount:{1} Saved", appCount, digiPassCount); return true; } catch (SqlException ex) { Msg = ex.Message; DatabaseAccess.RollbackTransaction(); return false; } finally { dp.AAL2DPXClose(); DatabaseAccess.CommitTransaction(); } }
//SPManagedCheckResponse public static int CheckResponse(ref String dpData, string challange, string response, out bool responseConfirmed, out string logMessage) { int result = 0; responseConfirmed = false; logMessage = string.Empty; try { AAL2Wrap wrapper = new AAL2Wrap(); result = wrapper.AAL2VerifyPassword(ref dpData, challange, response); responseConfirmed = result == 0; } catch (Exception exception) { logMessage = exception.Message; } return(result); }
/// <summary> /// 验证动态密码 RESPONSE ONLY /// </summary> /// <param name="passWord">密码</param> /// <param name="SerialNumber">序列号</param> /// <param name="DigipassType">型号</param> /// <param name="Mode">模式</param> /// <param name="Data">数据</param> /// <param name="Msg">返回的消息</param> /// <returns>验证成功返回HOSTCODE否则返回FALSE</returns> public bool VerifyDigiPass(string passWord, string SerialNumber, string DigipassType, string Mode, byte[] Data, ref string Msg) { AAL2Wrap dp = new AAL2Wrap(); int ret = 0; ret = dp.AAL2VerifyPassword(Data, passWord, null); Msg = dp.getLastError(); //超出限时阀值,重置数据. if (ret == 202 || ret == 203) { dp.AAL2ResetTokenInfo(Data); } //保存数据到数据库 SaveDigiPass(SerialNumber, DigipassType, Mode, Data); if (ret == 0) { return(true); } else { return(false); } }
/// <summary> /// 保存DIGIPASS信息 /// </summary> /// <param name="Digipass">DIGIPASS数据</param> public void SaveDigiPass(AAL2Wrap.TDigipass Digipass) { SaveDigiPass(Digipass.SerialNumber, Digipass.Type, Digipass.Mode, Digipass.bDpData); }
/// <summary> /// 验证动态密码 RESPONSE ONLY /// </summary> /// <param name="passWord">密码</param> /// <param name="SerialNumber">序列号</param> /// <param name="DigipassType">型号</param> /// <param name="Mode">模式</param> /// <param name="Data">数据</param> /// <param name="Msg">返回的消息</param> /// <returns>验证成功返回HOSTCODE否则返回FALSE</returns> public bool VerifyDigiPass(string passWord,string SerialNumber, string DigipassType, string Mode, byte[] Data,ref string Msg) { AAL2Wrap dp = new AAL2Wrap(); int ret = 0; ret = dp.AAL2VerifyPassword(Data, passWord, null); Msg = dp.getLastError(); //超出限时阀值,重置数据. if (ret == 202 || ret == 203) { dp.AAL2ResetTokenInfo(Data); } //保存数据到数据库 SaveDigiPass(SerialNumber, DigipassType, Mode, Data); if (ret == 0) { return true; } else { return false; } }
/// <summary> /// 验证动态密码,RESPONSE ONLY /// </summary> /// <param name="passWord">密码</param> /// <param name="Digipass">DIGIPASS数据</param> /// <param name="Msg">返回的消息</param> /// <returns>验证成功返回HOSTCODE否则返回FALSE</returns> public bool VerifyDigiPass(string passWord,AAL2Wrap.TDigipass Digipass,ref string Msg) { return VerifyDigiPass(passWord, Digipass.SerialNumber, Digipass.Type, Digipass.Mode, Digipass.bDpData, ref Msg); }