congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
RegistrationAssertionHelper
Code IndexAdd Tabnine to your IDE (free)

How to use
RegistrationAssertionHelper
in
org.eclipse.hono.service.registration

Best Java code snippets using org.eclipse.hono.service.registration.RegistrationAssertionHelper (Showing top 7 results out of 315)

origin: org.eclipse.hono/hono-service-base

/**
 * Creates a registration assertion token for a device and wraps it in a JSON object.
 * <p>
 * The returned JSON object may also contain <em>default</em> values registered for the
 * device under key {@link RegistrationConstants#FIELD_DEFAULTS}.
 * 
 * @param tenantId The tenant the device belongs to.
 * @param deviceId The device to create the assertion token for.
 * @param registrationInfo The device's registration information.
 * @return The payload.
 */
protected final JsonObject getAssertionPayload(final String tenantId, final String deviceId, final JsonObject registrationInfo) {
  final JsonObject result = new JsonObject()
      .put(RegistrationConstants.FIELD_PAYLOAD_DEVICE_ID, deviceId)
      .put(RegistrationConstants.FIELD_ASSERTION, assertionFactory.getAssertion(tenantId, deviceId));
  final JsonObject defaults = registrationInfo.getJsonObject(RegistrationConstants.FIELD_DEFAULTS);
  if (defaults != null) {
    result.put(RegistrationConstants.FIELD_DEFAULTS, defaults);
  }
  return result;
}
origin: eclipse/hono

/**
 * Verifies that signatures created using an RSA private key can be validated using the corresponding public key.
 */
@Test
public void testForSigningWorksWithRsaSignatures() {
  final SignatureSupportingConfigProperties props = new SignatureSupportingConfigProperties();
  props.setKeyPath("target/certs/hono-messaging-key.pem");
  props.setCertPath("target/certs/hono-messaging-cert.pem");
  final RegistrationAssertionHelper factory = RegistrationAssertionHelperImpl.forSigning(vertx, props);
  final String assertion = factory.getAssertion("tenant", "device");
  assertNotNull(assertion);
  final RegistrationAssertionHelper validator = RegistrationAssertionHelperImpl.forValidating(vertx, props);
  assertTrue(validator.isValid(assertion, "tenant", "device"));
}
origin: eclipse/hono

      HttpURLConnection.HTTP_OK,
      getAssertionPayload(tenantId, deviceId, result.getPayload().getJsonObject(RegistrationConstants.FIELD_DATA)),
      CacheDirective.maxAgeDirective(assertionFactory.getAssertionLifetime()));
} else {
  TracingHelper.logError(span, "device not enabled");
origin: org.eclipse.hono/hono-service-base

/**
 * {@inheritDoc}
 * <p>
 * Subclasses may override this method in order to implement a more sophisticated approach for asserting registration status, e.g.
 * using cached information etc.
 * This method requires a functional {@link #getDevice(String, String, Handler) getDevice} method to work.
 */
@Override
public void assertRegistration(
    final String tenantId,
    final String deviceId,
    final Handler<AsyncResult<RegistrationResult>> resultHandler) {
  Objects.requireNonNull(tenantId);
  Objects.requireNonNull(deviceId);
  Objects.requireNonNull(resultHandler);
  final Future<RegistrationResult> getResultTracker = Future.future();
  getDevice(tenantId, deviceId, getResultTracker.completer());
  getResultTracker.map(result -> {
    if (isDeviceEnabled(result)) {
      return RegistrationResult.from(
          HttpURLConnection.HTTP_OK,
          getAssertionPayload(tenantId, deviceId, result.getPayload().getJsonObject(RegistrationConstants.FIELD_DATA)),
          CacheDirective.maxAgeDirective(assertionFactory.getAssertionLifetime()));
    } else {
      return RegistrationResult.from(HttpURLConnection.HTTP_NOT_FOUND);
    }
  }).setHandler(resultHandler);
}
origin: eclipse/hono

/**
 * Creates a registration assertion token for a device and wraps it in a JSON object.
 * <p>
 * The returned JSON object may also contain <em>default</em> values registered for the
 * device under key {@link RegistrationConstants#FIELD_DEFAULTS}.
 * 
 * @param tenantId The tenant the device belongs to.
 * @param deviceId The device to create the assertion token for.
 * @param registrationInfo The device's registration information.
 * @return The payload.
 */
protected final JsonObject getAssertionPayload(final String tenantId, final String deviceId, final JsonObject registrationInfo) {
  final JsonObject result = new JsonObject()
      .put(RegistrationConstants.FIELD_PAYLOAD_DEVICE_ID, deviceId)
      .put(RegistrationConstants.FIELD_ASSERTION, assertionFactory.getAssertion(tenantId, deviceId));
  final JsonObject defaults = registrationInfo.getJsonObject(RegistrationConstants.FIELD_DEFAULTS);
  if (defaults != null) {
    result.put(RegistrationConstants.FIELD_DEFAULTS, defaults);
  }
  return result;
}
origin: org.eclipse.hono/hono-service-base

    HttpURLConnection.HTTP_OK,
    getAssertionPayload(tenantId, deviceId, deviceData),
    CacheDirective.maxAgeDirective(assertionFactory.getAssertionLifetime())));
} else {
  return Future.succeededFuture(RegistrationResult.from(HttpURLConnection.HTTP_FORBIDDEN));
origin: eclipse/hono

    HttpURLConnection.HTTP_OK,
    getAssertionPayload(tenantId, deviceId, deviceData),
    CacheDirective.maxAgeDirective(assertionFactory.getAssertionLifetime())));
} else {
  TracingHelper.logError(span, "gateway not authorized");
org.eclipse.hono.service.registrationRegistrationAssertionHelper

Javadoc

A utility for creating and validating JWT tokens asserting the registration status of devices.

Most used methods

  • getAssertion
    Creates a signed assertion.
  • getAssertionLifetime
    Gets the lifetime of the assertions created by the getAssertion method.
  • isValid
    Checks if a given token asserts a particular device's registration status.

Popular in Java

  • Making http post requests using okhttp
  • findViewById (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getApplicationContext (Context)
  • Kernel (java.awt.image)
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Reference (javax.naming)
  • JFileChooser (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now