use of com.auth0.json.mgmt.users.User in project neubbs by nuitcoder.
the class SecretUtil method decryptUserInfoToken.
/**
* 解密用户信息 Token
* - 解密 JWT 生成的用户信息 Token, 获取 UserDO 对象
*
* @param token 密文 token
* @return UserDO 用户信息对象(包含 id,name,rank,state 属性)
*/
public static UserDO decryptUserInfoToken(String token) {
checkParamNotNull(token);
DecodedJWT decodedJWT;
try {
// decrypt HS256
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(SetConst.JWT_TOKEN_SECRET_KEY)).build();
// decoding Base64
decodedJWT = verifier.verify(token);
} catch (UnsupportedEncodingException | TokenExpiredException e) {
throw new UtilClassException(ApiMessage.UNKNOWN_ERROR).log(LogWarnEnum.UC10);
}
// Get User information(id, name, rank ,state)
UserDO user = new UserDO();
user.setId(decodedJWT.getClaim(ParamConst.ID).asInt());
user.setName(decodedJWT.getClaim(ParamConst.NAME).asString());
user.setRank(decodedJWT.getClaim(ParamConst.RANK).asString());
user.setState(decodedJWT.getClaim(ParamConst.STATE).asInt());
return user;
}
use of com.auth0.json.mgmt.users.User in project gravitee-management-rest-api by gravitee-io.
the class UserServiceImpl method findByIds.
@Override
public Set<UserEntity> findByIds(List<String> ids) {
try {
LOGGER.debug("Find users by ID: {}", ids);
Set<User> users = userRepository.findByIds(ids);
if (!users.isEmpty()) {
return users.stream().map(u -> this.convert(u, false)).collect(Collectors.toSet());
}
Optional<String> idsAsString = ids.stream().reduce((a, b) -> a + '/' + b);
if (idsAsString.isPresent()) {
throw new UserNotFoundException(idsAsString.get());
} else {
throw new UserNotFoundException("?");
}
} catch (TechnicalException ex) {
Optional<String> idsAsString = ids.stream().reduce((a, b) -> a + '/' + b);
LOGGER.error("An error occurs while trying to find users using their ID {}", idsAsString, ex);
throw new TechnicalManagementException("An error occurs while trying to find users using their ID " + idsAsString, ex);
}
}
use of com.auth0.json.mgmt.users.User in project nextprot-api by calipho-sib.
the class NextprotAuth0EndpointImpl method fetchUser.
@Cacheable("user-auth")
public Auth0User fetchUser(String accessToken) throws IOException, JSONException {
Resty resty = new Resty();
String userInfoUri = getUserInfoUri(accessToken);
JSONResource json = resty.json(userInfoUri);
return new Auth0User(json.toObject());
}
use of com.auth0.json.mgmt.users.User in project survey by markoniemi.
the class JwtTokenTest method verifyTokenWithExpiredToken.
@Test
public void verifyTokenWithExpiredToken() {
try {
User user = new User("username", "password", "email", Role.ROLE_USER);
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("username", user.getUsername());
JwtToken token = new JwtToken(payload, 1);
Thread.sleep(1000);
token.verifyToken();
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(e instanceof JWTExpiredException);
}
}
use of com.auth0.json.mgmt.users.User in project chefly_android by chef-ly.
the class MainActivity method socialLogin.
private void socialLogin(String connection) {
// getString(R.string.auth0_domain
Auth0 auth0 = new Auth0(getString(R.string.auth0_client_id), getString(R.string.auth0_domain));
WebAuthProvider.init(auth0).withConnection(connection).start(MainActivity.this, new AuthCallback() {
@Override
public void onFailure(@NonNull Dialog dialog) {
dialog.show();
}
@Override
public void onFailure(final AuthenticationException exception) {
// Show error to the user
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "LOGIN FAIL");
String errorMsg = "Sign in request failed";
showToast(errorMsg);
}
});
}
@Override
public void onSuccess(@NonNull Credentials credentials) {
// Navigate to your next activity
startRecipeListActivity("aaa");
}
});
}
Aggregations