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 locally parsing application-supplied IdP metadata. Parsing does not approve trust. 023 * 024 * @since 1.0.0 025 */ 026@Immutable 027public sealed interface SamlIdentityProviderMetadataResult permits 028 SamlIdentityProviderMetadataResult.Parsed, SamlIdentityProviderMetadataResult.Rejected, 029 SamlIdentityProviderMetadataResult.Unavailable { 030 /** 031 * One selected, structurally checked IdP descriptor. 032 * 033 * @since 1.0.0 034 */ 035 @Immutable 036 final class Parsed implements SamlIdentityProviderMetadataResult { 037 private final @NonNull SamlIdentityProviderMetadata metadata; 038 Parsed(@NonNull SamlIdentityProviderMetadata metadata) { this.metadata = metadata; } 039 /** 040 * Returns the checked metadata fields. 041 * 042 * @return metadata 043 * @since 1.0.0 044 */ 045 public @NonNull SamlIdentityProviderMetadata getMetadata() { return metadata; } 046 } 047 048 /** 049 * Input was malformed, expired or unsupported. 050 * 051 * @since 1.0.0 052 */ 053 @Immutable 054 enum Rejected implements SamlIdentityProviderMetadataResult { 055 /** No trusted metadata is returned. */ INSTANCE 056 } 057 058 /** 059 * The local parser or certificate provider was unavailable. 060 * 061 * @since 1.0.0 062 */ 063 @Immutable 064 enum Unavailable implements SamlIdentityProviderMetadataResult { 065 /** No trusted metadata is returned. */ INSTANCE 066 } 067}