Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mais opções de configuração #28

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions MdWsSeiRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ public function montarMensagemProcesso(ProcedimentoAPI $objProcedimentoAPI)

public function adicionarElementoMenu()
{

$desabilitarQrCodeAplicativo = ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'DesabilitarQrCodeAplicativo', false, false);

if($desabilitarQrCodeAplicativo){
return '';
}

try{
$nomeArquivo = 'QRCODE_'
. self::NOME_MODULO
Expand Down
65 changes: 65 additions & 0 deletions controlador_ws.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,71 @@ public function __invoke($request, $response, $next)
}
}

/**
* Classe com regra para verificar se existe permiss�o para execu��o dos servi�os
*/
class ServicePermissionsMiddleware {

/**
* Aplica regra
*
* @param \Slim\Http\Request $request
* @param \Slim\Http\Response $response
* @param Closure $next
* @return \Slim\Http\Response
*/
public function __invoke($request, $response, $next)
{

$servicosHabilitados = ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'ServicosHabilitados', false, false);
$servicosDesabilitados = ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'ServicosDesabilitados', false, false);

$servicoHabilitado = true;
$servicoDesabilitado = false;

if($servicosHabilitados){
$servicoHabilitado = $this->isRequestInPatternList($request, $servicosHabilitados);
}

if($servicosDesabilitados){
$servicoDesabilitado = $this->isRequestInPatternList($request, $servicosDesabilitados);
}

if(!$servicoHabilitado || $servicoDesabilitado){
$response = $response->withJson(
array(
"sucesso" => false,
"mensagem" => utf8_encode('Servi�o ' . $request->getMethod() . ':' . str_replace('api/v2/', '', $request->getUri()->getPath()) . ' n�o permitido'),
"exception" => null
),
405
);
}else{
$response = $next($request, $response);
}

return $response;
}

/**
* verifica se path da requisi��o passa na espress�o regular da lista
*
* @param \Slim\Http\Request $request
* @param array $lista
* @return boolean retorna true se $request->getUri()->getPath() combina com com algum $pattern, false se n�o der match em nenhum registro
*/
private function isRequestInPatternList($request, $lista){
$result = false;
foreach ($lista as $pattern) {
$pattern = '/^api\/v2\/' . $pattern . '$/m';
if(preg_match($pattern, $request->getUri()->getPath())){
$result = true;
break;
}
}
return $result;
}
}

