| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.io.IOException; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.Date; |
| | | import javax.net.ssl.TrustManager; |
| | | import javax.net.ssl.X509TrustManager; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.Date; |
| | | |
| | | import javax.net.ssl.TrustManager; |
| | | import javax.net.ssl.X509TrustManager; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * This class provides an implementation of an X.509 trust manager which will |
| | |
| | | public class PromptTrustManager |
| | | implements X509TrustManager |
| | | { |
| | | |
| | | |
| | | |
| | | /** The singleton trust manager array for this class. */ |
| | | private static TrustManager[] trustManagerArray = |
| | | new TrustManager[] { new PromptTrustManager() }; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this prompt trust manager. |
| | | */ |
| | | /** Creates a new instance of this prompt trust manager. */ |
| | | private PromptTrustManager() |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the trust manager array that should be used to initialize an SSL |
| | | * context in cases where the user should be interactively prompted about |
| | |
| | | return trustManagerArray; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Determines whether an SSL client with the provided certificate chain should |
| | | * be trusted. This implementation is not intended for server-side use, and |
| | |
| | | * @throws CertificateException To indicate that the provided client |
| | | * certificate is not trusted. |
| | | */ |
| | | @Override |
| | | public void checkClientTrusted(X509Certificate[] chain, String authType) |
| | | throws CertificateException |
| | | { |
| | |
| | | throw new CertificateException(message.toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Determines whether an SSL server with the provided certificate chain should |
| | | * be trusted. In this case, the user will be interactively prompted as to |
| | |
| | | * |
| | | * @throws CertificateException If the user rejects the certificate. |
| | | */ |
| | | @Override |
| | | public void checkServerTrusted(X509Certificate[] chain, String authType) |
| | | throws CertificateException |
| | | { |
| | |
| | | notAfterDate)); |
| | | } |
| | | |
| | | |
| | | LocalizableMessage prompt = INFO_PROMPTTM_YESNO_PROMPT.get(); |
| | | BufferedReader reader = |
| | | new BufferedReader(new InputStreamReader(System.in)); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of certificate authority certificates which are trusted |
| | | * for authenticating peers. |
| | |
| | | * @return An empty array, since we don't care what certificates are |
| | | * presented because we will always prompt the user. |
| | | */ |
| | | @Override |
| | | public X509Certificate[] getAcceptedIssuers() |
| | | { |
| | | return new X509Certificate[0]; |
| | | } |
| | | } |
| | | |