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.jwk.source;
019
020
021import java.util.Date;
022
023import net.jcip.annotations.Immutable;
024
025import com.nimbusds.jose.jwk.JWKSet;
026
027
028/**
029 * JSON Web Key (JWK) set with timestamp.
030 *
031 * @author Vladimir Dzhuvinov
032 * @version 2020-12-27
033 */
034@Immutable
035public final class JWKSetWithTimestamp {
036
037
038        private final JWKSet jwkSet;
039        
040        
041        private final Date timestamp;
042        
043        
044        /**
045         * Creates a new JWK set with a timestamp set to now.
046         */
047        public JWKSetWithTimestamp(final JWKSet jwkSet) {
048                this(jwkSet, new Date());
049        }
050        
051        
052        /**
053         * Creates a new JWK set with timestamp.
054         *
055         * @param jwkSet    The JWK set. Must not be {@code null}.
056         * @param timestamp The timestamp date. Must not be {@code null}.
057         */
058        public JWKSetWithTimestamp(final JWKSet jwkSet, final Date timestamp) {
059                if (jwkSet == null) {
060                        throw new IllegalArgumentException("The JWK set must not be null");
061                }
062                this.jwkSet = jwkSet;
063                if (timestamp == null) {
064                        throw new IllegalArgumentException("The timestamp must not null");
065                }
066                this.timestamp = timestamp;
067        }
068        
069        
070        /**
071         * Returns the JWK set.
072         *
073         * @return The JWK set.
074         */
075        public JWKSet getJWKSet() {
076                return jwkSet;
077        }
078        
079        
080        /**
081         * Returns the timestamp date.
082         *
083         * @return The timestamp date.
084         */
085        public Date getDate() {
086                return timestamp;
087        }
088}