Compare View

switch
from
...
to
 
Commits (2)
pom.xml
... ... @@ -3,7 +3,7 @@
3 3 <modelVersion>4.0.0</modelVersion>
4 4 <groupId>br.gov.ans.commons</groupId>
5 5 <artifactId>ans-commons-sei</artifactId>
6   - <version>1.2.0</version>
  6 + <version>1.2.1</version>
7 7 <name>ans-commons-sei</name>
8 8 <packaging>jar</packaging>
9 9 <description>Biblioteca de apoio aos clientes do SEI-Broker.</description>
... ... @@ -24,13 +24,6 @@
24 24 <scope>provided</scope>
25 25 </dependency>
26 26  
27   - <!-- HASH -->
28   - <dependency>
29   - <groupId>br.gov.ans.commons</groupId>
30   - <artifactId>ans-commons-security</artifactId>
31   - <version>2.0</version>
32   - </dependency>
33   -
34 27 <!-- BASE64 -->
35 28 <dependency>
36 29 <groupId>commons-codec</groupId>
... ...
src/main/java/br/gov/ans/integracao/sei/modelo/Unidade.java
1 1 package br.gov.ans.integracao.sei.modelo;
2 2  
  3 +/**
  4 + * Enum que relaciona as Unidades da organização.
  5 + * Preencher conforme a organização.
  6 + *
  7 + *
  8 + */