$config = array(
'settings' => array(
Expand Down
9 changes: 8 additions & 1 deletion docs/instalacao.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@
'UrlServicoNotificacao' => '{URL do serviço de notificação}',
'IdApp' => '{ID do app registrado no serviço de notificação}',
'ChaveAutorizacao' => '{Chave de autorização do serviço de notificação}',
'TokenSecret' => '{chave unica com pelo menos 32 chars. Pode usar o comando uuidgen para gerar}'
'TokenSecret' => '{chave unica com pelo menos 32 chars. Pode usar o comando uuidgen para gerar}',

//chaves opcionais
'DesabilitarQrCodeAplicativo' => '{(bool) se true desabilita a visão do QrCode do aplicativo no menu do SEI. Padrão=false.}',
'DesabilitarServicoNotificacao' => '{(bool) se true desabilita o serviço de autenticação. Padrão=false}',
'ServicosHabilitados' => '{(array|bool) lista de expressões regulares para habilitar apenas os serviços que combinem com os padrões listados. Padrão=false. Exemplo "ServicosHabilitados" => ["hipoteseLegal.*"]}',
'ServicosDesabilitados' => '{(array|bool) lista de expressões regulares para desabilitar apenas os serviços que combinem com os padrões listados. Padrão=false. Exemplo "ServicosDesabilitados" => ["bloco/assinatura.*","versao"]}',
'Sleep' => '{int} valor padrão para sleeps nas chamadas ',
),

(...)
Expand Down
8 changes: 8 additions & 0 deletions rn/MdWsSeiAgendamentoRN.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ protected function inicializarObjInfraIBanco()

protected function notificacaoAtividadesControlado()
{

$desabilitarServicoNotificacao = ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'DesabilitarServicoNotificacao', false, false);

if($desabilitarServicoNotificacao){
LogSEI::getInstance()->gravar('Notifica��es n�o realizadas pois "DesabilitarServicoNotificacao = true". ', InfraLog::$INFORMACAO);
return;
}

try {
ini_set('max_execution_time', '0');
ini_set('memory_limit', '1024M');
Expand Down
4 changes: 2 additions & 2 deletions rn/MdWsSeiBlocoRN.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function retornarBlocoControlado(BlocoDTO $blocoDTO){
public function apiAssinarBloco($idBloco, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario)
{
try{
sleep(3);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 3));
$objRelBlocoProtocoloDTO = new RelBlocoProtocoloDTO();
$objRelBlocoProtocoloDTO->setNumIdBloco($idBloco);
$objRelBlocoProtocoloDTO->setOrdNumSequencia(InfraDTO::$TIPO_ORDENACAO_ASC);
Expand Down Expand Up @@ -80,7 +80,7 @@ public function apiAssinarBloco($idBloco, $idOrgao, $strCargoFuncao, $siglaUsuar
public function apiAssinarDocumentos($idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario, $arrIdDocumentos)
{
try{
sleep(3);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 3));
if(!$arrIdDocumentos){
return MdWsSeiRest::formataRetornoSucessoREST('Nenhum documento foi informado para ser assinado.');
}
Expand Down
2 changes: 1 addition & 1 deletion rn/MdWsSeiBloco_V1_RN.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function retornarControlado(BlocoDTO $blocoDTO){
public function apiAssinarBloco($idBloco, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario)
{
try{
sleep(3);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 3));
$objRelBlocoProtocoloDTO = new RelBlocoProtocoloDTO();
$objRelBlocoProtocoloDTO->setNumIdBloco($idBloco);
$objRelBlocoProtocoloDTO->setOrdNumSequencia(InfraDTO::$TIPO_ORDENACAO_ASC);
Expand Down
2 changes: 1 addition & 1 deletion rn/MdWsSeiDocumentoRN.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ public function apiAssinarDocumento($idDocumento, $idOrgao, $strCargoFuncao, $si
public function assinarDocumentoControlado(AssinaturaDTO $assinaturaDTO)
{
try {
sleep(3);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 3));
$assinaturaDTO->setStrStaFormaAutenticacao(AssinaturaRN::$TA_SENHA);
// $assinaturaDTO->setNumIdContextoUsuario(null);
$documentoRN = new DocumentoRN();
Expand Down
2 changes: 1 addition & 1 deletion rn/MdWsSeiDocumento_V1_RN.php
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ public function apiAssinarDocumento($idDocumento, $idOrgao, $strCargoFuncao, $si
*/
public function assinarDocumentoControlado(AssinaturaDTO $assinaturaDTO) {
try {
sleep(3);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 3));
$assinaturaDTO->setStrStaFormaAutenticacao(AssinaturaRN::$TA_SENHA);
// $assinaturaDTO->setNumIdContextoUsuario(null);
$documentoRN = new DocumentoRN();
Expand Down
2 changes: 1 addition & 1 deletion rn/MdWsSeiUsuarioRN.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function apiAutenticar(UsuarioDTO $usuarioDTO, OrgaoDTO $orgaoDTO){
);

if(!$ret){
sleep(3);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 3));
throw new InfraException('Usu�rio ou senha inv�lido!');
}

Expand Down
11 changes: 9 additions & 2 deletions scripts/sei_atualizar_versao_modulo_wssei.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ public function versao_0_8_12($strVersaoAtual)
$infraAgemdanemtoTarefaDTO->setStrPeriodicidadeComplemento('0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23');
}

$infraAgemdanemtoTarefaDTO->setStrSinAtivo('S');
$desabilitarServicoNotificacao = ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'DesabilitarServicoNotificacao', false, false);
if($desabilitarServicoNotificacao){
$infraAgemdanemtoTarefaDTO->setStrSinAtivo('N');
}else{
$infraAgemdanemtoTarefaDTO->setStrSinAtivo('S');
}

$infraAgemdanemtoTarefaDTO->setStrSinSucesso('S');

$infraAgemdanemtoTarefaBD = new InfraAgendamentoTarefaBD(BancoSEI::getInstance());
Expand Down Expand Up @@ -116,9 +122,10 @@ public function versao_1_0_3($strVersaoAtual)
public function versao_1_0_4($strVersaoAtual)
{
$this->logar("VERIFICANDO SE A CHAVE: TokenSecret ESTA PRESENTE NO ARQUIVO DE CONFIGURACOES.");
$desabilitarServicoNotificacao = ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'DesabilitarServicoNotificacao', false, false);

$token = ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'TokenSecret', false);
if((!$token) || (strlen($token)<25)){
if(!$desabilitarServicoNotificacao && ((!$token) || (strlen($token)<25))){
$msg = 'Token Secret inexistente ou tamanho menor que o permitido! Verifique o manual de instalacao do m�dulo. ';
$msg = $msg . 'O script de instalacao foi interrompido. M�dulo nao instalado corretamente. ';
$msg = $msg . 'Ajuste a chave e rode novamente o script.';
Expand Down
2 changes: 1 addition & 1 deletion testes/PhpUnit/src/paginas/PaginaDocumento.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function adicionarInteressado($arrayNomeInteressado)
$input->value($nomeInteressado);
$this->test->keys(Keys::ENTER);
$this->test->acceptAlert();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion testes/PhpUnit/src/paginas/PaginaEditarProcesso.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function adicionarInteressado($arrayNomeInteressado)
$input->value($nomeInteressado);
$this->test->keys(Keys::ENTER);
$this->test->acceptAlert();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions testes/PhpUnit/src/paginas/PaginaIncluirDocumento.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public function selecionarTipoDocumento($tipoDocumento)
{
try{
$this->test->byId('txtFiltro')->value($tipoDocumento);
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$this->test->byLinkText($tipoDocumento)->click();
}
catch (Exception $e){
$this->test->byId("imgExibirSeries")->click();
$this->test->byId('txtFiltro')->value($tipoDocumento);
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$this->test->byLinkText($tipoDocumento)->click();
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public function adicionarInteressado($nomeInteressado)
$this->test->keys(Keys::ENTER);
$this->test->acceptAlert();

sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
}

public function salvarDocumento()
Expand Down Expand Up @@ -124,7 +124,7 @@ public function gerarDocumentoTeste(array $dadosDocumento = null)
$this->test->frame(null);
$this->test->frame("ifrVisualizacao");
$this->test->byXPath("//img[@alt='Incluir Documento']")->click();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));

$dadosDocumento = $dadosDocumento ?: array();
$dadosDocumento["TIPO_DOCUMENTO"] = @$dadosDocumento["TIPO_DOCUMENTO"] ?: "Ofício";
Expand Down Expand Up @@ -162,7 +162,7 @@ public function gerarDocumentoExternoTeste(array $dadosDocumento)
$this->test->frame(null);
$this->test->frame("ifrVisualizacao");
$this->test->byXPath("//img[@alt='Incluir Documento']")->click();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));

$dadosDocumento = $dadosDocumento ?: array();
$dadosDocumento["TIPO_DOCUMENTO"] = @$dadosDocumento["TIPO_DOCUMENTO"] ?: "Ofício";
Expand All @@ -175,9 +175,9 @@ public function gerarDocumentoExternoTeste(array $dadosDocumento)
$dadosDocumento["HIPOTESE_LEGAL"] = @$dadosDocumento["HIPOTESE_LEGAL"] ?: "";

$this->selecionarTipoDocumentoExterno();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$this->tipoDocumento($dadosDocumento["TIPO_DOCUMENTO"]);
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));

