True, 'nonavbar' => True, 'currentapp' => 'preferences' ); if(file_exists('../header.inc.php')) { include('../header.inc.php'); } else { echo '1'.chr(0x0D).chr(0x0A).lang('Error. header.inc.php not found'); exit(); } if($_POST['certificado']) { $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Digital Certificate Registration'); $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); echo '
'; echo '


'; require_once('../security/classes/CertificadoB.php'); require_once('../security/classes/Verifica_Certificado.php'); include('../security/classes/Verifica_Certificado_conf.php'); $cert = troca_espaco_por_mais(str_replace(chr(0x0D).chr(0x0A),chr(0x0A),str_replace(chr(0x0A).chr(0x0A),chr(0x0A),$_POST['certificado']))); $c = new certificadoB(); $c->certificado($cert); if (!$c->apresentado) { echo '

'.lang('Fail to get certificate').'

'; exit(); } $b = new Verifica_Certificado($c->dados,$cert); // Testa se Certificado OK. if(!$b->status) { $msg = '3'.chr(0x0D).chr(0x0A).$b->msgerro; foreach($b->erros_ssl as $linha) { $msg .= "\n" . $linha; } echo '

'.$msg.'

'; exit(); } if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) { $ds = $GLOBALS['phpgw']->common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); } else { $ds = $GLOBALS['phpgw']->common->ldapConnect(); } if (!$ds) { echo '

'.lang('Failure when get user data to login').'

'; exit(); } $cert_atrib_cpf = isset($GLOBALS['phpgw_info']['server']['certificado_atributo_cpf'])&&$GLOBALS['phpgw_info']['server']['certificado_atributo_cpf']!=''?$GLOBALS['phpgw_info']['server']['certificado_atributo_cpf']:"uid"; // CPF he valor obrigatório no certificado ICP-BRASIL. $filtro = $cert_atrib_cpf .'='. $c->dados['2.16.76.1.3.1']['CPF']; $atributos = array(); if(isset($GLOBALS['phpgw_info']['server']['atributoexpiracao']) && $GLOBALS['phpgw_info']['server']['atributoexpiracao']) { $atributos[] = $GLOBALS['phpgw_info']['server']['atributoexpiracao']; } else { $atributos[] = 'phpgwlastpasswdchange'; } $atributos[] = "userCertificate"; $atributos[] = "uid"; $sr=ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'],$filtro,$atributos); // Pega resultado .... $info = ldap_get_entries($ds, $sr); // Tem de achar só uma entrada.....ao menos uma.... if($info["count"]!=1) { echo '

'.lang('Invalid data from users directory').'('.$cert_atrib_cpf.' = ' . $c->dados['2.16.76.1.3.1']['CPF'] . ')'.'

'; ldap_close($ds); exit(); } if($info[0]["uid"][0] != $GLOBALS['phpgw_info']['user']['userid']) { echo '

'.lang('Invalid data from users directory').'('.$cert_atrib_cpf.' = ' . $c->dados['2.16.76.1.3.1']['CPF'] . ' - ' . $info[0]["uid"][0] . ' - ' . $GLOBALS['phpgw_info']['user']['userid'] . ')'.'

'; ldap_close($ds); exit(); } if($info[0]["userCertificate"][0] && $cert == $info[0]["userCertificate"][0] ) { //echo '0'.chr(0x0D).chr(0x0A).$info[0]["uid"][0].chr(0x0D).chr(0x0A).$info[0]["cryptpassword"][0]; echo '

'.lang('Certificate already registered').'

'; ldap_close($ds); exit(); } $user_info = array(); $aux1 = $info[0]["dn"]; $user_info['userCertificate'] = $cert; if(isset($GLOBALS['phpgw_info']['server']['atributoexpiracao']) && $GLOBALS['phpgw_info']['server']['atributoexpiracao']) { if(substr($info[0][$GLOBALS['phpgw_info']['server']['atributoexpiracao']][0],-1,1)=="Z") { $user_info[$GLOBALS['phpgw_info']['server']['atributoexpiracao']] = '19800101000000Z'; } else { $user_info[$GLOBALS['phpgw_info']['server']['atributoexpiracao']] = '0'; } } else { $user_info['phpgwlastpasswdchange'] = '0'; } if(!ldap_modify($ds,$aux1,$user_info)) { echo '

'.lang('Error in Certificate registration'). ' - ' . $aux1.'

'; } else { echo '

'.lang('To conclude your Certificate registration change your password').'

'; } echo '

'; echo '
'; $GLOBALS['phpgw']->common->phpgw_footer(); ldap_close($ds); exit(); } else { $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Digital Certificate Registration'); $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); if ($GLOBALS['phpgw_info']['server']['certificado']==1) { $var_tokens = ''; for($ii = 1; $ii < 11; ++$ii) { if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1']) $var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ','; } if(!$var_tokens) { $var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll'; } $param1 = " ' ' + "; $param2 = " 'token=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\" ' + "; $cod_applet = /* // com debug ativado ''; */ // sem debug ativado ''; echo $cod_applet; echo '
'; echo '


'; echo '

'.lang('Getting your Certificate').'

'; echo '

'; echo ''; echo '
'; $GLOBALS['phpgw']->common->phpgw_footer(); } } ?>