|
|
|
@ -1,12 +1,7 @@ |
|
|
|
package api.menu.playa.helper; |
|
|
|
package api.menu.playa.helper; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
import java.security.Key; |
|
|
|
import java.security.Key; |
|
|
|
import java.security.KeyFactory; |
|
|
|
|
|
|
|
import java.security.PrivateKey; |
|
|
|
|
|
|
|
import java.security.spec.PKCS8EncodedKeySpec; |
|
|
|
|
|
|
|
import java.util.Base64; |
|
|
|
import java.util.Base64; |
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
@ -16,23 +11,15 @@ import javax.crypto.spec.SecretKeySpec; |
|
|
|
import javax.enterprise.context.ApplicationScoped; |
|
|
|
import javax.enterprise.context.ApplicationScoped; |
|
|
|
import javax.inject.Inject; |
|
|
|
import javax.inject.Inject; |
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.microprofile.jwt.Claims; |
|
|
|
|
|
|
|
import org.eclipse.microprofile.jwt.JsonWebToken; |
|
|
|
|
|
|
|
import org.jboss.logging.Logger; |
|
|
|
import org.jboss.logging.Logger; |
|
|
|
import org.jose4j.jwk.JsonWebKey; |
|
|
|
|
|
|
|
import org.jose4j.jws.JsonWebSignature; |
|
|
|
|
|
|
|
import org.jose4j.keys.resolvers.JwksVerificationKeyResolver; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import api.menu.playa.dao.UsuarioDAO; |
|
|
|
import api.menu.playa.dao.UsuarioDAO; |
|
|
|
import api.menu.playa.enums.RolesEnum; |
|
|
|
import api.menu.playa.enums.RolesEnum; |
|
|
|
import api.menu.playa.exceptions.NegocioException; |
|
|
|
import api.menu.playa.exceptions.NegocioException; |
|
|
|
import api.menu.playa.model.Usuario; |
|
|
|
import api.menu.playa.model.Usuario; |
|
|
|
import api.menu.playa.util.TokenUtils; |
|
|
|
|
|
|
|
import api.menu.playa.vo.RegistroVO; |
|
|
|
import api.menu.playa.vo.RegistroVO; |
|
|
|
import api.menu.playa.vo.UsuarioVO; |
|
|
|
import api.menu.playa.vo.UsuarioVO; |
|
|
|
import io.smallrye.jwt.auth.principal.DefaultJWTParser; |
|
|
|
|
|
|
|
import io.smallrye.jwt.build.Jwt; |
|
|
|
import io.smallrye.jwt.build.Jwt; |
|
|
|
import io.smallrye.jwt.build.JwtSignature; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApplicationScoped |
|
|
|
@ApplicationScoped |
|
|
|
public class LoginHelper { |
|
|
|
public class LoginHelper { |
|
|
|
@ -112,7 +99,7 @@ public class LoginHelper { |
|
|
|
return Base64.getEncoder().encodeToString(encrypted); |
|
|
|
return Base64.getEncoder().encodeToString(encrypted); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String decrypt(String encrypted) throws Exception { |
|
|
|
/* private static String decrypt(String encrypted) throws Exception { |
|
|
|
byte[] encryptedBytes = Base64.getDecoder().decode(encrypted.replace("\n", "")); |
|
|
|
byte[] encryptedBytes = Base64.getDecoder().decode(encrypted.replace("\n", "")); |
|
|
|
|
|
|
|
|
|
|
|
Key aesKey = new SecretKeySpec(ENCRYPT_KEY.getBytes(), "AES"); |
|
|
|
Key aesKey = new SecretKeySpec(ENCRYPT_KEY.getBytes(), "AES"); |
|
|
|
@ -123,7 +110,7 @@ public class LoginHelper { |
|
|
|
String decrypted = new String(cipher.doFinal(encryptedBytes)); |
|
|
|
String decrypted = new String(cipher.doFinal(encryptedBytes)); |
|
|
|
|
|
|
|
|
|
|
|
return decrypted; |
|
|
|
return decrypted; |
|
|
|
} |
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
public int currentTimeInSecs() { |
|
|
|
public int currentTimeInSecs() { |
|
|
|
long currentTimeMS = System.currentTimeMillis(); |
|
|
|
long currentTimeMS = System.currentTimeMillis(); |
|
|
|
|