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;
019
020
021import java.util.Objects;
022
023/**
024 * Action required for JWS completion. Can be used to signal a user
025 * authentication requirement in Android to unlock a private signing key
026 * created with {@code setUserAuthenticationRequired(true)}.
027 *
028 * @author Vladimir Dzhuvinov
029 * @version 2024-04-20
030 */
031public class ActionRequiredForJWSCompletionException extends JOSEException {
032        
033        
034        private final JWSSignerOption option;
035        
036        
037        private final CompletableJWSObjectSigning completableSigning;
038        
039        
040        /**
041         * Creates a new action required for JWS completion exception.
042         *
043         * @param message            The exception message.
044         * @param option             The JWS signer option that triggered the
045         *                           exception.
046         * @param completableSigning To complete the JWS object signing after
047         *                           the required action.
048         */
049        public ActionRequiredForJWSCompletionException(final String message,
050                                                       final JWSSignerOption option,
051                                                       final CompletableJWSObjectSigning completableSigning) {
052                super(message);
053                this.option = Objects.requireNonNull(option);
054                this.completableSigning = Objects.requireNonNull(completableSigning);
055        }
056        
057        
058        /**
059         * Returns the JWS signer option that triggered this exception.
060         *
061         * @return The JWS signer option.
062         */
063        public JWSSignerOption getTriggeringOption() {
064                return option;
065        }
066        
067        
068        /**
069         * Returns an interface to complete the JWS object signing after the
070         * required action is performed.
071         *
072         * @return The completable JWS object signing.
073         */
074        public CompletableJWSObjectSigning getCompletableJWSObjectSigning() {
075                return completableSigning;
076        }
077}