Пример #1
0
//---------------------------------------------------------------------------
void FrmCriptoTxt::BtCriptoTxtClick(WindowBase *wB)
{
	char *txt = NULL;
	txt = TxtNormal->getText();
	if (txt != NULL) {
		txt = EncryptText(txt);
		TxtCriptoN->setText(txt);
	}
	txt = TxtMascara->getText();
	if (txt != NULL) {
		txt = EncryptText(txt);
		TxtCriptoM->setText(txt);
	}
}
Пример #2
0
bool CWord2007DocumentImpl::IsRestrictionPasswordValid(const CStdString& password)
{  
	LOG_WS_FUNCTION_SCOPE();
   IDispatchPtr spDocument = InstanceManager->OpenDocument(m_sWorkingFileName.c_str(), VARIANT_FALSE);
   try
   {
		WordDOMDocumentTagger tagger(spDocument);
		if(!tagger.IsInternalOnly() && !tagger.IsFullyRestricted())
         throw Workshare::Com::ComException(_T("This document is not restricted, checking for restriction password is not valid."), E_FAIL);

		CStdString sExistingPassword = tagger.GetPassword();

      CStdString sEncryptedPassword;
      if(!password.IsEmpty())
         sEncryptedPassword = EncryptText(password);  

      InstanceManager->CloseDocument(spDocument, true);

      return (sEncryptedPassword.Equals(sExistingPassword));
   }
   catch(const Workshare::Exception&)
   {
      InstanceManager->CloseDocument(spDocument, true);
      throw;
   }
   catch(...)
   {
      InstanceManager->CloseDocument(spDocument, true);
      unexpected();
   }
}
Пример #3
0
//---------------------------------------------------------------------------
void __fastcall TCFin1003A::BtOKClick(TObject *Sender)
{
   TZQuery *QyConsulta;
   String SenhaCripto;

   if (pEdtPdw->Text.Length() == 0) {
      MessageBox(NULL,"Informe a senha do cliente para confirmar a operação.","Senha",APP_ATENTION);
      return;
   }
   SenhaCripto = EncryptText(pEdtPdw->Text.c_str());
try {
   QyConsulta = new TZQuery(Application);
   QyConsulta->Connection = AppConnection;
   QyConsulta->SQL->Add("SELECT senha_cliente FROM tbl_cliente_ctm");
   QyConsulta->SQL->Add("WHERE cod_cliente = '" + cod_cliente + "';");
   QyConsulta->Open();
   if (QyConsulta->RecordCount <= 0) {
      MessageBox(NULL,"O cliente não possui senha cadastrada.","Senha",APP_ATENTION);
      return;
   }
   if (QyConsulta->FieldByName("senha_cliente")->AsString == SenhaCripto) {
      this->ModalResult = mrOk;
   } else {
      MessageBox(NULL,"A senha do cliente não confere!","Senha",APP_ATENTION);
      pEdtPdw->SetFocus();
   }
}
__finally { delete(QyConsulta); }
}
Пример #4
0
void CWord2007DocumentImpl::SetRestrictionLevel(const mwDocumentRestrictionLevel eRestrictionLevel, const CStdString* sPassword /*= NULL*/)
{
	LOG_WS_FUNCTION_SCOPE();
   if (eRestrictionLevel < NO_RESTRICTION)
      throw Workshare::ArgumentException(_T("eRestrictionLevel"), _T("The restriction level, which is less than NO_RESTRICTION, is invalid. The value must be NO_RESTRICTION(0), EXTERNAL_RESTRICTION(1) or FULL_RESTRICTION(2)."));

   if (eRestrictionLevel > FULL_RESTRICTION)
      throw Workshare::ArgumentException(_T("eRestrictionLevel"), _T("The restriction level, which is greater than FULL_RESTRICTION, is invalid. The value must be NO_RESTRICTION(0), EXTERNAL_RESTRICTION(1) or FULL_RESTRICTION(2)."));

   CStdString sEncryptedPassword;
   if(sPassword)
      if(!sPassword->IsEmpty())
         sEncryptedPassword = EncryptText(*sPassword);

   IDispatchPtr pDoc = InstanceManager->OpenDocument(m_sWorkingFileName.c_str(), VARIANT_FALSE);

   try
   {
		WordDOMDocumentTagger tagger(pDoc);

		CStdString sExistingPassword = tagger.GetPassword();

      if(!sExistingPassword.IsEmpty() && !sEncryptedPassword.Equals(sExistingPassword) && !sEncryptedPassword.empty())
      {
         SetLastError(ERROR_INVALID_DATA);
         throw Workshare::System::SystemException(_T("Invalid password"));
      }

	  tagger.ClearRestrictions();

      if (EXTERNAL_RESTRICTION == eRestrictionLevel)
      {
		  tagger.SetInternalOnly(true);
		  tagger.SetPassword(sEncryptedPassword);
      }
      else if(FULL_RESTRICTION == eRestrictionLevel)
      {
         tagger.SetFullRestriction(true);
         tagger.SetPassword(sEncryptedPassword);
      }
	  else
	  {
         tagger.SetPassword(sEncryptedPassword);
	  }

      InstanceManager->CloseDocument(pDoc, true);
   }
   catch(const Workshare::Exception&)
   {
      InstanceManager->CloseDocument(pDoc, true);
      throw;
   }
   catch(...)
   {
      InstanceManager->CloseDocument(pDoc, true);
      unexpected();
   }
}
Пример #5
0
//---------------------------------------------------------------------------
bool __fastcall TFrmLogin::CadastraUserAdm()
{
   bool bRet = false;
	TZQuery *QyCadAdm = new TZQuery(Application);
try {
   char *cSenha = EncryptText("administrador");
   String sSenha = cSenha;
   delete[] cSenha;
   QyCadAdm->Connection = AppConnection;
   QyCadAdm->SQL->Add("INSERT INTO tbl_usuario (usuario,nome,senha,ies_administrador)");
   QyCadAdm->SQL->Add(" VALUES ('administrador','Administrador','"+ sSenha +"','S')");
   QyCadAdm->ExecSQL();
   bRet = true;
} catch(Exception &e) {
   String Msg = "Ocorreu o seguinte erro ao tentar cadastro o administrador para primeiro acesso:\n" + e.Message;
   MessageBox(NULL,Msg.c_str(),"Mensagem de Erro",MB_OK | MB_ICONSTOP);
}
   delete QyCadAdm;
   return bRet;
}
Пример #6
0
//---------------------------------------------------------------------------
bool __fastcall TFrmLogin::SenhaValida()
{
  TZQuery *QyConsulta;
  String SenhaCripto = EncryptText(Senha->Text.c_str());
try{
  QyConsulta = new TZQuery(Application);
  QyConsulta->Connection = AppConnection;
  QyConsulta->SQL->Add("SELECT senha FROM tbl_usuario");
  QyConsulta->SQL->Add("WHERE usuario = '" + Login->Text + "';");
  QyConsulta->Open();
  if(QyConsulta->FieldByName("senha")->AsString == SenhaCripto){
	 AppUser->Usuario = Login->Text;
	 return true;
  }
  else{
     MessageBox(Handle,"A senha do usuário não confere!",
                Caption.c_str(),APP_ATENTION);
     Senha->SetFocus();
    return false;
  }
}
 __finally{delete(QyConsulta);}
  return false;
}
Пример #7
0
void TestCryptWrap::TestEncryptText()
{
   assertMessage(0 == (EncryptText(_T("Password"))).compare(_T("f15abd57801840f3348ddccafb677f6a")), _T("The text was not encrypted correctly"));
   assertThrowsMessage(EncryptText(_T("")), Workshare::ArgumentException, _T("Expected a Workshare argument exception for an empty string"));
}