3 9 public enum Unidade {
4 10  
5   - AGEST_DIGES("110001107"),
6   - ASSNT_DIGES("110001106"),
7   - DIRAD_DIGES("110001105"),
8   - DIGES("110001104"),
9   - COPEO("110001101"),
10   - COMIN("110001100"),
11   - COPAS("110001099"),
12   - COADI("110001098"),
13   - GGFIS("110001097"),
14   - COGIN("110001096"),
15   - COCEN("110001095"),
16   - COAFI("110001094"),
17   - COPAM("110001093"),
18   - GGART("110001092"),
19   - COADM("110001091"),
20   - COAJU("110001090"),
21   - ASSNT_DIFIS("110001089"),
22   - GGAAC("110001088"),
23   - CEANS("110001087"),
24   - CAMSS("110001086"),
25   - ASSIS("110001085"),
26   - COAUD("110001084"),
27   - AUDIT("110001083"),
28   - PPCOR("110001082"),
29   - ASINF("110001081"),
30   - ASSIF("110001080"),
31   - OUVID("110001078"),
32   - DIRAD_DIFIS("110001077"),
33   - DIFIS("110001076"),
34   - GEDAT("110001075"),
35   - COPRASS("110001074"),
36   - GECOS("110001073"),
37   - CODIT("110001072"),
38   - GEDIT("110001071"),
39   - GEADM("110001070"),
40   - GECON("110001069"),
41   - GEAS("110001068"),
42   - ASSERDC("110001067"),
43   - COINF("110001066"),
44   - COSAI("110001065"),
45   - COMOA("110001064"),
46   - ASSEP("110001063"),
47   - GMOA("110001062"),
48   - PROGE("110001061"),
49   - GGRAS("110001060"),
50   - COADP("110001059"),
51   - COFIP("110001058"),
52   - COEI("110001057"),
53   - COREF("110001056"),
54   - ACAMS("110001055"),
55   - COAFP("110001054"),
56   - CATDF("110001053"),
57   - ASPAR("110001052"),
58   - COMEP("110001051"),
59   - GGRIN("110001050"),
60   - GEFAP("110001049"),
61   - COERA("110001048"),
62   - COATP("110001047"),
63   - COARI("110001046"),
64   - COMRA("110001045"),
65   - GGATP("110001044"),
66   - GEARA("110001043"),
67   - GAB_PRESI("110001042"),
68   - SECEX("110001041"),
69   - COMOP("110001040"),
70   - PRESI("110001039"),
71   - CORAP("110001038"),
72   - NUCLEO_SP("110001037"),
73   - COMAP("110001036"),
74   - NUCLEO_RS("110001035"),
75   - GEMOP("110001034"),
76   - NUCLEO_RJ("110001033"),
77   - NUCLEO_RP("110001032"),
78   - NUCLEO_PE("110001031"),
79   - NUCLEO_PR("110001030"),
80   - DIRAD_DIPRO("110001029"),
81   - NUCLEO_PA("110001028"),
82   - NUCLEO_MG("110001027"),
83   - NUCLEO_MT("110001026"),
84   - NUCLEO_DF("110001025"),
85   - GGREP("110001024"),
86   - NUCLEO_CE("110001023"),
87   - ASPES("110001022"),
88   - NUCLEO_BA("110001021"),
89   - NUCLEOS_DA_ANS("110001020"),
90   - COCRE("110001019"),
91   - COAINES("110001018"),
92   - COIND("110001017"),
93   - AGEST_DIPRO("110001016"),
94   - CODAD("110001015"),
95   - COLIQ("110001014"),
96   - GEPIN("110001013"),
97   - CODIF("110001012"),
98   - ASSNT_DIPRO("110001011"),
99   - GERE("110001010"),
100   - COIMO("110001009"),
101   - GGRE("110001008"),
102   - COEST("110001007"),
103   - CESME("110001006"),
104   - COATU("110001005"),
105   - GERPI("110001004"),
106   - COIEP("110001003"),
107   - CAQS("110001002"),
108   - COHAB("110001001"),
109   - CEIS("110001000"),
110   - GEHAE("110000999"),
111   - GEEIQ("110000998"),
112   - COPAEF("110000997"),
113   - COAOP("110000996"),
114   - COBPC("110000995"),
115   - COIQP("110000994"),
116   - GEAOP("110000993"),
117   - GERAR("110000992"),
118   - GGAME("110000991"),
119   - COGED("110000990"),
120   - CONOR("110000989"),
121   - CEAD("110000988"),
122   - COARE("110000987"),
123   - ASSNT_DIOPE("110000986"),
124   - COAI("110000985"),
125   - DIPRO("110000984"),
126   - SECEA("110000983"),
127   - COAD("110000982"),
128   - COTEC("110000981"),
129   - COINQ("110000980"),
130   - COREC("110000979"),
131   - GEIRS("110000978"),
132   - ASSINF_DIDES("110000977"),
133   - DIRAD_DIOPE("110000976"),
134   - COADC("110000975"),
135   - ASSNT_DIDES("110000974"),
136   - GCOMS("110000973"),
137   - COBPR("110000972"),
138   - ASTEG_DIDES("110000971"),
139   - DIOPE("110000970"),
140   - GPLAN("110000969"),
141   - DIRAD_DIDES("110000968"),
142   - SEGER("110000967"),
143   - DICOL("110000965"),
144   - COPAL("110000964"),
145   - COTRANS("110000963"),
146   - GEASI("110000962"),
147   - COGEC("110000961"),
148   - COLIC("110000960"),
149   - GECOL("110000959"),
150   - CCONT("110000958"),
151   - CODOF("110000957"),
152   - COARR("110000956"),
153   - GEFIN("110000955"),
154   - CAD_DF("110000954"),
155   - CAD_SP("110000953"),
156   - GGAFI("110000952"),
157   - COSAQ("110000951"),
158   - CODPT("110000950"),
159   - COCAD("110000949"),
160   - CODAP("110000948"),
161   - GERH("110000947"),
162   - COGEP("110000946"),
163   - CPROJ("110000945"),
164   - CPESC("110000944"),
165   - GEQIN("110000943"),
166   - CPROC("110000942"),
167   - ASSISS("110000941"),
168   - CODOB("110000938"),
169   - GEDOC("110000937"),
170   - GGAPI("110000936"),
171   - COSIT("110000935"),
172   - COSAP("110000934"),
173   - GGISS("110000933"),
174   - DIDES("110000834"),
175   - GLOBAL("110000833");
  11 + DESCONHECIDA("0000");
176 12  
177 13 private String codigo;
178 14  
... ...
src/main/java/br/gov/ans/sei/utils/SeiHelper.java
... ... @@ -2,59 +2,74 @@ package br.gov.ans.sei.utils;
2 2  
3 3 import java.io.File;
4 4 import java.io.FileInputStream;
  5 +import java.security.MessageDigest;
5 6 import java.security.NoSuchAlgorithmException;
6 7  
7 8 import org.apache.commons.codec.binary.Base64;
8 9  
9   -import br.gov.ans.commons.security.crypt.HashUtils;
10   -
11 10 public class SeiHelper {
12 11  
13 12 /**
14 13 * Calcula o hash utilizando o algoritimo SHA-256.
15   - *
16   - * @param conteudo entrada da qual será gerado o hash.
  14 + *
  15 + * @param conteudo
  16 + * entrada da qual será gerado o hash.
17 17 *
18 18 * @return resultado do calculo do hash.
19   - *
  19 + *
20 20 * @throws NoSuchAlgorithmException
21 21 *
22 22 */
23   - public static String calcularHash(String conteudo) throws NoSuchAlgorithmException{
24   - return HashUtils.toSHA256(conteudo, null);
  23 + public static String calcularHash(String conteudo) throws NoSuchAlgorithmException {
  24 + MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
  25 +
  26 + byte[] inputBytes = conteudo.getBytes();
  27 + byte[] inputHash = sha256.digest(inputBytes);
  28 + StringBuilder sb = new StringBuilder();
  29 +
  30 + for (int i = 0; i < inputHash.length; i++) {
  31 + sb.append(Integer.toString((inputHash[i] & 0xff) + 0x100, 16).substring(1));
  32 + }
  33 +
  34 + String generatedHash = sb.toString();
  35 +
  36 + return generatedHash;
25 37 }
26   -
  38 +
27 39 /**
28 40 * Codifica entrada para Base64.
29   - *
30   - * @param bytes Array de bytes que será codificado.
  41 + *
  42 + * @param bytes
  43 + * Array de bytes que será codificado.
31 44 *
32 45 * @return resultado da conversão dos bytes.
33   - *
  46 + *
34 47 * @throws NoSuchAlgorithmException
35 48 *
36 49 */
37   - public static String getBase64(byte[] bytes){
  50 + public static String getBase64(byte[] bytes) {
38 51 return Base64.encodeBase64String(bytes);
39 52 }
40   -
  53 +
41 54 /**
42 55 * Codifica entrada para Base64.
43   - *
44   - * @param arquivo File que será codificado.
  56 + *
  57 + * @param arquivo
  58 + * File que será codificado.
45 59 *
46 60 * @return resultado da conversão dos bytes do arquivo.
47   - *
  61 + *
48 62 * @throws NoSuchAlgorithmException
49 63 *
50 64 */
51   - public static String getBase64(File arquivo) throws Exception{
52   - byte[] bytes = new byte[(int) arquivo.length()];
53   -
54   - FileInputStream fileInputStream = new FileInputStream(arquivo);
  65 + public static String getBase64(File arquivo) throws Exception {
  66 + byte[] bytes = new byte[(int) arquivo.length()];
  67 +
  68 + FileInputStream fileInputStream = new FileInputStream(arquivo);
55 69 fileInputStream.read(bytes);
56 70 fileInputStream.close();
57   -
  71 +
58 72 return getBase64(bytes);
59 73 }
  74 +
60 75 }
... ...