Commit bb251d91c3fdfa526b32008c1a78e6d915e8b803
1 parent
fef69e63
Exists in
master
and in
1 other branch
Segundo commit em relação a primeira demanda
Showing
1 changed file
with
65 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,65 @@ | @@ -0,0 +1,65 @@ | ||
| 1 | +<?php | ||
| 2 | +session_start(); | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * Controlador (API v1) de servicos REST usando o framework Slim | ||
| 6 | + */ | ||
| 7 | + | ||
| 8 | +require_once dirname(__FILE__) . '/../../SEI.php'; | ||
| 9 | +require_once dirname(__FILE__) . '/vendor/autoload.php'; | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +//// parada da validação do token e login | ||
| 13 | + | ||
| 14 | +session_start(); | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +//$_POST['documento_id'] = '105'; | ||
| 18 | +//$_POST['token'] = 'YTE5YzgzNDM0OWFhMDNlNzAxMWY3OWNkN2UwZTYwZDdlZDAxNzFkM2FUVnhUV2sxYnoxOGZHazFjVTFwTlc4OWZId3dmSHc9'; | ||
| 19 | + | ||
| 20 | +if(empty($_POST['documento_id'])) | ||
| 21 | + throw new InfraException('Deve ser passado valor para o (id_documento).'); | ||
| 22 | + | ||
| 23 | +if(empty($_POST['token'])) | ||
| 24 | + throw new InfraException('Deve ser passado token no header.'); | ||
| 25 | + | ||
| 26 | +$token = $_POST['token']; | ||
| 27 | + | ||
| 28 | +if(!$token) | ||
| 29 | + return new InfraException('Acesso negado!'); | ||
| 30 | + | ||
| 31 | +$rn = new MdWsSeiUsuarioRN(); | ||
| 32 | + | ||
| 33 | +$result = $rn->autenticarToken($token); | ||
| 34 | + | ||
| 35 | +if(!$result['sucesso']){ | ||
| 36 | + new InfraException('Token inválido!'); | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +$tokenData = $rn->tokenDecode($token); | ||
| 40 | + | ||
| 41 | +$rn = new MdWsSeiUsuarioRN(); | ||
| 42 | +$usuarioDTO = new UsuarioDTO(); | ||
| 43 | +$contextoDTO = new ContextoDTO(); | ||
| 44 | +$usuarioDTO->setStrSigla($tokenData[0]); | ||
| 45 | +$usuarioDTO->setStrSenha($tokenData[1]); | ||
| 46 | +$contextoDTO->setNumIdContexto(null); | ||
| 47 | +$orgaoDTO = new OrgaoDTO(); | ||
| 48 | +$orgaoDTO->setNumIdOrgao(null); | ||
| 49 | +$rn->apiAutenticar($usuarioDTO, $contextoDTO, $orgaoDTO); | ||
| 50 | + | ||
| 51 | +// Recupera o id do procedimento | ||
| 52 | +$protocoloDTO = new DocumentoDTO(); | ||
| 53 | +$protocoloDTO->setDblIdDocumento($_POST['documento_id']); | ||
| 54 | +$protocoloDTO->retDblIdProcedimento(); | ||
| 55 | +$protocoloRN = new DocumentoRN(); | ||
| 56 | +$protocoloDTO = $protocoloRN->consultarRN0005($protocoloDTO); | ||
| 57 | + | ||
| 58 | +if(empty($protocoloDTO)) | ||
| 59 | + return new InfraException('Documento não encontrado'); | ||
| 60 | + | ||
| 61 | +$linkassinado = SessaoSEI::getInstance()->assinarLink('/sei/controlador.php?acao=editor_montar&acao_origem=arvore_visualizar&id_procedimento=' . $protocoloDTO->getDblIdProcedimento() . '&id_documento=' . $_POST['documento_id']); | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + header('Location: ' . $linkassinado); | ||
| 65 | + |