use of com.auth0.flickr2.domain.User in project engine by Lumeer.
the class UserAuth0Utils method renameUser.
public void renameUser(final String newUserName) throws Auth0Exception {
if (!initialized) {
init();
}
final String authId = authenticatedUser.getAuthUserInfo().user.getAuthIds().iterator().next();
refreshManagementApiToken();
final ManagementAPI mApi = new ManagementAPI(domain, managementApiToken);
final User user = new User();
user.setName(newUserName);
mApi.users().update(authId, user).execute();
}
use of com.auth0.flickr2.domain.User in project otus_java_basic by petrelevich.
the class Main method main.
public static void main(String[] args) {
AtomicBoolean executionFlag = new AtomicBoolean(true);
ConsoleIOService ioService = new ConsoleIOService();
UserService userService = new UserService();
EquationEvaluationResultHistoryHolder historyHolder = new EquationEvaluationResultHistoryHolder();
User user = userService.askUserName(ioService);
while (executionFlag.get()) {
String commandOrEquation = showPromptAndReadCommand(ioService);
if (!handleExitCommand(ioService, commandOrEquation, user.getFullName(), executionFlag)) {
if (!handleHistoryCommand(ioService, commandOrEquation, historyHolder)) {
handleEquationCommand(ioService, commandOrEquation, historyHolder);
}
}
}
}
use of com.auth0.flickr2.domain.User in project hopsworks by logicalclocks.
the class DownloadService method downloadFromHDFS.
@GET
@javax.ws.rs.Path("with_token/{path: .+}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@JWTNotRequired
@ApiOperation(value = "Download file.", response = StreamingOutput.class)
public Response downloadFromHDFS(@PathParam("path") String path, @QueryParam("token") String token, @QueryParam("type") DatasetType datasetType, @Context SecurityContext sc) throws DatasetException, SigningKeyNotFoundException, VerificationException, ProjectException {
if (!settings.isDownloadAllowed()) {
throw new DatasetException(RESTCodes.DatasetErrorCode.DOWNLOAD_NOT_ALLOWED, Level.FINEST);
}
Project project = this.getProject();
DatasetPath datasetPath = datasetHelper.getDatasetPathIfFileExist(project, path, datasetType);
String fullPath = datasetPath.getFullPath().toString();
DecodedJWT djwt = jWTHelper.verifyOneTimeToken(token, fullPath);
Users user = userFacade.findByUsername(djwt.getSubject());
Pair<Path, StreamingOutput> pathStreamPair = downloadFromHDFS(project, datasetPath, user);
Response.ResponseBuilder response = Response.ok(pathStreamPair.getValue1());
response.header("Content-disposition", "attachment; filename=\"" + pathStreamPair.getValue0().getName() + "\"");
return response.build();
}
use of com.auth0.flickr2.domain.User in project hopsworks by logicalclocks.
the class AirflowManager method monitorSecurityMaterial.
/**
* Timer bean to periodically (JWT expiration lee way / 2) (a) clean stale JWT and X.509 material for Airflow
* and (b) renew used JWTs.
*
* a. Iterate all the material in memory and clean those that don't have any entry in the database, project has been
* deleted or those that project exist but user does not own any non-paused DAG in Airflow.
*
* b. For a valid JWT, renew it if the time has come (after expiration time and before expiration + expLeeWay)
*
* @param timer
*/
@Lock(LockType.WRITE)
@AccessTimeout(value = 500)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Timeout
public void monitorSecurityMaterial(Timer timer) {
try {
LocalDateTime now = DateUtils.getNow();
// Clean unused token files and X.509 certificates
cleanStaleSecurityMaterial();
// Renew them
Set<AirflowJWT> newTokens2Add = new HashSet<>();
Iterator<AirflowJWT> airflowJWTIt = airflowJWTs.iterator();
while (airflowJWTIt.hasNext()) {
AirflowJWT airflowJWT = airflowJWTIt.next();
// If first does not need to be renewed, neither do the rest
if (airflowJWT.maybeRenew(now)) {
try {
LocalDateTime expirationDateTime = now.plus(settings.getJWTLifetimeMs(), ChronoUnit.MILLIS);
Date expirationDate = DateUtils.localDateTime2Date(expirationDateTime);
String token = jwtController.renewToken(airflowJWT.token, expirationDate, DateUtils.localDateTime2Date(DateUtils.getNow()), true, new HashMap<>(3));
AirflowJWT renewedJWT = new AirflowJWT(airflowJWT.username, airflowJWT.projectId, airflowJWT.projectName, expirationDateTime, airflowJWT.uid);
renewedJWT.tokenFile = airflowJWT.tokenFile;
renewedJWT.token = token;
airflowJWTIt.remove();
writeTokenToFile(renewedJWT);
newTokens2Add.add(renewedJWT);
} catch (JWTException ex) {
LOG.log(Level.WARNING, "Could not renew Airflow JWT for " + airflowJWT, ex);
} catch (IOException ex) {
LOG.log(Level.WARNING, "Could not write renewed Airflow JWT for " + airflowJWT, ex);
try {
jwtController.invalidate(airflowJWT.token);
} catch (InvalidationException iex) {
LOG.log(Level.FINE, "Could not invalidate Airflow JWT. SKipping...");
}
} catch (Exception ex) {
LOG.log(Level.SEVERE, "Generic error while renewing Airflow JWTs", ex);
}
} else {
break;
}
}
airflowJWTs.addAll(newTokens2Add);
} catch (Exception e) {
LOG.log(Level.SEVERE, "Got an exception while renewing/invalidating airflow jwt token", e);
}
}
use of com.auth0.flickr2.domain.User in project hopsworks by logicalclocks.
the class JWTHelper method getUserPrincipal.
/**
* Get the user from the request header Authorization field.
*
* @param req
* @return
*/
public Users getUserPrincipal(HttpServletRequest req) {
String jwt = getAuthToken(req);
DecodedJWT djwt = jwtController.decodeToken(jwt);
return djwt == null ? null : userFacade.findByUsername(djwt.getSubject());
}
Aggregations