use of com.auth0.flickr2.domain.User in project auth0-java by auth0.
the class UsersEntityTest method shouldGetUserWithFields.
@Test
public void shouldGetUserWithFields() throws Exception {
UserFilter filter = new UserFilter().withFields("some,random,fields", true);
Request<User> request = api.users().get("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_USER, 200);
User response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("fields", "some,random,fields"));
assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.flickr2.domain.User in project auth0-java by auth0.
the class EmailVerificationTicketTest method shouldSerializeWithIdentity.
@Test
public void shouldSerializeWithIdentity() throws Exception {
EmailVerificationTicket ticket = new EmailVerificationTicket("usr123");
ticket.setResultUrl("https://page.auth0.com/result");
ticket.setTTLSeconds(36000);
EmailVerificationIdentity identity = new EmailVerificationIdentity("some-provider", "some-user-id");
ticket.setIdentity(identity);
String serialized = toJSON(ticket);
assertThat(serialized, is(notNullValue()));
assertThat(serialized, JsonMatcher.hasEntry("user_id", "usr123"));
assertThat(serialized, JsonMatcher.hasEntry("result_url", "https://page.auth0.com/result"));
assertThat(serialized, JsonMatcher.hasEntry("ttl_sec", 36000));
Map<String, String> identityMap = new HashMap<>();
identityMap.put("provider", "some-provider");
identityMap.put("user_id", "some-user-id");
assertThat(serialized, JsonMatcher.hasEntry("identity", identityMap));
}
use of com.auth0.flickr2.domain.User in project auth0-java by auth0.
the class JobErrorDetailsTest method shouldSerialize.
@Test
public void shouldSerialize() throws JsonProcessingException {
User user = new User();
user.setEmail("john.doe@gmail.com");
JobError error = new JobError("code", "message", "path");
JobErrorDetails errorDetails = new JobErrorDetails(user, Collections.singletonList(error));
String serialized = toJSON(errorDetails);
assertThat(serialized, is(equalTo(json)));
}
use of com.auth0.flickr2.domain.User in project CSKY by SHU-Silence.
the class UserServiceImpl method createToken.
private String createToken(User user) {
UserVo userVo = new UserVo();
BeanUtils.copyProperties(user, userVo);
Algorithm algorithm = Algorithm.HMAC256(user.getPassword());
Date nowDate = new Date();
Date expireDate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000);
return JWT.create().withIssuedAt(// 设置 载荷 生成签名的时间
nowDate).withExpiresAt(// 设置 载荷 签名过期的时间
expireDate).withAudience(JSON.toJSONString(userVo), user.getUsername()).sign(// 签名 Signature
algorithm);
}
use of com.auth0.flickr2.domain.User in project conquery by bakdata.
the class ConqueryTokenRealm method doGetAuthenticationInfo.
@Override
public ConqueryAuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
if (!(TOKEN_CLASS.isAssignableFrom(token.getClass()))) {
log.trace("Incompatible token. Expected {}, got {}", TOKEN_CLASS, token.getClass());
return null;
}
log.trace("Token has expected format: {}\tWas: {} ", TOKEN_CLASS, token.getClass());
DecodedJWT decodedToken = null;
try {
decodedToken = jwtConfig.getTokenVerifier(this).verify((String) token.getCredentials());
} catch (TokenExpiredException e) {
log.trace("The provided token is expired.");
throw new ExpiredCredentialsException(e);
} catch (SignatureVerificationException | InvalidClaimException e) {
log.trace("The provided token was not successfully verified against its signature or claims.");
throw new IncorrectCredentialsException(e);
} catch (JWTVerificationException e) {
log.trace("The provided token could not be verified.", e);
throw new AuthenticationException(e);
} catch (Exception e) {
log.trace("Unable to decode token", e);
throw new AuthenticationException(e);
}
log.trace("Received valid token.");
String username = decodedToken.getSubject();
UserId userId = UserId.Parser.INSTANCE.parse(username);
final User user = getUserOrThrowUnknownAccount(storage, userId);
return new ConqueryAuthenticationInfo(user, token, this, true);
}
Aggregations