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 producing SP metadata. Only generated metadata is publishable.
023 *
024 * @since 1.0.0
025 */
026@Immutable
027public sealed interface SamlServiceProviderMetadataResult permits
028        SamlServiceProviderMetadataResult.Generated, SamlServiceProviderMetadataResult.Rejected,
029        SamlServiceProviderMetadataResult.Unavailable {
030    /**
031     * Complete XML metadata from a configured signing credential.
032     *
033     * @since 1.0.0
034     */
035    @Immutable
036    final class Generated implements SamlServiceProviderMetadataResult {
037        private final @NonNull String xml;
038        Generated(@NonNull String xml) { this.xml = xml; }
039        /**
040         * Returns complete UTF-8 XML text for publication.
041         *
042         * @return metadata XML
043         * @since 1.0.0
044         */
045        public @NonNull String getXml() { return xml; }
046    }
047    /**
048     * The SP lacks a publishable signing credential or has unsupported features.
049     *
050     * @since 1.0.0
051     */
052    @Immutable
053    enum Rejected implements SamlServiceProviderMetadataResult {
054        /** No metadata was produced. */ CONFIGURATION
055    }
056    /**
057     * XML or certificate encoding was unavailable.
058     *
059     * @since 1.0.0
060     */
061    @Immutable
062    enum Unavailable implements SamlServiceProviderMetadataResult {
063        /** No metadata was produced. */ INSTANCE
064    }
065}