All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vlingo.xoom.auth.infra.resource.UserData Maven / Gradle / Ivy

Go to download

The reactive, scalable, and resilient authentication and authorization service for VLINGO XOOM Platform components, and also suitable for hosted platform services and applications.

There is a newer version: 1.11.1
Show newest version
// Copyright © 2012-2021 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.

package io.vlingo.xoom.auth.infra.resource;

import java.util.List;

import io.vlingo.xoom.auth.model.User;

public final class UserData {
  public final boolean active;
  public final List credentials;
  public final ProfileData profile;
  public final String tenantId;
  public final String username;

  public static UserData from(final String tenantId, final String username, final ProfileData profile, final List credentials, final boolean active) {
    return new UserData(tenantId, username, profile, credentials, active);
  }

  public static UserData from(final User user) {
    return new UserData(
            user.tenantId().value,
            user.username(),
            ProfileData.from(user),
            CredentialData.from(user),
            user.isActive());
  }

  public CredentialData credentialOf(final String authority) {
    for (final CredentialData credential : credentials) {
      if (credential.authority.equals(authority)) {
        return credential;
      }
    }
    return null;
  }

  private UserData(final String tenantId, final String username, final ProfileData profile, final List credentials, final boolean active) {
    this.tenantId = tenantId;
    this.username = username;
    this.profile = profile;
    this.credentials = credentials;
    this.active = active;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy