001/* 002 * nimbus-jose-jwt 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 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.produce; 019 020 021import com.nimbusds.jose.JOSEException; 022import com.nimbusds.jose.JWSAlgorithm; 023import com.nimbusds.jose.JWSProvider; 024import com.nimbusds.jose.JWSSigner; 025import com.nimbusds.jose.jwk.JWK; 026 027 028/** 029 * JSON Web Signature (JWS) signer factory to create a signer out of a JSON Web 030 * Key (JWK). 031 * 032 * @author Justin Richer 033 * @version 2020-03-26 034 */ 035public interface JWSSignerFactory extends JWSProvider { 036 037 /** 038 * Create a JWS signer based on the key. 039 * 040 * @param key The JWK. Must not be {@code null}. 041 * 042 * @return The JWS signer. 043 */ 044 JWSSigner createJWSSigner(final JWK key) 045 throws JOSEException; 046 047 /** 048 * Create a JWS signer based on the key and algorithm. Ensures that the 049 * key supports the given algorithm. 050 * 051 * @param key The JWK. Must not be {@code null}. 052 * @param alg The algorithm. Must not be {@code null}. 053 * 054 * @return The JWS signer. 055 */ 056 JWSSigner createJWSSigner(final JWK key, final JWSAlgorithm alg) 057 throws JOSEException; 058}