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