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