/**
* Cadastra litersminute
*
* @param User
* @return Response
*/
@PermitAll
@POST
@Path("/")
@Consumes("application/json")
@Produces("application/json")
public Response insert(LitersMinute litersminute) {
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
builder.expires(new Date());
Timestamp date = new Timestamp(System.currentTimeMillis());
litersminute.setDate(date);
try {
AirConditioning air = AirConditioningDao.getInstance().getById(litersminute.getAirconditioning().getId());
if (air.getId().equals(null)) {
AirConditioningDao.getInstance().insertU(litersminute.getAirconditioning());
} else {
litersminute.setAirconditioning(air);
}
Long id = LitersMinuteDao.getInstance().insertU(litersminute);
litersminute.setId(id);
System.out.println(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(date.getTime()));
System.out.println(date.getTime());
builder.status(Response.Status.OK).entity(litersminute);
} catch (SQLException e) {
builder.status(Response.Status.INTERNAL_SERVER_ERROR);
}
return builder.build();
}
java类javax.annotation.security.PermitAll的实例源码
LitersMinuteController.java 文件源码
项目:Celebino
阅读 28
收藏 0
点赞 0
评论 0
LitersMinuteController.java 文件源码
项目:Celebino
阅读 30
收藏 0
点赞 0
评论 0
/**
* Return all lmin by air
*
* @return Response
*/
@PermitAll
@GET
@Path("/byair/{id}")
@Produces("application/json")
public Response getAirConditioningById(@PathParam("id") Long idAir) {
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
builder.expires(new Date());
try {
List<LitersMinute> lmin = LitersMinuteDao.getInstance().getByAirId(idAir);
if (lmin != null) {
builder.status(Response.Status.OK);
builder.entity(lmin);
} else {
builder.status(Response.Status.NOT_FOUND);
}
} catch (SQLException exception) {
builder.status(Response.Status.INTERNAL_SERVER_ERROR);
}
return builder.build();
}
JobResource.java 文件源码
项目:jobson
阅读 43
收藏 0
点赞 0
评论 0
@GET
@Path("/{job-id}/stderr")
@ApiOperation(
value = "Get the job's standard error",
notes = "Get the job's standard error, if available. A job that has not yet starrted will not have a standard error and, " +
"therefore, this method will return a 404. There is no guarantee that all running/finished jobs will have standard " +
"error data. This is because administrative and cleanup routines may dequeue a job's output in order to save space on " +
"the server.")
@Produces(DEFAULT_BINARY_MIME_TYPE)
@PermitAll
public Response fetchJobStderrById(
@Context
SecurityContext context,
@ApiParam(value = "ID of the job to get stderr for")
@PathParam("job-id")
@NotNull
JobId jobId) {
if (jobId == null)
throw new WebApplicationException("Job ID cannot be null", 400);
return generateBinaryDataResponse(jobId, jobDAO.getStderr(jobId));
}
GroupResource.java 文件源码
项目:outland
阅读 39
收藏 0
点赞 0
评论 0
@GET
@Path("/{group}")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
@Timed(name = "getByKey")
public Response getByKey(
@Auth AuthPrincipal authPrincipal,
@PathParam("group") String group
) throws AuthenticationException {
final long start = System.currentTimeMillis();
final Optional<Group> maybe = findGroup(group);
if (maybe.isPresent()) {
accessControlSupport.throwUnlessGrantedFor(authPrincipal, maybe.get());
return headers.enrich(Response.ok(maybe.get()), start).build();
}
return headers.enrich(Response.status(404).entity(
Problem.clientProblem(GroupResource.TITLE_NOT_FOUND, "", 404)), start).build();
}
GroupResource.java 文件源码
项目:outland
阅读 34
收藏 0
点赞 0
评论 0
@DELETE
@Path("/{group}/access/members/{member_key}")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
@Timed(name = "removeMember")
public Response removeMember(
@Auth AuthPrincipal authPrincipal,
@PathParam("group") String groupKey,
@PathParam("member_key") String memberKey
) throws AuthenticationException {
final long start = System.currentTimeMillis();
final Optional<Group> maybe = findGroup(groupKey);
if (maybe.isPresent()) {
final Group group = maybe.get();
accessControlSupport.throwUnlessGrantedFor(authPrincipal, group);
final Group updated = groupService.removeMemberAccess(group, memberKey);
return headers.enrich(Response.ok(updated), start).build();
}
return headers.enrich(Response.status(404).entity(
Problem.clientProblem(TITLE_NOT_FOUND, "", 404)), start).build();
}
SecurityRestServiceImpl.java 文件源码
项目:oasp-tutorial-sources
阅读 32
收藏 0
点赞 0
评论 0
/**
* Retrieves the CSRF token from the server session.
*
* @param request {@link HttpServletRequest} to retrieve the current session from
* @param response {@link HttpServletResponse} to send additional information
* @return the Spring Security {@link CsrfToken}
*/
@Produces(MediaType.APPLICATION_JSON)
@GET
@Path("/csrftoken/")
@PermitAll
public CsrfToken getCsrfToken(@Context HttpServletRequest request, @Context HttpServletResponse response) {
// return (CsrfToken) request.getSession().getAttribute(
// HttpSessionCsrfTokenRepository.class.getName().concat(".CSRF_TOKEN"));
CsrfToken token = this.csrfTokenRepository.loadToken(request);
if (token == null) {
LOG.warn("No CsrfToken could be found - instanciating a new Token");
token = this.csrfTokenRepository.generateToken(request);
this.csrfTokenRepository.saveToken(token, request, response);
}
return token;
}
GardenController.java 文件源码
项目:Celebino
阅读 34
收藏 0
点赞 0
评论 0
/**
* Cadastra o jardim
*
* @param User
* @return Response
*/
@PermitAll
@POST
@Path("/")
@Consumes("application/json")
@Produces("application/json")
public Response insert(Garden garden) {
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
builder.expires(new Date());
try {
Long id = (Long) GardenDao.getInstance().insertU(garden);
garden.setId(id);
builder.status(Response.Status.OK).entity(garden);
} catch (SQLException e) {
builder.status(Response.Status.INTERNAL_SERVER_ERROR);
}
return builder.build();
}
GardenController.java 文件源码
项目:Celebino
阅读 38
收藏 0
点赞 0
评论 0
/**
* retorna todos os jardins.
*
* @return Response
*/
@PermitAll
@GET
@Path("/")
@Produces("application/json")
public List<Garden> getAll() {
List<Garden> gardens = new ArrayList<Garden>();
try {
gardens = GardenDao.getInstance().getAll();
} catch (SQLException e) {
// TRATAR EXCECAO
}
return gardens;
}
UserController.java 文件源码
项目:Celebino
阅读 54
收藏 0
点赞 0
评论 0
/**
* Cadastra usuario
*
* @param User
* @return Response
*/
@PermitAll
@POST
@Path("/")
@Consumes("application/json")
@Produces("application/json")
public Response insert(User user) {
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
builder.expires(new Date());
try {
Long idUser = (long) UserDao.getInstance().insertU(user);
user.setId(idUser);
builder.status(Response.Status.OK).entity(user);
} catch (SQLException e) {
builder.status(Response.Status.INTERNAL_SERVER_ERROR);
}
return builder.build();
}
UserController.java 文件源码
项目:Celebino
阅读 36
收藏 0
点赞 0
评论 0
/**
* retorna todos os usuarios.
*
* @return Response
*/
@PermitAll
@GET
@Path("/")
@Produces("application/json")
public List<User> getAll() {
List<User> users = new ArrayList<User>();
try {
users = UserDao.getInstance().getAll();
} catch (SQLException e) {
// TRATAR EXCECAO
}
return users;
}
WateringController.java 文件源码
项目:Celebino
阅读 33
收藏 0
点赞 0
评论 0
/**
* retorna todos os waterings.
*
* @return Response
*/
@PermitAll
@GET
@Path("/")
@Produces("application/json")
public List<Watering> getAll() {
List<Watering> waterings = new ArrayList<Watering>();
try {
waterings = WateringDao.getInstance().getAll();
} catch (SQLException e) {
// TRATAR EXCECAO
}
return waterings;
}
GardenStatusController.java 文件源码
项目:Celebino
阅读 28
收藏 0
点赞 0
评论 0
/**
* retorna todos os gardenstatus.
*
* @return Response
*/
@PermitAll
@GET
@Path("/")
@Produces("application/json")
public List<GardenStatus> getAll() {
List<GardenStatus> gardenstatus = new ArrayList<GardenStatus>();
try {
gardenstatus = GardenStatusDao.getInstance().getAll();
} catch (SQLException e) {
// TRATAR EXCECAO
}
return gardenstatus;
}
AirConditioningController.java 文件源码
项目:Celebino
阅读 35
收藏 0
点赞 0
评论 0
/**
* Return all air.
*
* @return Response
*/
@PermitAll
@GET
@Path("/")
@Produces("application/json")
public List<AirConditioning> getAll() {
List<AirConditioning> airConditionings = new ArrayList<>();
try {
airConditionings = AirConditioningDao.getInstance().getAll();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return airConditionings;
}
AirConditioningController.java 文件源码
项目:Celebino
阅读 36
收藏 0
点赞 0
评论 0
/**
* Return air by id
*
* @param id
* @return Response
*/
@PermitAll
@GET
@Path("/{id}")
@Produces("application/json")
public Response getAirConditioningById(@PathParam("id") Long idAirConditioning) {
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
builder.expires(new Date());
try {
AirConditioning air = AirConditioningDao.getInstance().getById(idAirConditioning);
if (air != null) {
builder.status(Response.Status.OK);
builder.entity(air);
} else {
builder.status(Response.Status.NOT_FOUND);
}
} catch (SQLException exception) {
builder.status(Response.Status.INTERNAL_SERVER_ERROR);
}
return builder.build();
}
LitersMinuteController.java 文件源码
项目:Celebino
阅读 30
收藏 0
点赞 0
评论 0
/**
* Return all lmin
*
* @return Response
*/
@PermitAll
@GET
@Path("/")
@Produces("application/json")
public List<LitersMinute> getAll() {
List<LitersMinute> lmin = new ArrayList<>();
try {
lmin = LitersMinuteDao.getInstance().getAll();
} catch (SQLException e) {
// TRATAR EXCECAO
}
return lmin;
}
JobResource.java 文件源码
项目:jobson
阅读 44
收藏 0
点赞 0
评论 0
@GET
@Path("{job-id}")
@ApiOperation(
value = "Get details of a job managed by the system.",
code = 200,
notes = "")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Job details found", response = APIJobDetails.class),
@ApiResponse(code = 404, message = "The job could not be found", response = APIErrorMessage.class),
@ApiResponse(code = 401, message = "Client not authorized to request job details", response = APIErrorMessage.class)
})
@PermitAll
public Optional<APIJobDetails> getJobDetailsById(
@Context
SecurityContext context,
@ApiParam(value = "The job's ID")
@PathParam("job-id")
@NotNull
JobId jobId) {
if (jobId == null)
throw new WebApplicationException("Job ID is null", 400);
return jobDAO.getJobDetailsById(jobId).map(this::toJobResponse);
}
JobResource.java 文件源码
项目:jobson
阅读 50
收藏 0
点赞 0
评论 0
@POST
@Path("/{job-id}/abort")
@ApiOperation(
value = "Abort a running job",
notes = "Abort a job, stopping it or removing it from the job execute. The job's status " +
"should immediately change to aborting. However, full job abortion is not guaranteed " +
"to be immediate. This is because the underlying job may take time to close gracefully " +
"or because the system itself has a short delay before forcibly killing the job outright.")
@PermitAll
public void abortJob(
@Context
SecurityContext context,
@ApiParam(value = "ID of the job to abort")
@PathParam("job-id")
@NotNull
JobId jobId) {
if (jobId == null)
throw new WebApplicationException("Job ID cannot be null", 400);
if (jobDAO.jobExists(jobId)) {
if (jobManagerActions.tryAbort(jobId)) return;
else throw new WebApplicationException("Job cannot be aborted", 400);
} else throw new WebApplicationException("Job cannot be found", 400);
}
JobResource.java 文件源码
项目:jobson
阅读 43
收藏 0
点赞 0
评论 0
@GET
@Path("/{job-id}/stdout")
@ApiOperation(
value = "Get a job's standard output",
notes = "Get a job's standard output, if available. A job that has not yet started will not have a standard output and, " +
"therefore, this method will return a 404. There is no guarantee that all running/finished jobs will have standard output " +
"data. This is because administrative and cleanup routines may dequeue a job's output in order to save space on the server. ")
@Produces(DEFAULT_BINARY_MIME_TYPE)
@PermitAll
public Response fetchJobStdoutById(
@Context
SecurityContext context,
@ApiParam(value = "ID of the job to get stdout for")
@PathParam("job-id")
@NotNull
JobId jobId) {
if (jobId == null) throw new WebApplicationException("Job ID cannot be null", 400);
return generateBinaryDataResponse(jobId, jobDAO.getStdout(jobId));
}
JobResource.java 文件源码
项目:jobson
阅读 35
收藏 0
点赞 0
评论 0
@GET
@Path("/{job-id}/spec")
@ApiOperation(
value = "Get the spec the job was submitted against",
notes = "Get the spec the job was submitted against. Note: This returns the exact spec the job was submitted" +
" against. Any updates to the spec will not be reflected.")
@PermitAll
public Optional<APIJobSpec> fetchJobSpecJobWasSubmittedAgainst(
@Context
SecurityContext context,
@ApiParam(value = "ID of the job to get the spec for")
@PathParam("job-id")
@NotNull
JobId jobId) {
if (jobId == null)
throw new WebApplicationException("Job ID cannot be null", 400);
return jobDAO.getSpecJobWasSubmittedAgainst(jobId)
.map(APIJobSpec::fromJobSpec);
}
JobResource.java 文件源码
项目:jobson
阅读 40
收藏 0
点赞 0
评论 0
@GET
@Path("/{job-id}/inputs")
@ApiOperation(
value = "Get the job's inputs",
notes = "Get the inputs that were supplied when the job was submitted.")
@PermitAll
public Optional<Map<JobExpectedInputId, JsonNode>> fetchJobInputs(
@Context
SecurityContext context,
@ApiParam(value = "ID of the job to get inputs for")
@PathParam("job-id")
@NotNull
JobId jobId) {
if (jobId == null)
throw new WebApplicationException("Job ID cannot be null", 400);
return jobDAO.getJobInputs(jobId);
}
DelegateROCBean.java 文件源码
项目:jboss-eap7.1-playground
阅读 33
收藏 0
点赞 0
评论 0
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@PermitAll
@Override
public void checkTransactionBehaviour(boolean setLocalRollbackOnly, boolean throwLocalException, boolean setRemoteRollbackOnly, boolean throwRemoteException, boolean expectedToCommit) throws NamingException {
txRegistry.registerInterposedSynchronization(new TxSyncInterceptor(!expectedToCommit));
proxy.checkTransactionContext(setRemoteRollbackOnly, throwRemoteException, expectedToCommit);
if(setLocalRollbackOnly) {
context.setRollbackOnly();
log.warning("Rollback set!");
}
if(throwLocalException) {
throw new RuntimeException("Forced failure!");
}
log.info("Method done");
}
UserResource.java 文件源码
项目:traccar-service
阅读 33
收藏 0
点赞 0
评论 0
@Override
@PermitAll
@POST
public Response add(User entity) throws SQLException {
if (!Context.getPermissionsManager().getUserAdmin(getUserId())) {
Context.getPermissionsManager().checkUserUpdate(getUserId(), new User(), entity);
if (Context.getPermissionsManager().getUserManager(getUserId())) {
Context.getPermissionsManager().checkUserLimit(getUserId());
} else {
Context.getPermissionsManager().checkRegistration(getUserId());
entity.setDeviceLimit(Context.getConfig().getInteger("users.defaultDeviceLimit", -1));
int expirationDays = Context.getConfig().getInteger("users.defaultExpirationDays");
if (expirationDays > 0) {
entity.setExpirationTime(
new Date(System.currentTimeMillis() + (long) expirationDays * 24 * 3600 * 1000));
}
}
}
Context.getUsersManager().addItem(entity);
if (Context.getPermissionsManager().getUserManager(getUserId())) {
Context.getDataManager().linkObject(User.class, getUserId(), ManagedUser.class, entity.getId(), true);
}
Context.getUsersManager().refreshUserItems();
return Response.ok(entity).build();
}
InfoResource.java 文件源码
项目:task-app
阅读 29
收藏 0
点赞 0
评论 0
@GET
@Produces(MediaType.TEXT_PLAIN)
@PermitAll
@Path("/info")
public String info() {
StringBuilder sb = new StringBuilder();
sb.append("Task app client api v1 runnig.\n");
try {
sb.append("TMP DIR: ").append(taskDao.getAppProperty(AppProperty.TMP_DIR, "NOT SET")).append("\n");
sb.append("TIMEOUT: ").append(taskDao.getAppProperty(AppProperty.TIMEOUT, "NOT SET")).append("\n");
sb.append("DELETE FINISHED: ").append(taskDao.getAppProperty(AppProperty.DELETE_FINISHED, "NOT SET")).append("\n");
} catch (Exception e) {
sb.append(ThrowableUtil.createMessage(e));
}
return sb.toString();
}
SecurityAnnotationsViewAccessControl.java 文件源码
项目:holon-vaadin
阅读 33
收藏 0
点赞 0
评论 0
@Override
public boolean isAccessGranted(UI ui, String beanName) {
if (applicationContext.findAnnotationOnBean(beanName, DenyAll.class) != null) {
// DenyAll (no authentication required)
return false;
}
if (applicationContext.findAnnotationOnBean(beanName, PermitAll.class) != null) {
// PermitAll (no authentication required)
return true;
}
// RolesAllowed - authentication required
RolesAllowed ra = applicationContext.findAnnotationOnBean(beanName, RolesAllowed.class);
if (ra != null) {
// check authentication
final AuthContext authContext = AuthContext.getCurrent()
.orElseThrow(() -> new IllegalStateException("No AuthContext available as Context resource: "
+ "failed to validate RolesAllowed security annotation on View bean name [" + beanName
+ "]"));
if (!authContext.getAuthentication().isPresent()) {
// not authenticated
return false;
}
// check permissions
if (ra.value().length > 0) {
// for empty roles names, no role is required, only authentication
if (!authContext.isPermittedAny(ra.value())) {
// no roles matches (with ANY semantic)
return false;
}
}
}
return true;
}
RemoteTokenResource.java 文件源码
项目:minebox
阅读 33
收藏 0
点赞 0
评论 0
@GET
@Path("/getMetadataToken")
@Produces("text/plain")
@PermitAll
public Response getMetadataToken() {
final Optional<String> token = remoteTokenService.getToken();
if (token.isPresent()) {
return Response.ok(token).build();
} else {
return Response.status(Response.Status.SERVICE_UNAVAILABLE).entity("unable to get token").build();
}
}
SerialNoResource.java 文件源码
项目:minebox
阅读 29
收藏 0
点赞 0
评论 0
@GET
@Produces("text/plain")
@PermitAll
public Response getSerialNumber() {
final ListenableFuture<String> masterPassword = encyptionKeyProvider.getMasterPassword();
if (!masterPassword.isDone()) {
return Response.status(Response.Status.PRECONDITION_FAILED)
.entity("Key is not set yet..")
.build();
}
return Response
.ok(serialNumberService.getPublicIdentifier())
.build();
}
SerialNoResource.java 文件源码
项目:tools
阅读 26
收藏 0
点赞 0
评论 0
@GET
@Produces("text/plain")
@PermitAll
public Response getSerialNumber() {
final ListenableFuture<String> masterPassword = encyptionKeyProvider.getMasterPassword();
if (!masterPassword.isDone()) {
return Response.status(Response.Status.PRECONDITION_FAILED)
.entity("Key is not set yet..")
.build();
}
return Response
.ok(serialNumberService.getPublicIdentifier())
.build();
}
StatusResource.java 文件源码
项目:minebox
阅读 37
收藏 0
点赞 0
评论 0
@GET
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
public Status getStatus() {
//todo extract to status service
final Status status = new Status();
status.hasEncryptionKey = encyptionKeyProvider.getMasterPassword().isDone();
if (!status.hasEncryptionKey) {
return status;
}
if (downloadFactory.hasDownloadService()) {
final DownloadService downloadService = downloadFactory.get();
status.connectedMetadata = downloadService.connectedMetadata();
if (!status.connectedMetadata) {
return status;
}
status.remoteMetadataDetected = downloadService.hasMetadata();
if (!status.remoteMetadataDetected) {
return status;
}
if (status.hasEncryptionKey) {
final File firstDir = new File(parentDirs.get(0), serialNumberService.getPublicIdentifier());
status.completedRestorePercent = downloadService.completedPercent(firstDir);
}
status.restoreRunning = status.completedRestorePercent < 100.0;
} else {
status.connectedMetadata = false;
status.hasEncryptionKey = false;
status.remoteMetadataDetected = false;
status.restoreRunning = false;
}
return status;
}
PauseResource.java 文件源码
项目:minebox
阅读 34
收藏 0
点赞 0
评论 0
@PUT
@ApiOperation(value = "causes the MineBD deamon to not flush files for 1.5 seconds. this is to avoid having nonequal .dat files with equal last-write date",
response = String.class)
@Produces("text/plain")
@PermitAll
public String pause() {
final Instant instant = mineboxExportProvider.get().blockFlushFor1500Millis();
return "Not flushing files until " + instant.atZone(ZoneId.systemDefault()).toString() + "\n";
}
LoggedInUserService.java 文件源码
项目:InComb
阅读 27
收藏 0
点赞 0
评论 0
/**
* Returns the currently logged in user from the current session
* @param con is injected automatically
* @return {@link UserModel}
*/
@GET
@PermitAll
public Response getLoggedInUser(@Context final Connection con) {
final User loggedIn = (User) getSessionAttribute(SESSIONATTR_LOGGEDIN);
if(loggedIn == null) {
throw new NotFoundException();
}
return ok(UserUtil.getModel(true, loggedIn, con));
}