001/*
002 * Copyright 2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.revetsec.totp;
018
019import org.jspecify.annotations.NonNull;
020import javax.annotation.concurrent.Immutable;
021import java.time.Instant;
022
023import static java.util.Objects.requireNonNull;
024
025/** Non-secret pending-enrollment information for reconciling an uncertain management operation.
026 * @since 1.0.0 */
027@Immutable
028public final class TotpPendingEnrollment {
029    private final @NonNull String enrollmentId;
030    private final @NonNull String factorId;
031    private final @NonNull Instant expiresAt;
032
033    TotpPendingEnrollment(@NonNull String enrollmentId, @NonNull String factorId, @NonNull Instant expiresAt) {
034        this.enrollmentId = requireNonNull(enrollmentId);
035        this.factorId = requireNonNull(factorId);
036        this.expiresAt = requireNonNull(expiresAt);
037    }
038
039    /** The pending enrollment identifier.
040     * @return enrollmentId
041     * @since 1.0.0 */
042    public @NonNull String getEnrollmentId() { return this.enrollmentId; }
043
044    /** The candidate factor generation identifier.
045     * @return factorId
046     * @since 1.0.0 */
047    public @NonNull String getFactorId() { return this.factorId; }
048
049    /** The pending enrollment expiry.
050     * @return expiresAt
051     * @since 1.0.0 */
052    public @NonNull Instant getExpiresAt() { return this.expiresAt; }
053
054    /** Redacts all account, operation and secret data.
055     * @return a fixed description
056     * @since 1.0.0 */
057    @Override public @NonNull String toString() { return "TotpPendingEnrollment{<redacted>}"; }
058}