aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/signing/ssh/VerificationException.java
blob: cd77111813e229bb415592f0bf7288fa5907d097 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright (C) 2024, Thomas Wolf <twolf@apache.org> and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
package org.eclipse.jgit.signing.ssh;

/**
 * An exception giving details about a failed
 * {@link SigningKeyDatabase#isAllowed(org.eclipse.jgit.lib.Repository, org.eclipse.jgit.lib.GpgConfig, java.security.PublicKey, String, org.eclipse.jgit.lib.PersonIdent)}
 * validation.
 *
 * @since 7.1
 */
public class VerificationException extends Exception {

	private static final long serialVersionUID = 313760495170326160L;

	private final boolean expired;

	private final String reason;

	/**
	 * Creates a new instance.
	 *
	 * @param expired
	 *            whether the checked public key or certificate was expired
	 * @param reason
	 *            describing the check failure
	 */
	public VerificationException(boolean expired, String reason) {
		this.expired = expired;
		this.reason = reason;
	}

	@Override
	public String getMessage() {
		return reason;
	}

	/**
	 * Tells whether the check failed because the public key was expired.
	 *
	 * @return {@code true} if the check failed because the public key was
	 *         expired, {@code false} otherwise
	 */
	public boolean isExpired() {
		return expired;
	}

	/**
	 * Retrieves the check failure reason.
	 *
	 * @return the reason description
	 */
	public String getReason() {
		return reason;
	}
}