001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2020, 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.oauth2.sdk.dpop; 019 020 021import java.net.URI; 022import java.util.Date; 023 024import com.nimbusds.jose.JOSEException; 025import com.nimbusds.jose.JOSEObjectType; 026import com.nimbusds.jwt.SignedJWT; 027import com.nimbusds.oauth2.sdk.id.JWTID; 028 029 030/** 031 * DPoP JWT factory. 032 */ 033public interface DPoPJWTFactory { 034 035 036 /** 037 * The DPoP JWT (typ) type. 038 */ 039 JOSEObjectType TYPE = new JOSEObjectType("dpop+jwt"); 040 041 042 /** 043 * The minimal required JWT ID (jti) length, 12 bytes (96 bits). 044 */ 045 int MINIMAL_JTI_BYTE_LENGTH = 96 / 8; 046 047 048 /** 049 * Creates a new DPoP JWT. 050 * 051 * @param htm The HTTP request method. Must not be {@code null}. 052 * @param htu The HTTP URI, without a query or fragment. Must not be 053 * {@code null}. 054 * 055 * @return The signed DPoP JWT. 056 * 057 * @throws JOSEException If signing failed. 058 */ 059 SignedJWT createDPoPJWT(final String htm, 060 final URI htu) 061 throws JOSEException; 062 063 064 /** 065 * Creates a new DPoP JWT. 066 * 067 * @param jti The JWT ID. Must not be {@code null}. 068 * @param htm The HTTP request method. Must not be {@code null}. 069 * @param htu The HTTP URI, without a query or fragment. Must not be 070 * {@code null}. 071 * @param iat The issue time. Must not be {@code null}. 072 * 073 * @return The signed DPoP JWT. 074 * 075 * @throws JOSEException If signing failed. 076 */ 077 SignedJWT createDPoPJWT(final JWTID jti, 078 final String htm, 079 final URI htu, 080 final Date iat) 081 throws JOSEException; 082}