io.vertx.ext.auth.PRNG Java Examples

The following examples show how to use io.vertx.ext.auth.PRNG. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtendedSessionUT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test
public void extendeSessionShouldBeClusterSerializable() throws InterruptedException {
    Vertx vertx = Vertx.vertx();
    SharedDataSessionImpl delegate = new SharedDataSessionImpl(new PRNG(vertx), 3000, SessionStore.DEFAULT_SESSIONID_LENGTH);
    ExtendedSession extendedSession = ExtendedSession.adapt(delegate);
    assertThat(extendedSession).isInstanceOf(ClusterSerializable.class);
    long createdAt = extendedSession.createdAt();
    extendedSession.put("key1", "value");
    extendedSession.put("key2", 20);
    Thread.sleep(300);

    Buffer buffer = Buffer.buffer();
    ((ClusterSerializable) extendedSession).writeToBuffer(buffer);
    assertThat(buffer.length() > 0);

    ExtendedSession fromBuffer = ExtendedSession.adapt(
        new SharedDataSessionImpl(new PRNG(vertx), 0, SessionStore.DEFAULT_SESSIONID_LENGTH)
    );
    ((ClusterSerializable) fromBuffer).readFromBuffer(0, buffer);
    assertThat(fromBuffer.createdAt()).isEqualTo(createdAt);
    assertThat(fromBuffer.id()).isEqualTo(delegate.id());
    assertThat(fromBuffer.timeout()).isEqualTo(delegate.timeout());
    assertThat(fromBuffer.data()).isEqualTo(delegate.data());

}
 
Example #2
Source File: ExtendedSessionUT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test
public void extendeSessionShouldBeClusterSerializable() throws InterruptedException {
    Vertx vertx = Vertx.vertx();
    SharedDataSessionImpl delegate = new SharedDataSessionImpl(new PRNG(vertx), 3000, SessionStore.DEFAULT_SESSIONID_LENGTH);
    ExtendedSession extendedSession = ExtendedSession.adapt(delegate);
    assertThat(extendedSession).isInstanceOf(ClusterSerializable.class);
    long createdAt = extendedSession.createdAt();
    extendedSession.put("key1", "value");
    extendedSession.put("key2", 20);
    Thread.sleep(300);

    Buffer buffer = Buffer.buffer();
    ((ClusterSerializable) extendedSession).writeToBuffer(buffer);
    assertThat(buffer.length() > 0);

    ExtendedSession fromBuffer = ExtendedSession.adapt(
        new SharedDataSessionImpl(new PRNG(vertx), 0, SessionStore.DEFAULT_SESSIONID_LENGTH)
    );
    ((ClusterSerializable) fromBuffer).readFromBuffer(0, buffer);
    assertThat(fromBuffer.createdAt()).isEqualTo(createdAt);
    assertThat(fromBuffer.id()).isEqualTo(delegate.id());
    assertThat(fromBuffer.timeout()).isEqualTo(delegate.timeout());
    assertThat(fromBuffer.data()).isEqualTo(delegate.data());

}
 
Example #3
Source File: SMTPConnectionPool.java    From vertx-mail-client with Apache License 2.0 6 votes vote down vote up
SMTPConnectionPool(Vertx vertx, MailConfig config) {
  this.config = config;
  maxSockets = config.getMaxPoolSize();
  keepAlive = config.isKeepAlive();
  this.prng = new PRNG(vertx);
  this.authOperationFactory = new AuthOperationFactory(prng);

  // If the hostname verification isn't set yet, but we are configured to use SSL, update that now
  String verification = config.getHostnameVerificationAlgorithm();
  if ((verification == null || verification.isEmpty()) && !config.isTrustAll() &&
      (config.isSsl() || config.getStarttls() != StartTLSOptions.DISABLED)) {
    // we can use HTTPS verification, which matches the requirements for SMTPS
    config.setHostnameVerificationAlgorithm("HTTPS");
  }

  netClient = vertx.createNetClient(config);
}
 
Example #4
Source File: WebAuthnImpl.java    From vertx-auth with Apache License 2.0 6 votes vote down vote up
public WebAuthnImpl(Vertx vertx, WebAuthnOptions options, CredentialStore store) {
  random = new PRNG(vertx);
  this.options = options;
  this.store = store;

  if (options == null || store == null) {
    throw new IllegalArgumentException("options and store cannot be null!");
  }

  ServiceLoader<Attestation> attestationServiceLoader = ServiceLoader.load(Attestation.class);

  for (Attestation att : attestationServiceLoader) {
    attestations.put(att.fmt(), att);
  }
  try {
    sha256 = MessageDigest.getInstance("SHA-256");
  } catch (NoSuchAlgorithmException nsae) {
    throw new IllegalStateException("SHA-256 is not available", nsae);
  }
}
 
Example #5
Source File: AuthDigest.java    From vertx-mail-client with Apache License 2.0 5 votes vote down vote up
protected AuthDigest(String name, PRNG random, String username, String password) {
  super(name, username, password);
  counter = 0;
  this.random = random;
  try {
    digest = MessageDigest.getInstance(NAME_MD_MAP.get(name));
  } catch (NoSuchAlgorithmException e) {
    throw new IllegalStateException("hash " + NAME_MD_MAP.get(name) + " not found", e);
  }
}
 
Example #6
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 4 votes vote down vote up
private ExtendedSession createSession(Vertx vertx) {
    return ExtendedSession.adapt(new SharedDataSessionImpl(new PRNG(vertx), 36000, DEFAULT_SESSIONID_LENGTH));
}
 
Example #7
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 4 votes vote down vote up
private ExtendedSession createSession(Vertx vertx) {
    return ExtendedSession.adapt(new SharedDataSessionImpl(new PRNG(vertx), 36000, DEFAULT_SESSIONID_LENGTH));
}
 
Example #8
Source File: AuthOperationFactory.java    From vertx-mail-client with Apache License 2.0 4 votes vote down vote up
public AuthOperationFactory(PRNG prng) {
  this.prng = prng;
}
 
Example #9
Source File: AbstractHashingStrategy.java    From vertx-auth with Apache License 2.0 4 votes vote down vote up
AbstractHashingStrategy(Vertx vertx) {
  random = new PRNG(vertx);
}