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.crypto.impl; 019 020 021import com.nimbusds.jose.JWSAlgorithm; 022import com.nimbusds.jose.JWSProvider; 023import com.nimbusds.jose.jca.JCAContext; 024 025import java.util.Collections; 026import java.util.Objects; 027import java.util.Set; 028 029 030/** 031 * The base abstract class for JSON Web Signature (JWS) signers and verifiers. 032 * 033 * @author Vladimir Dzhuvinov 034 * @version 2024-04-20 035 */ 036public abstract class BaseJWSProvider implements JWSProvider { 037 038 039 /** 040 * The supported algorithms by the JWS provider instance. 041 */ 042 private final Set<JWSAlgorithm> algs; 043 044 045 /** 046 * The JCA context. 047 */ 048 private final JCAContext jcaContext = new JCAContext(); 049 050 051 /** 052 * Creates a new base JWS provider. 053 * 054 * @param algs The supported algorithms by the JWS provider instance. 055 * Must not be {@code null}. 056 */ 057 public BaseJWSProvider(final Set<JWSAlgorithm> algs) { 058 059 this.algs = Collections.unmodifiableSet(Objects.requireNonNull(algs)); 060 } 061 062 063 @Override 064 public Set<JWSAlgorithm> supportedJWSAlgorithms() { 065 066 return algs; 067 } 068 069 070 @Override 071 public JCAContext getJCAContext() { 072 073 return jcaContext; 074 } 075} 076