io.vlingo.xoom.auth.infra.resource.MinimalUserData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xoom-auth Show documentation
Show all versions of xoom-auth Show documentation
The reactive, scalable, and resilient authentication and authorization service for VLINGO XOOM Platform
components, and also suitable for hosted platform services and applications.
// 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.Collection;
import java.util.HashSet;
import java.util.Set;
import io.vlingo.xoom.auth.model.User;
public final class MinimalUserData {
public final boolean active;
public final PersonNameData name;
public final String tenantId;
public final String username;
public static MinimalUserData from(final String tenantId, final String username, final PersonNameData name, final boolean active) {
return new MinimalUserData(tenantId, username, name, active);
}
public static MinimalUserData from(final User user) {
return new MinimalUserData(
user.tenantId().value,
user.username(),
PersonNameData.of(user.profile().name.given, user.profile().name.second, user.profile().name.family),
user.isActive());
}
public static Collection from(final Collection users) {
final Set userData = new HashSet<>();
for (final User user : users) {
userData.add(from(user));
}
return userData;
}
private MinimalUserData(final String tenantId, final String username, final PersonNameData name, final boolean active) {
this.tenantId = tenantId;
this.username = username;
this.name = name;
this.active = active;
}
}