$this->dataElaboracao($dadosDocumento["DATA_ELABORACAO"]);
$this->formato($dadosDocumento["FORMATO_DOCUMENTO"]);
Expand Down
6 changes: 3 additions & 3 deletions testes/PhpUnit/src/paginas/PaginaIniciarProcesso.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public function selecionarTipoProcesso($tipoProcesso)
{
try{
$this->test->byId('txtFiltro')->value($tipoProcesso);
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$this->test->byLinkText($tipoProcesso)->click();
}
catch (Exception $e){
$this->test->byId("imgExibirTiposProcedimento")->click();
$this->test->byId('txtFiltro')->value($tipoProcesso);
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$this->test->byLinkText($tipoProcesso)->click();
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public function adicionarInteressado($arrayNomeInteressado)
$input->value($nomeInteressado);
$this->test->keys(Keys::ENTER);
$this->test->acceptAlert();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions testes/PhpUnit/src/paginas/PaginaProcesso.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function navegarParaTramitarProcesso()
$this->test->frame("ifrVisualizacao");
$this->editarProcessoButton = $this->test->byXPath("//img[@alt='Envio Externo de Processo']");
$this->editarProcessoButton->click();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$testCase->assertContains('Envio Externo de Processo', $testCase->byCssSelector('body')->text());
return true;
}, 100000);
Expand All @@ -73,7 +73,7 @@ public function navegarParaConsultarAndamentos()

$this->test->frame(null);
$this->test->frame("ifrVisualizacao");
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$testCase->assertContains('Histórico do Processo', $testCase->byCssSelector('body')->text());
return true;
}, 100000);
Expand All @@ -89,7 +89,7 @@ public function navegarParaConsultarRecibos()
$this->test->frame("ifrVisualizacao");
$this->editarProcessoButton = $this->test->byXPath("//img[@alt='Consultar Recibos']");
$this->editarProcessoButton->click();
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$testCase->assertContains('Consultar Recibos', $testCase->byCssSelector('body')->text());
return true;
}, 100000);
Expand Down Expand Up @@ -147,7 +147,7 @@ public function selecionarDocumento($nomeDocumentoArvore)
public function selecionarProcesso()
{
$this->selecionarItemArvore($this->listarArvoreProcesso()[0]);
sleep(1);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 1));
}

public function listarDocumentos()
Expand Down
2 changes: 1 addition & 1 deletion testes/PhpUnit/src/paginas/PaginaTeste.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function titulo()

public function alertTextAndClose($confirm = true)
{
sleep(2);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 2));
$result = $this->test->alertText();
$result = (!is_array($result) ? $result : null);

Expand Down
9 changes: 5 additions & 4 deletions versao/v2/MdWsSeiServicosV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function registrarServicos()
*/
$this->post('/autenticar', function ($request, $response, $args) {
/** @var $response Slim\Http\Response */
sleep(3);
sleep(ConfiguracaoSEI::getInstance()->getValor('WSSEI', 'Sleep', false, 3));
$rn = new MdWsSeiUsuarioRN();
$usuarioDTO = new UsuarioDTO();
$usuarioDTO->setStrSigla($request->getParam('usuario'));
Expand Down Expand Up @@ -1742,9 +1742,10 @@ public function registrarServicos()
});
})->add(new TokenValidationMiddleware());

})
->add(new ModuleVerificationMiddleware())
->add(new EncodingMiddleware());
})
->add(new ModuleVerificationMiddleware())
->add(new EncodingMiddleware())
->add(new ServicePermissionsMiddleware());

return $this->slimApp;
}
Expand Down