Changeset 1574
- Timestamp:
- 11/03/09 16:23:16 (15 years ago)
- Location:
- trunk/security
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/security/ExpressoCertLogin/src/LoginApplet.java
r1174 r1574 121 121 122 122 123 String redirect = this.getCodeBase(). toExternalForm() + "login.php?cd=98&ts=202";123 String redirect = this.getCodeBase().getProtocol() + "://" + this.getCodeBase().getHost() + "/login.php?cd=98&ts=202"; 124 124 try { 125 125 this.getAppletContext().showDocument(new URL(redirect)); … … 150 150 151 151 tryAgain = false; 152 String redirect = this.getCodeBase(). toExternalForm() + "login.php";152 String redirect = this.getCodeBase().getProtocol() + "://" + this.getCodeBase().getHost() + "/login.php"; 153 153 try { 154 154 this.getAppletContext().showDocument(new URL(redirect)); … … 223 223 System.gc(); 224 224 225 String redirect = this.getCodeBase(). toExternalForm() + "login.php";225 String redirect = this.getCodeBase().getProtocol() + "://" + this.getCodeBase().getHost() + "/login.php"; 226 226 try { 227 227 this.getAppletContext().showDocument(new URL(redirect)); -
trunk/security/ExpressoCertMail/src/br/gov/serpro/js/ParamReaderThread.java
r1174 r1574 17 17 import netscape.javascript.JSObject; 18 18 import org.bouncycastle.cms.CMSException; 19 20 19 21 20 public class ParamReaderThread extends Thread { … … 40 39 super.run(); 41 40 42 while (true){ 43 if (setup.getParameter("debug").equalsIgnoreCase("true")){ 44 System.out.println("Classe ParamReaderThread: pegando resultado."); 45 } 46 47 // processa o smime. Método sign implementado na classe DigitalCertificate 48 String smime = null; 49 DigitalCertificate dc = null; 50 51 try { 52 53 //Map<String, String> parsedData = parseData(resultado); 54 Map<String, String> parsedData = data.getMap(); 55 56 dc = new DigitalCertificate(this.parentFrame, this.setup); 57 dc.init(); 58 59 // Testa a operação e se for 60 if (parsedData.get("operation").equals("sign")){ 61 62 smime = dc.signMail(parsedData); 63 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 64 System.out.println("\nMensagem assinada: " + smime); 65 } 66 67 } 68 else if (parsedData.get("operation").equals("decript")){ 69 String decryptedMsg = dc.cipherMail(parsedData); 70 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 71 System.out.println("Mensagem decifrada: " + decryptedMsg); 72 } 73 if (decryptedMsg == null){ 74 smime = null; 75 } else { 76 smime = Base64Utils.base64Encode(decryptedMsg.getBytes()); 77 } 78 79 } 80 else { 81 throw new UnsupportedOperationException("Operation not supported: " + parsedData.get("operation")); 82 // Lança 83 } 84 85 // Retorna para a página 86 // se smime = null, a assinatura não funcionou 87 if (smime != null){ 88 page.call("appletReturn", new String[] {smime, parsedData.get("ID"), parsedData.get("operation"), parsedData.get("folder")}); 89 } 90 91 } catch (IOException e) { 92 //DialogBuilder.showMessageDialog(this.parentFrame, "Não foi possível carregar Token/SmartCard: senha incorreta", this.setup); 93 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread001"), this.setup); 94 //JOptionPane.showMessageDialog(this.parentFrame, "Não foi possível carregar Token/SmartCard: senha incorreta", 95 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 96 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 41 while (true){ 42 if (setup.getParameter("debug").equalsIgnoreCase("true")){ 43 System.out.println("Classe ParamReaderThread: pegando resultado."); 44 } 45 46 // processa o smime. Método sign implementado na classe DigitalCertificate 47 String smime = null; 48 DigitalCertificate dc = null; 49 Map<String, String> parsedData = null; 50 51 try { 52 53 //Map<String, String> parsedData = parseData(resultado); 54 parsedData = data.getMap(); 55 56 dc = new DigitalCertificate(this.parentFrame, this.setup); 57 dc.init(); 58 59 // Testa a operação e se for 60 if (parsedData.get("operation").equals("sign")){ 61 62 smime = dc.signMail(parsedData); 63 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 64 System.out.println("\nMensagem assinada: " + smime); 65 } 66 67 } 68 else if (parsedData.get("operation").equals("decript")){ 69 String decryptedMsg = dc.cipherMail(parsedData); 70 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 71 System.out.println("Mensagem decifrada: " + decryptedMsg); 72 } 73 if (decryptedMsg == null){ 74 smime = null; 75 } else { 76 smime = Base64Utils.base64Encode(decryptedMsg.getBytes()); 77 } 78 79 } 80 else { 81 throw new UnsupportedOperationException("Operation not supported: " + parsedData.get("operation")); 82 // Lança 83 } 84 85 // Retorna para a página 86 // se smime = null, a assinatura não funcionou 87 88 } catch (IOException e) { 89 //DialogBuilder.showMessageDialog(this.parentFrame, "Não foi possível carregar Token/SmartCard: senha incorreta", this.setup); 90 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread001"), this.setup); 91 //JOptionPane.showMessageDialog(this.parentFrame, "Não foi possível carregar Token/SmartCard: senha incorreta", 92 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 93 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 94 e.printStackTrace(); 95 } 96 } catch (GeneralSecurityException e) { 97 if (e.getCause() != null){ 98 DialogBuilder.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getCause().getMessage(), this.setup); 99 //JOptionPane.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getCause().getMessage(), 100 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 101 } 102 else { 103 DialogBuilder.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getMessage(), this.setup); 104 //JOptionPane.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getMessage(), 105 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 106 } 107 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 108 e.printStackTrace(); 109 } 110 } catch (SMIMEException e) { 111 //DialogBuilder.showMessageDialog(this.parentFrame, "Erro no processamento da assinatura: " + e.getMessage(), this.setup); 112 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread002"), this.setup); 113 //JOptionPane.showMessageDialog(this.parentFrame, "Erro no processamento da assinatura: " + e.getMessage(), 114 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 115 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 116 e.printStackTrace(); 117 } 118 } catch (MessagingException e) { 119 //DialogBuilder.showMessageDialog(this.parentFrame, "Erro no processamento da mensagem: " + e.getMessage(), this.setup); 120 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread003"), this.setup); 121 //JOptionPane.showMessageDialog(this.parentFrame, "Erro no processamento da mensagem: " + e.getMessage(), 122 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 123 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 124 e.printStackTrace(); 125 } 126 } 127 catch (CMSException e){ 128 //DialogBuilder.showMessageDialog(this.parentFrame, "Erro ao decifrar mensagem: Detectado problema na integridade da mensagem cifrada!", this.setup); 129 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread004"), this.setup); 130 //if (setup.getParameter("debug").equalsIgnoreCase("true")) { 131 Throwable cause = e.getCause(); 132 System.out.println(e.getClass().getCanonicalName() + ": " + e.getMessage()); 133 if (cause != null){ 134 System.out.println(cause.getClass().getCanonicalName() + ": " + cause.getMessage()); 135 } 97 136 e.printStackTrace(); 98 } 99 } catch (GeneralSecurityException e) { 100 if (e.getCause() != null){ 101 DialogBuilder.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getCause().getMessage(), this.setup); 102 //JOptionPane.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getCause().getMessage(), 103 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 104 } 105 else { 106 DialogBuilder.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getMessage(), this.setup); 107 //JOptionPane.showMessageDialog(this.parentFrame, "GeneralSecurityException: " + e.getMessage(), 108 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 109 } 110 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 111 e.printStackTrace(); 112 } 113 } catch (SMIMEException e) { 114 //DialogBuilder.showMessageDialog(this.parentFrame, "Erro no processamento da assinatura: " + e.getMessage(), this.setup); 115 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread002"), this.setup); 116 //JOptionPane.showMessageDialog(this.parentFrame, "Erro no processamento da assinatura: " + e.getMessage(), 117 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 118 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 119 e.printStackTrace(); 120 } 121 } catch (MessagingException e) { 122 //DialogBuilder.showMessageDialog(this.parentFrame, "Erro no processamento da mensagem: " + e.getMessage(), this.setup); 123 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread003"), this.setup); 124 //JOptionPane.showMessageDialog(this.parentFrame, "Erro no processamento da mensagem: " + e.getMessage(), 125 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 126 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 127 e.printStackTrace(); 128 } 137 //} 138 } 139 catch (ProviderException e){ 140 //DialogBuilder.showMessageDialog(this.parentFrame, "Problema no acesso às informações do Token: " + e.getMessage(), this.setup); 141 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread005"), this.setup); 142 //JOptionPane.showMessageDialog(this.parentFrame, "Problema no acesso às informações do Token: " + e.getMessage(), 143 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 144 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 145 e.printStackTrace(); 146 } 147 } 148 catch (UnsupportedOperationException e){ 149 // DialogBuilder.showMessageDialog(this.parentFrame, e.getMessage()); 150 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 151 e.printStackTrace(); 152 } 153 } 154 catch (IllegalArgumentException e){ 155 //DialogBuilder.showMessageDialog(this.parentFrame, e.getMessage()); 156 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 157 e.printStackTrace(); 158 } 159 } 160 catch (InterruptedException e){ 161 if (setup.getParameter("debug").equalsIgnoreCase("true")){ 162 System.out.println("Classe ParamReaderThread: Thread has been interrupted! Break."); 163 e.printStackTrace(); 164 } 165 break; 166 } 167 finally { 168 169 page.call("appletReturn", new String[]{smime, parsedData.get("ID"), parsedData.get("operation"), parsedData.get("folder")}); 170 171 } 172 173 dc.destroy(); 174 dc = null; 175 System.gc(); 176 Thread.yield(); 177 129 178 } 130 catch (CMSException e){ 131 //DialogBuilder.showMessageDialog(this.parentFrame, "Erro ao decifrar mensagem: Detectado problema na integridade da mensagem cifrada!", this.setup); 132 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread004"), this.setup); 133 //if (setup.getParameter("debug").equalsIgnoreCase("true")) { 134 Throwable cause = e.getCause(); 135 System.out.println(e.getClass().getCanonicalName() + ": " + e.getMessage()); 136 if (cause != null){ 137 System.out.println(cause.getClass().getCanonicalName() + ": " + cause.getMessage()); 138 } 139 e.printStackTrace(); 140 //} 141 } 142 catch (ProviderException e){ 143 //DialogBuilder.showMessageDialog(this.parentFrame, "Problema no acesso às informações do Token: " + e.getMessage(), this.setup); 144 DialogBuilder.showMessageDialog(this.parentFrame, setup.getLang("ExpressoCertMailMessages", "ParamReaderThread005"), this.setup); 145 //JOptionPane.showMessageDialog(this.parentFrame, "Problema no acesso às informações do Token: " + e.getMessage(), 146 // "Aviso", JOptionPane.INFORMATION_MESSAGE); 147 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 148 e.printStackTrace(); 149 } 150 } 151 catch (UnsupportedOperationException e){ 152 // DialogBuilder.showMessageDialog(this.parentFrame, e.getMessage()); 153 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 154 e.printStackTrace(); 155 } 156 } 157 catch (IllegalArgumentException e){ 158 //DialogBuilder.showMessageDialog(this.parentFrame, e.getMessage()); 159 if (setup.getParameter("debug").equalsIgnoreCase("true")) { 160 e.printStackTrace(); 161 } 162 } 163 catch (InterruptedException e){ 164 if (setup.getParameter("debug").equalsIgnoreCase("true")){ 165 System.out.println("Classe ParamReaderThread: Thread has been interrupted! Break."); 166 e.printStackTrace(); 167 } 168 break; 169 } 170 171 dc.destroy(); 172 dc = null; 173 System.gc(); 174 Thread.yield(); 175 176 } 177 } 178 179 } 179 180 //TODO: Documentar o que recebe!!! 180 181 /*private Map<String, String> parseData(String expressoMailData){ -
trunk/security/captcha.php
r1174 r1574 89 89 $this->Font, 90 90 $this->CaptchaString); 91 imagecolortransparent($image,$bgcolor); 91 92 switch ($this->ImageType) 92 93 { -
trunk/security/classes/CertificadoB.php
r1174 r1574 161 161 $this->erros_ssl[] = $erro; 162 162 } 163 If(file_exists($vrf_msg_arquivo_temporario)) 164 { 165 $this->msg_sem_assinatura = file_get_contents($vrf_msg_arquivo_temporario); 166 } 167 else 168 { 169 $this->msg_sem_assinatura = 'Nao pode exibir a msg(CD-1)'; 170 } 163 171 # Reexecuta o comando com um nivel menor de criticas. 164 172 $this->cert_assinante = $this->extrai_certificado_da_msg_assinada($m); … … 166 174 { 167 175 # Se nao foi possivel obter o certificado retorna com falso ..... 176 If(file_exists($vrf_msg_arquivo_temporario)) 177 { 178 $this->msg_sem_assinatura = file_get_contents($vrf_msg_arquivo_temporario); 179 } 180 else 181 { 182 $this->msg_sem_assinatura = 'Nao pode exibir a msg(CD-2)'; 183 } 168 184 deleta_arquivos_temporarios($this->arquivos_para_deletar); 169 185 $this->arquivos_para_deletar = array(); … … 187 203 while ($erro = openssl_error_string()); // Limpa buffer de erros anteriores...... 188 204 # Certificado poderia ter assinado um email?? 189 if(!($this->dados['KEYUSAGE']['digitalSignature'] && $this->dados['EXTKEYUSAGE']['emailProtection']))205 if(!($this->dados['KEYUSAGE']['digitalSignature'])) 190 206 { 191 207 $this->erros_ssl[] = 'Certificado nao poderia ter sido utilizado para assinar email.'; -
trunk/security/classes/funcoes_auxiliares.php
r1174 r1574 1388 1388 // Unknown 1389 1389 $result[] = 'UNKNOWN' . $data;; 1390 //file_put_contents('/opt/lampp/htdocs/se curity/temp/arquivo_desconhecido.txt',$data);1390 //file_put_contents('/opt/lampp/htdocs/seguranca/temp/arquivo_desconhecido.txt',$data); 1391 1391 $data = ''; 1392 1392 break; … … 1423 1423 1424 1424 1425 function testa_p7m($msg) 1426 { 1427 // oids pesquisadas: 1428 // 1.2.840.113549.1.7.2 assinatura digital 1429 // 1.2.840.113549.1.7.3 envelopeddata 1430 $ZZ1 = explode('MIME-Version: 1.0',$msg); 1431 $ZZ2 = explode('filename="smime.p7m"',$ZZ1[count($ZZ1)-1]); 1432 $ZZ3 = str_replace(' ','',$ZZ2[count($ZZ2)-1]); 1433 $p7m_formato_der = base64_decode($ZZ3); 1434 $oid_hexa = OIDtoHex('1.2.840.113549.1.7.2'); // converte oid de texto para hexadecimal ... 1435 $partes = explode($oid_hexa,$p7m_formato_der); // Faz o split pela oid... 1436 if(count($partes)>1) 1437 { 1438 return 'signature' ; 1439 } 1440 $oid_hexa = OIDtoHex('1.2.840.113549.1.7.3'); 1441 $partes = explode($oid_hexa,$p7m_formato_der); // Faz o split pela oid... 1442 if(count($partes)>1) 1443 { 1444 return 'cipher' ; 1445 } 1446 return 'normal'; 1447 } 1448 1449 1450 function parse_sequence($data) 1451 { 1452 $len = ord($data[1]); 1453 $bytes = 0; 1454 get_length(&$len,&$bytes,$data); // obtem tamanho da parte de dados da oid. 1455 $oid_data = substr($data,2 + $bytes,$len); // Obtem porcao de bytes pertencentes a oid. 1456 $ret = Crl_parseASN($oid_data); // parse dos dados da oid. 1457 return $ret; 1458 } 1459 1425 1460 function recupera_dados_oid($certificado_digital_formato_der, $oid) 1426 1461 { 1427 1462 // Esta função assume que a oid esta inserida dentro de uma estrutura do tipo "sequencia" , como primeiro elemento da estrutura... 1428 $oid_hexa = OIDtoHex($oid); 1463 $oid_hexa = OIDtoHex($oid); // converte oid de texto para hexadecimal ... 1429 1464 $partes = explode($oid_hexa,$certificado_digital_formato_der); // Faz o split pela oid... 1430 $ret = array();1465 $retr = array(); 1431 1466 if(count($partes)>1) 1432 1467 { … … 1437 1472 $xcv3 = substr($partes[$i-1],strlen($partes[$i-1])-3,3); // recupera da primeira parte os 3 ultimos digitos... 1438 1473 $xcv2 = substr($partes[$i-1],strlen($partes[$i-1])-2,2); // recupera da primeira parte os 2 ultimos digitos... 1474 if($xcv2[0] == chr(0x30)) 1475 { 1476 $xcv = $xcv2; 1477 $data = $xcv . $oid_hexa . $partes[$i]; // reconstroi a sequencia..... 1478 $ret = parse_sequence($data); 1479 1480 if($ret[0] != '') 1481 { 1482 $retr[] = $ret; 1483 continue; 1484 } 1485 } 1486 if($xcv3[0] == chr(0x30)) 1487 { 1488 $xcv = $xcv3; 1489 $data = $xcv . $oid_hexa . $partes[$i]; // reconstroi a sequencia..... 1490 $ret = parse_sequence($data); 1491 if($ret[0] != '') 1492 { 1493 $retr[] = $ret; 1494 continue; 1495 } 1496 } 1439 1497 if($xcv4[0] == chr(0x30)) 1440 1498 { 1441 1499 $xcv = $xcv4; 1442 } 1443 else 1444 { 1445 if($xcv3[0] == chr(0x30)) 1500 $data = $xcv . $oid_hexa . $partes[$i]; // reconstroi a sequencia..... 1501 $ret = parse_sequence($data); 1502 if($ret[0] != '') 1446 1503 { 1447 $xcv = $xcv3; 1448 } 1449 else 1450 { 1451 $xcv = $xcv2; 1452 } 1453 } 1454 $data = $xcv . $oid_hexa . $partes[$i]; // reconstroi a sequencia..... 1455 $len = ord($data[1]); 1456 $bytes = 0; 1457 get_length(&$len,&$bytes,$data); // obtem tamanho da parte de dados da oid. 1458 $oid_data = substr($data,2 + $bytes,$len); // Obtem porcao de bytes pertencentes a oid. 1459 $ret[] = Crl_parseASN($oid_data); // parse dos dados da oid. 1504 $retr[] = $ret; 1505 continue; 1506 } 1507 } 1460 1508 } 1461 1509 } 1462 return $ret ;1510 return $retr; 1463 1511 } 1464 1512 -
trunk/security/vercert.php
r1174 r1574 179 179 180 180 $atributos = array(); 181 $atributos[] = 'phpgwaccountexpires'; 181 //$atributos[] = 'phpgwaccountexpires'; 182 $atributos[] = 'phpgwlastpasswdchange'; 182 183 183 184 if(isset($GLOBALS['phpgw_info']['server']['atributoexpiracao'])) … … 240 241 else 241 242 { 242 $user_info['phpgwaccountexpires'] = '0'; 243 //$user_info['phpgwaccountexpires'] = '0'; 244 $user_info['phpgwlastpasswdchange'] = '0'; 243 245 } 244 246 ldap_modify($cc,$aux1,$user_info);
Note: See TracChangeset
for help on using the changeset viewer.