use of com.auth0.flickr2.domain.User in project javasrc by IanDarwin.
the class UserDBJDBC method setLoginDate.
/**
* Update the Last Login Date field.
*/
public synchronized void setLoginDate(String nick, java.util.Date date) throws SQLException {
// Find the user object
User u = getUser(nick);
// Change it in DB first; if this fails, the date in
// the in-memory copy won't be changed either.
// Have to convert from java.util.Date to java.sql.Date here.
// Would be more efficient to use java.sql.Date everywhere.
setLastLoginStmt.setDate(1, new java.sql.Date(date.getTime()));
setLastLoginStmt.setString(2, nick);
setLastLoginStmt.executeUpdate();
// Change it in-memory
u.setLastLoginDate(date);
}
use of com.auth0.flickr2.domain.User in project IginX by thulab.
the class UsersClientImpl method findUsers.
@Override
public List<User> findUsers() throws IginXException {
GetUserReq req = new GetUserReq(sessionId);
GetUserResp resp;
synchronized (iginXClient) {
iginXClient.checkIsClosed();
try {
resp = client.getUser(req);
RpcUtils.verifySuccess(resp.status);
} catch (TException | ExecutionException e) {
throw new IginXException("find users failure: ", e);
}
}
if (resp.usernames == null || resp.userTypes == null || resp.auths == null) {
return Collections.emptyList();
}
List<User> users = new ArrayList<>();
for (int i = 0; i < resp.usernames.size(); i++) {
String username = resp.usernames.get(i);
UserType userType = resp.userTypes.get(i);
Set<AuthType> auths = resp.auths.get(i);
users.add(new User(username, userType, auths));
}
return users;
}
use of com.auth0.flickr2.domain.User in project rhizome by geekbeast.
the class AuthenticationTest method testLoadUserInfo.
@Test
public void testLoadUserInfo() throws Auth0Exception {
String accessToken = accessTokens();
UserInfo userInfoRequest = client.userInfo(accessToken).execute();
Map<String, Object> d2 = userInfoRequest.getValues();
Assert.assertTrue(d2.containsKey("email"));
Assert.assertTrue(d2.containsKey("email_verified"));
Assert.assertTrue(d2.containsKey("nickname"));
Assert.assertTrue(d2.containsKey("picture"));
Assert.assertTrue(d2.containsKey("name"));
Assert.assertTrue(d2.containsKey("sub"));
Assert.assertTrue(d2.containsKey("updated_at"));
logger.info("User Info: {}", d2);
}
use of com.auth0.flickr2.domain.User in project bank-of-anthos by GoogleCloudPlatform.
the class LedgerMonolithController method getTransactions.
// BEGIN TRANSACTION HISTORY
/**
* Return a list of transactions for the specified account.
*
* The currently authenticated user must be allowed to access the account.
* @param bearerToken HTTP request 'Authorization' header
* @param accountId the account to get transactions for.
* @return a list of transactions for this account.
*/
@GetMapping("/transactions/{accountId}")
public ResponseEntity<?> getTransactions(@RequestHeader("Authorization") String bearerToken, @PathVariable String accountId) {
if (bearerToken != null && bearerToken.startsWith("Bearer ")) {
bearerToken = bearerToken.split("Bearer ")[1];
}
try {
DecodedJWT jwt = verifier.verify(bearerToken);
// Check that the authenticated user can access this account.
if (!accountId.equals(jwt.getClaim("acct").asString())) {
LOGGER.error("Failed to retrieve account transactions: " + "not authorized");
return new ResponseEntity<String>("not authorized", HttpStatus.UNAUTHORIZED);
}
// Load from cache
AccountInfo info = ledgerReaderCache.get(accountId);
Deque<Transaction> historyList = info.getTransactions();
// Set artificial extra latency.
LOGGER.debug("Setting artificial latency");
if (extraLatencyMillis != null) {
try {
Thread.sleep(extraLatencyMillis);
} catch (InterruptedException e) {
// Fake latency interrupted. Continue.
}
}
return new ResponseEntity<Collection<Transaction>>(historyList, HttpStatus.OK);
} catch (JWTVerificationException e) {
LOGGER.error("Failed to retrieve account transactions: " + "not authorized");
return new ResponseEntity<String>("not authorized", HttpStatus.UNAUTHORIZED);
} catch (ExecutionException | UncheckedExecutionException e) {
LOGGER.error("Cache error");
return new ResponseEntity<String>("cache error", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
use of com.auth0.flickr2.domain.User in project bank-of-anthos by GoogleCloudPlatform.
the class BalanceReaderController method getBalance.
/**
* Return the balance for the specified account.
*
* The currently authenticated user must be allowed to access the account.
*
* @param bearerToken HTTP request 'Authorization' header
* @param accountId the account to get the balance for
* @return the balance of the account
*/
@GetMapping("/balances/{accountId}")
public ResponseEntity<?> getBalance(@RequestHeader("Authorization") String bearerToken, @PathVariable String accountId) {
if (bearerToken != null && bearerToken.startsWith("Bearer ")) {
bearerToken = bearerToken.split("Bearer ")[1];
}
try {
DecodedJWT jwt = verifier.verify(bearerToken);
// Check that the authenticated user can access this account.
if (!accountId.equals(jwt.getClaim("acct").asString())) {
LOGGER.error("Failed to retrieve account balance: " + "not authorized");
return new ResponseEntity<String>("not authorized", HttpStatus.UNAUTHORIZED);
}
// Load from cache
Long balance = cache.get(accountId);
return new ResponseEntity<Long>(balance, HttpStatus.OK);
} catch (JWTVerificationException e) {
LOGGER.error("Failed to retrieve account balance: not authorized");
return new ResponseEntity<String>("not authorized", HttpStatus.UNAUTHORIZED);
} catch (ExecutionException | UncheckedExecutionException e) {
LOGGER.error("Cache error");
return new ResponseEntity<String>("cache error", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Aggregations