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.openid.connect.sdk.rp.statement;
019
020
021import com.nimbusds.oauth2.sdk.ErrorObject;
022import com.nimbusds.oauth2.sdk.client.RegistrationError;
023
024
025/**
026 * Invalid software statement exception.
027 */
028public class InvalidSoftwareStatementException extends Exception {
029        
030        
031        private static final long serialVersionUID = -3170931736329757864L;
032        
033        
034        /**
035         * Creates a new invalid software statement exception.
036         *
037         * @param message The message, {@code null} if not specified.
038         */
039        public InvalidSoftwareStatementException(final String message) {
040                this(message, null);
041        }
042        
043        
044        /**
045         * Creates a new invalid software statement exception.
046         *
047         * @param message The message, {@code null} if not specified.
048         * @param cause   The error cause, {@code null} if not specified.
049         */
050        public InvalidSoftwareStatementException(final String message, final Throwable cause) {
051                super(message, cause);
052        }
053        
054        
055        /**
056         * Returns the error object to return, an instance of a
057         * {@link RegistrationError#INVALID_SOFTWARE_STATEMENT}.
058         *
059         * @return The error object.
060         */
061        public ErrorObject getErrorObject() {
062                if (getMessage() != null) {
063                        return RegistrationError.INVALID_SOFTWARE_STATEMENT.setDescription(getMessage());
064                } else {
065                        return RegistrationError.INVALID_SOFTWARE_STATEMENT;
066                }
067        }
068}