001/*
002 * nimbus-jose-jwt
003 *
004 * Copyright 2012-2019, 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.proc;
019
020
021/**
022 * JOSE processor configuration.
023 *
024 * <p>Specifies the required components to process secured JOSE objects:
025 *
026 * <ul>
027 *     <li>To verify JWS objects:
028 *         <ul>
029 *             <li>{@link #setJWSTypeVerifier Verifier} for the acceptable JWS
030 *                 header "typ" (type) parameters.
031 *             <li>{@link #setJWSKeySelector Key selector} to determine key
032 *                 candidate(s) for JWS verification based on the JWS header,
033 *                 payload and / or application-specific context information.
034 *             <li>{@link #setJWSVerifierFactory Factory} to construct a JWS
035 *                 verifier for a given key candidate and JWS header information.
036 *         </ul>
037 *     <li>To decrypt JWE objects:
038 *         <ul>
039 *             <li>{@link #setJWETypeVerifier Verifier} for the acceptable JWE
040 *                 header "typ" (type) parameters.
041 *             <li>{@link #setJWEKeySelector Key selector} to determine key
042 *                 candidate(s) for JWE decryption based on the JWE header and
043 *                 / or application-specific context information.
044 *             <li>{@link #setJWEDecrypterFactory Factory} to construct a JWE
045 *                 decrypter for a given key candidate and JWE header
046 *                 information.
047 *         </ul>
048 * </ul>
049 *
050 * @author Vladimir Dzhuvinov
051 * @version 2019-10-15
052 */
053public interface JOSEProcessorConfiguration <C extends SecurityContext> {
054        
055        
056        /**
057         * Gets the JWS header "typ" (type) parameter verifier. This verifier
058         * is also applied to plain (unsecured) JOSE objects. If none JWS
059         * and plain objects will be rejected.
060         *
061         * @return The JWS type verifier, {@code null} if not specified.
062         *
063         * @since 8.0
064         */
065        JOSEObjectTypeVerifier<C> getJWSTypeVerifier();
066        
067        
068        /**
069         * Sets the JWS header "typ" (type) parameter verifier. This verifier
070         * is also applied to plain (unsecured) JOSE objects. If none JWS and
071         * plain objects will be rejected.
072         *
073         * @param jwsTypeVerifier The JWS type verifier, {@code null} if not
074         *                        specified.
075         *
076         * @since 8.0
077         */
078        void setJWSTypeVerifier(final JOSEObjectTypeVerifier<C> jwsTypeVerifier);
079
080        
081        /**
082         * Gets the JWS key selector. If none JWS objects will be rejected.
083         *
084         * @return The JWS key selector, {@code null} if not specified.
085         */
086        JWSKeySelector<C> getJWSKeySelector();
087
088
089        /**
090         * Sets the JWS key selector. If none JWS objects will be rejected.
091         *
092         * @param jwsKeySelector The JWS key selector, {@code null} if not
093         *                       specified.
094         */
095        void setJWSKeySelector(final JWSKeySelector<C> jwsKeySelector);
096        
097        
098        /**
099         * Gets the JWE header "typ" (type) parameter verifier. If none JWE
100         * objects will be rejected.
101         *
102         * @return The JWE verifier, {@code null} if not specified.
103         *
104         * @since 8.0
105         */
106        JOSEObjectTypeVerifier<C> getJWETypeVerifier();
107        
108        
109        /**
110         * Sets the JWE header "typ" (type) parameter verifier. If none JWE
111         * objects will be rejected.
112         *
113         * @param jweTypeVerifier The JWE type verifier, {@code null} if not
114         *                        specified.
115         *
116         * @since 8.0
117         */
118        void setJWETypeVerifier(final JOSEObjectTypeVerifier<C> jweTypeVerifier);
119
120
121        /**
122         * Gets the JWE key selector. If none JWE objects will be rejected.
123         *
124         * @return The JWE key selector, {@code null} if not specified.
125         */
126        JWEKeySelector<C> getJWEKeySelector();
127
128
129        /**
130         * Sets the JWE key selector. If none JWE objects will be rejected.
131         *
132         * @param jweKeySelector The JWE key selector, {@code null} if not
133         *                       specified.
134         */
135        void setJWEKeySelector(final JWEKeySelector<C> jweKeySelector);
136
137
138        /**
139         * Gets the factory for creating JWS verifier instances. If none JWS
140         * objects will be rejected.
141         *
142         * @return The JWS verifier factory, {@code null} if not specified.
143         */
144        JWSVerifierFactory getJWSVerifierFactory();
145
146
147        /**
148         * Sets the factory for creating JWS verifier instances. If none JWS
149         * objects will be rejected.
150         *
151         * @param factory The JWS verifier factory, {@code null} if not
152         *                specified.
153         */
154        void setJWSVerifierFactory(final JWSVerifierFactory factory);
155
156
157        /**
158         * Gets the factory for creating JWE decrypter instances. If none JWE
159         * objects will be rejected.
160         *
161         * @return The JWE decrypter factory, {@code null} if not specified.
162         */
163        JWEDecrypterFactory getJWEDecrypterFactory();
164
165
166        /**
167         * Sets the factory for creating JWE decrypter instances. If none JWE
168         * objects will be rejected.
169         *
170         * @param factory The JWE decrypter factory, {@code null} if not
171         *                specified.
172         */
173        void setJWEDecrypterFactory(final JWEDecrypterFactory factory);
174}