001/* 002 * Copyright 2017-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2017-2018 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.util.ssl.cert; 022 023 024 025import com.unboundid.util.NotMutable; 026import com.unboundid.util.OID; 027import com.unboundid.util.ThreadSafety; 028import com.unboundid.util.ThreadSafetyLevel; 029 030import static com.unboundid.util.ssl.cert.CertMessages.*; 031 032 033 034/** 035 * This class provides an implementation of the subject alternative name X.509 036 * certificate extension as described in 037 * <A HREF="https://www.ietf.org/rfc/rfc5280.txt">RFC 5280</A> section 4.2.1.6. 038 * It can provide additional information about the entity that is being 039 * certified, including alternate DNS hostnames or IP addresses that may be used 040 * to access the server, email addresses or DNs of end users, URIs of services, 041 * etc. This information may be used in the course of determining whether to 042 * trust a peer certificate. 043 * <BR><BR> 044 * The OID for this extension is 2.5.29.17. See the 045 * {@link GeneralAlternativeNameExtension} class for implementation details and 046 * the value encoding. 047 */ 048@NotMutable() 049@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 050public final class SubjectAlternativeNameExtension 051 extends GeneralAlternativeNameExtension 052{ 053 /** 054 * The OID (2.5.29.17) for subject alternative name extensions. 055 */ 056 public static final OID SUBJECT_ALTERNATIVE_NAME_OID = new OID("2.5.29.17"); 057 058 059 060 /** 061 * The serial version UID for this serializable class. 062 */ 063 private static final long serialVersionUID = 4194307412985686108L; 064 065 066 067 /** 068 * Creates a new subject alternative name extension with the provided 069 * information. 070 * 071 * @param isCritical Indicates whether this extension should be considered 072 * critical. 073 * @param generalNames The set of names to include in this extension. This 074 * must not be {@code null}. 075 * 076 * @throws CertException If a problem occurs while trying to encode the 077 * value. 078 */ 079 SubjectAlternativeNameExtension(final boolean isCritical, 080 final GeneralNames generalNames) 081 throws CertException 082 { 083 super(SUBJECT_ALTERNATIVE_NAME_OID, isCritical, generalNames); 084 } 085 086 087 088 /** 089 * Creates a new subject alternative name extension from the provided generic 090 * extension. 091 * 092 * @param extension The extension to decode as a subject alternative name 093 * extension. 094 * 095 * @throws CertException If the provided extension cannot be decoded as a 096 * subject alternative name extension. 097 */ 098 SubjectAlternativeNameExtension(final X509CertificateExtension extension) 099 throws CertException 100 { 101 super(extension); 102 } 103 104 105 106 /** 107 * {@inheritDoc} 108 */ 109 @Override() 110 public String getExtensionName() 111 { 112 return INFO_SUBJECT_ALT_NAME_EXTENSION_NAME.get(); 113 } 114 115 116 117 /** 118 * {@inheritDoc} 119 */ 120 @Override() 121 public void toString(final StringBuilder buffer) 122 { 123 toString("SubjectAlternativeNameExtension", buffer); 124 } 125}