001/* 002 * nimbus-jose-jwt 003 * 004 * Copyright 2012-2026, 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.opts; 019 020import com.nimbusds.jose.JWEDecrypterOption; 021import net.jcip.annotations.Immutable; 022 023 024/** 025 * JSON Web Encryption (JWE) decrypter option to configure the maximum allowed 026 * length of decompressed plain text. The 027 * {@link com.nimbusds.jose.JWEObject#MAX_DECOMPRESSED_PLAIN_TEXT_LENGTH default} 028 * is 1 million characters. 029 * 030 * @author Vladimir Dzhuvinov 031 * @version 2026-09-16. 032 */ 033@Immutable 034public final class MaxDecompressedPlainTextLength implements JWEDecrypterOption { 035 036 037 private final int maxLength; 038 039 040 /** 041 * Creates a new maximum decompressed plain text length option. 042 * 043 * @param maxLength The maximum allowed length, in characters. Must be 044 * positive 045 */ 046 public MaxDecompressedPlainTextLength(final int maxLength) { 047 if (maxLength <= 0) { 048 throw new IllegalArgumentException("The max decompressed plain text length must be a positive integer"); 049 } 050 this.maxLength = maxLength; 051 } 052 053 054 /** 055 * Returns the maximum allowed decompressed plain text length. 056 * 057 * @return The maximum length, in characters. 058 */ 059 public int getMaxLength() { 060 return maxLength; 061 } 062 063 @Override 064 public String toString() { 065 return "MaxDecompressedPlainTextLength(" + maxLength + ")"; 066 067 } 068}