001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 * Portions Copyright 2015 ForgeRock AS. 026 */ 027package org.opends.admin.ads.util; 028 029import java.security.cert.CertificateException; 030import java.security.cert.X509Certificate; 031 032/** 033 * When a remote client (dsconfig for instance) wants to establish a 034 * remote connection with opends server through a secure connection, 035 * and if the certificate is not known, the SSL handcheck fails and 036 * this exception is thrown. This allows to get the certificate chain 037 * which is unknown. 038 */ 039public class OpendsCertificateException extends CertificateException 040{ 041 /** The serial version UUID. */ 042 private static final long serialVersionUID = 1151044344529478436L; 043 044 /** Private certificate chain. */ 045 private X509Certificate[] chain; 046 047 // ------------------ 048 // Constructor 049 // ------------------ 050 051 /** 052 * Build a new OpendsCertificationException object. 053 * 054 * @param chain the certificate chain which is unknown and has caused 055 * the SSL handcheck failure. 056 */ 057 public OpendsCertificateException(X509Certificate[] chain) 058 { 059 super(); 060 this.chain = chain; 061 } 062 063 /** 064 * Build a new OpendsCertificationException object. 065 * 066 * @param msg the detail message string of this exception. 067 * 068 * @param chain the certificate chain which is unknown and has caused 069 * the SSL handcheck failure. 070 */ 071 public OpendsCertificateException(String msg, X509Certificate[] chain) 072 { 073 super(msg); 074 this.chain = chain; 075 } 076 077 /** 078 * Build a new OpendsCertificationException object. 079 * 080 * @param chain the certificate chain which is unknown and has caused 081 * the SSL handcheck failure. 082 * @param cause the cause 083 */ 084 public OpendsCertificateException(X509Certificate[] chain, CertificateException cause) 085 { 086 super(cause); 087 this.chain = chain; 088 } 089 090 /** 091 * Return the certificate chain which is unknown and has caused 092 * the SSL handcheck failure. 093 * 094 * @return the certificate chain which is unknown and has caused 095 * the SSL handcheck failure. 096 */ 097 public X509Certificate[] getChain() 098 { 099 return chain; 100 } 101}