001/*
002 * nimbus-jose-jwt
003 *
004 * Copyright 2012-2016, Connect2id Ltd.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
007 * this file except in compliance with the License. You may obtain a copy of the
008 * License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software distributed
013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
015 * specific language governing permissions and limitations under the License.
016 */
017
018package com.nimbusds.jose.util;
019
020
021import java.util.List;
022import java.util.Map;
023
024/**
025 * Retriever of resources specified by URL which permits setting of HTTP
026 * connect and read timeouts, size limit and headers.
027 */
028public interface RestrictedResourceRetriever extends ResourceRetriever {
029        
030
031        /**
032         * Gets the HTTP connect timeout.
033         *
034         * @return The HTTP connect timeout, in milliseconds, zero for
035         *         infinite.
036         */
037        int getConnectTimeout();
038
039
040        /**
041         * Sets the HTTP connect timeout.
042         *
043         * @param connectTimeoutMs The HTTP connect timeout, in milliseconds,
044         *                         zero for infinite. Must not be negative.
045         */
046        void setConnectTimeout(final int connectTimeoutMs);
047
048
049        /**
050         * Gets the HTTP read timeout.
051         *
052         * @return The HTTP read timeout, in milliseconds, zero for infinite.
053         */
054        int getReadTimeout();
055
056
057        /**
058         * Sets the HTTP read timeout.
059         *
060         * @param readTimeoutMs The HTTP read timeout, in milliseconds, zero
061         *                      for infinite. Must not be negative.
062         */
063        void setReadTimeout(final int readTimeoutMs);
064
065
066        /**
067         * Gets the HTTP entity size limit.
068         *
069         * @return The HTTP entity size limit, in bytes, zero for infinite.
070         */
071        int getSizeLimit();
072
073
074        /**
075         * Sets the HTTP entity size limit.
076         *
077         * @param sizeLimitBytes The HTTP entity size limit, in bytes, zero for
078         *                       infinite. Must not be negative.
079         */
080        void setSizeLimit(int sizeLimitBytes);
081
082        
083        /**
084         * Gets the headers to set for the HTTP request.
085         *
086         * @return The HTTP headers as name - values map, {@code null} if not
087         *         set.
088         */
089        Map<String, List<String>> getHeaders();
090
091        
092        /**
093         * Sets the headers to set for the HTTP request.
094         *
095         * @param headers The HTTP headers as name - values map, {@code null}
096         *                if none.
097         */
098        void setHeaders(final Map<String, List<String>> headers);
099}