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 */ 016package com.revetsec.saml; 017 018import org.jspecify.annotations.NonNull; 019import javax.annotation.concurrent.Immutable; 020import java.net.URI; 021 022/** 023 * Result of preparing a signed outbound logout Redirect. 024 * 025 * @since 1.0.0 026 */ 027@Immutable 028public sealed interface SamlLogoutRedirectResult permits SamlLogoutRedirectResult.Prepared, 029 SamlLogoutRedirectResult.Rejected, SamlLogoutRedirectResult.Unavailable { 030 /** 031 * A browser Redirect with pending state to retain until the response. 032 * 033 * @since 1.0.0 034 */ 035 @Immutable 036 final class Prepared implements SamlLogoutRedirectResult { 037 private final @NonNull URI redirectUri; 038 private final @NonNull PendingSamlLogout pending; 039 Prepared(@NonNull URI redirectUri, @NonNull PendingSamlLogout pending) { 040 this.redirectUri = redirectUri; 041 this.pending = pending; 042 } 043 /** 044 * Returns the signed IdP Redirect. 045 * 046 * @return URI 047 * @since 1.0.0 048 */ 049 public @NonNull URI getRedirectUri() { return redirectUri; } 050 /** 051 * Returns pending logout state. 052 * 053 * @return pending state 054 * @since 1.0.0 055 */ 056 public @NonNull PendingSamlLogout getPendingLogout() { return pending; } 057 } 058 /** 059 * Session or connection configuration is incompatible. 060 * 061 * @since 1.0.0 062 */ 063 @Immutable 064 enum Rejected implements SamlLogoutRedirectResult { 065 /** No Redirect was prepared. */ CONFIGURATION 066 } 067 /** 068 * Randomness, clock or signing failed. 069 * 070 * @since 1.0.0 071 */ 072 @Immutable 073 enum Unavailable implements SamlLogoutRedirectResult { 074 /** No Redirect was prepared. */ INSTANCE 075 } 076}