/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2016 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.wildfly.security.http;

import static org.wildfly.security._private.ElytronMessages.log;

/**
 * An attachment scope for use by an authentication mechanism, different scopes may be available to share Objects e.g.
 * Application, Session, Connection.
 *
 * @author <a href="mailto:darran.lofthouse@jboss.com">Darran Lofthouse</a>
 */
public interface HttpScope {

    // TODO - Lazy HTTP session creation.

    /**
     * Get the ID of this scope or (@code null} if IDs are not supported for this scope.
     *
     * @return the ID of this scope or (@code null} if IDs are not supported for this scope.
     */
    default String getID() {
        return null;
    }

    /**
     * Does this scope support attachments?
     *
     * @return {@code true} if this scope supports attachments, {@code false} otherwise}
     */
    default boolean supportsAttachments() {
        return false;
    }

    /**
     * Set the named attribute on this scope, setting to {@code null} will clear any value previously set for this key.
     *
     * @param key the key to use to store the attachment.
     * @param value the value to store with the key or {@code null} to clear any previously stored attachment.
     * @throws UnsupportedOperationException if attachments are not supported.
     */
    default void setAttachment(final String key, final Object value) {
        throw log.noAttachmentSupport();
    }

    /**
     * Get the attachment previously associated with the key specified on this scope.
     *
     * @param key the key used to store the attachment on this scope.
     * @return the value associated with the scope or {@code null} if no association exists.
     * @throws UnsupportedOperationException if attachments are not supported.
     */
    default Object getAttachment(final String key) {
        throw log.noAttachmentSupport();
    }

    /**
     * Is invalidation supported for this scope?
     *
     * @return {@code true} if this scope supports invalidation, {@code false} otherwise.
     */
    default boolean supportsInvalidation() {
        return false;
    }

    /**
     * Invalidate this scope.
     *
     * @return {@code true} if invalidation was successful, {@code false} otherwise.
     */
    default boolean invalidate() {
        return false;
    }

}

@@ -802,16 +802,45 @@
 s.log;%0A%0A
+import java.io.InputStream;%0A%0A
 /**%0A * A
@@ -3038,10 +3038,634 @@
 %0A    %7D%0A%0A
+    /**%0A     * Does this scope support access to scope specific resources?%0A     *%0A     * @return %7B@code true%7D if this scope supports access to scope specific resources, %7B@code false%7D otherwise.%0A     */%0A    default boolean supportsResources() %7B%0A        return false;%0A    %7D%0A%0A    /**%0A     * Get the resource associated with the path specified.%0A     *%0A     * @param path the path to the resource.%0A     * @return the %7B@link InputStream%7D of the resource or %7B@code null%7D if resources not supported or the specified resource is not found.%0A     */%0A    default InputStream getResource(final String path) %7B%0A        return null;%0A    %7D%0A%0A
 %7D%0A

Update the HttpScope API to support access to scope specific resources.