use of javax.ws.rs.POST in project OpenAttestation by OpenAttestation.
the class RevokeTagCertificate method revokeCert.
@POST
public //@RequiresPermissions("tag_certificates:delete")
void revokeCert(@QueryParam("certId") String certId) {
log.debug("RPC: RevokeTagCertificate - Got request to revocation of certificate: {}", certId);
setCertificateId(UUID.valueOf(certId));
try (CertificateDAO dao = TagJdbi.certificateDao()) {
CertificateLocator locator = new CertificateLocator();
locator.id = certificateId;
Certificate obj = dao.findById(certificateId);
if (obj != null) {
// tries jvm properties, environment variables, then mtwilson.properties; you can set location of mtwilson.properties with -Dmtwilson.home=/path/to/dir
org.apache.commons.configuration.Configuration conf = ConfigurationUtil.getConfiguration();
ApiClient mtwilson = new ApiClient(conf);
log.debug("RPC: RevokeTagCertificate - Sha1 of the certificate about to be revoked is {}.", obj.getSha1());
dao.updateRevoked(certificateId, true);
AssetTagCertRevokeRequest request = new AssetTagCertRevokeRequest();
request.setSha1OfAssetCert(obj.getSha1().toByteArray());
mtwilson.revokeAssetTagCertificate(request);
//Global.mtwilson().revokeAssetTagCertificate(request);
log.info("RPC: RevokeTagCertificate - Certificate with id {} has been revoked successfully.");
} else {
log.error("RPC: RevokeTagCertificate - Certificate with id {} does not exist.", certificateId);
throw new RepositoryInvalidInputException(locator);
}
} catch (RepositoryException re) {
throw re;
} catch (Exception ex) {
log.error("RPC: RevokeTagCertificate - Error during certificate revocation.", ex);
throw new RepositoryException(ex);
}
}
use of javax.ws.rs.POST in project OpenAttestation by OpenAttestation.
the class AssetTagCert method importAssetTagCertificate.
/**
* This REST API would be called by the tag provisioning service whenever a new asset tag certificate is generated for a host.
* Initially we would stored this asset tag certificate in the DB without being mapped to any host. After the host is registered, then
* the asset tag certificate would be mapped to it.
* @param atagObj
* @return
*/
//@RolesAllowed({"AssetTagManagement"})
// @RequiresPermissions({"tag_certificates:create","hosts:search"})
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String importAssetTagCertificate(AssetTagCertCreateRequest atagObj) {
AssetTagCertBO object = new AssetTagCertBO();
boolean result = object.importAssetTagCertificate(atagObj, null);
return Boolean.toString(result);
}
use of javax.ws.rs.POST in project newts by OpenNMS.
the class MeasurementsResource method getMeasurements.
@POST
@Path("/{resource}")
@Timed
public Collection<Collection<MeasurementDTO>> getMeasurements(ResultDescriptorDTO descriptorDTO, @PathParam("resource") Resource resource, @QueryParam("start") Optional<TimestampParam> start, @QueryParam("end") Optional<TimestampParam> end, @QueryParam("resolution") Optional<DurationParam> resolution, @QueryParam("context") Optional<String> contextId) {
Optional<Timestamp> lower = Transform.toTimestamp(start);
Optional<Timestamp> upper = Transform.toTimestamp(end);
Optional<Duration> step = Transform.toDuration(resolution);
Context context = contextId.isPresent() ? new Context(contextId.get()) : Context.DEFAULT_CONTEXT;
LOG.debug("Retrieving measurements for resource {}, from {} to {} w/ resolution {} and w/ report {}", resource, lower, upper, step, descriptorDTO);
ResultDescriptor rDescriptor = Transform.resultDescriptor(descriptorDTO);
return Transform.measurementDTOs(m_repository.select(context, resource, lower, upper, rDescriptor, step));
}
use of javax.ws.rs.POST in project airpal by airbnb.
the class SessionResource method doLogin.
@POST
@Path("/login")
public void doLogin(@Context HttpServletRequest request, @Context HttpServletResponse response, @FormParam("username") String username, @FormParam("password") String password) throws IOException {
Subject currentUser = SecurityUtils.getSubject();
if (!currentUser.isAuthenticated()) {
AuthenticationToken token = new UsernamePasswordToken(username, password);
currentUser.login(token);
}
WebUtils.redirectToSavedRequest(request, response, "/app");
}
use of javax.ws.rs.POST in project javaee7-samples by javaee-samples.
the class MyResource method postOctetStream.
@POST
@Path("/upload")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.TEXT_PLAIN)
public Response postOctetStream(InputStream content) {
try (Reader reader = new InputStreamReader(content)) {
int totalsize = 0;
int count = 0;
final char[] buffer = new char[256];
while ((count = reader.read(buffer)) != -1) {
totalsize += count;
}
return Response.ok(totalsize).build();
} catch (IOException e) {
e.printStackTrace();
return Response.serverError().build();
}
}
Aggregations