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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.schema; 028 029 030 031 import org.opends.server.admin.std.server.AttributeSyntaxCfg; 032 import org.opends.server.api.ApproximateMatchingRule; 033 import org.opends.server.api.AttributeSyntax; 034 import org.opends.server.api.EqualityMatchingRule; 035 import org.opends.server.api.OrderingMatchingRule; 036 import org.opends.server.api.SubstringMatchingRule; 037 import org.opends.server.config.ConfigException; 038 import org.opends.server.core.DirectoryServer; 039 import org.opends.server.types.ByteString; 040 041 042 043 import static org.opends.server.loggers.ErrorLogger.*; 044 import static org.opends.messages.SchemaMessages.*; 045 import org.opends.messages.MessageBuilder; 046 import static org.opends.server.schema.SchemaConstants.*; 047 048 049 /** 050 * This class implements the certificate list attribute syntax. This should be 051 * restricted to holding only X.509 certificate lists, but we will accept any 052 * set of bytes. It will be treated much like the octet string attribute 053 * syntax. 054 */ 055 public class CertificateListSyntax 056 extends AttributeSyntax<AttributeSyntaxCfg> 057 { 058 // The default equality matching rule for this syntax. 059 private EqualityMatchingRule defaultEqualityMatchingRule; 060 061 // The default ordering matching rule for this syntax. 062 private OrderingMatchingRule defaultOrderingMatchingRule; 063 064 // The default substring matching rule for this syntax. 065 private SubstringMatchingRule defaultSubstringMatchingRule; 066 067 068 069 /** 070 * Creates a new instance of this syntax. Note that the only thing that 071 * should be done here is to invoke the default constructor for the 072 * superclass. All initialization should be performed in the 073 * <CODE>initializeSyntax</CODE> method. 074 */ 075 public CertificateListSyntax() 076 { 077 super(); 078 } 079 080 081 082 /** 083 * {@inheritDoc} 084 */ 085 public void initializeSyntax(AttributeSyntaxCfg configuration) 086 throws ConfigException 087 { 088 defaultEqualityMatchingRule = 089 DirectoryServer.getEqualityMatchingRule(EMR_OCTET_STRING_OID); 090 if (defaultEqualityMatchingRule == null) 091 { 092 logError(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( 093 EMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME)); 094 } 095 096 defaultOrderingMatchingRule = 097 DirectoryServer.getOrderingMatchingRule(OMR_OCTET_STRING_OID); 098 if (defaultOrderingMatchingRule == null) 099 { 100 logError(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get( 101 OMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME)); 102 } 103 104 defaultSubstringMatchingRule = 105 DirectoryServer.getSubstringMatchingRule(SMR_OCTET_STRING_OID); 106 if (defaultSubstringMatchingRule == null) 107 { 108 logError(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get( 109 SMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME)); 110 } 111 } 112 113 114 115 /** 116 * Retrieves the common name for this attribute syntax. 117 * 118 * @return The common name for this attribute syntax. 119 */ 120 public String getSyntaxName() 121 { 122 return SYNTAX_CERTLIST_NAME; 123 } 124 125 126 127 /** 128 * Retrieves the OID for this attribute syntax. 129 * 130 * @return The OID for this attribute syntax. 131 */ 132 public String getOID() 133 { 134 return SYNTAX_CERTLIST_OID; 135 } 136 137 138 139 /** 140 * Retrieves a description for this attribute syntax. 141 * 142 * @return A description for this attribute syntax. 143 */ 144 public String getDescription() 145 { 146 return SYNTAX_CERTLIST_DESCRIPTION; 147 } 148 149 150 151 /** 152 * Retrieves the default equality matching rule that will be used for 153 * attributes with this syntax. 154 * 155 * @return The default equality matching rule that will be used for 156 * attributes with this syntax, or <CODE>null</CODE> if equality 157 * matches will not be allowed for this type by default. 158 */ 159 public EqualityMatchingRule getEqualityMatchingRule() 160 { 161 return defaultEqualityMatchingRule; 162 } 163 164 165 166 /** 167 * Retrieves the default ordering matching rule that will be used for 168 * attributes with this syntax. 169 * 170 * @return The default ordering matching rule that will be used for 171 * attributes with this syntax, or <CODE>null</CODE> if ordering 172 * matches will not be allowed for this type by default. 173 */ 174 public OrderingMatchingRule getOrderingMatchingRule() 175 { 176 return defaultOrderingMatchingRule; 177 } 178 179 180 181 /** 182 * Retrieves the default substring matching rule that will be used for 183 * attributes with this syntax. 184 * 185 * @return The default substring matching rule that will be used for 186 * attributes with this syntax, or <CODE>null</CODE> if substring 187 * matches will not be allowed for this type by default. 188 */ 189 public SubstringMatchingRule getSubstringMatchingRule() 190 { 191 return defaultSubstringMatchingRule; 192 } 193 194 195 196 /** 197 * Retrieves the default approximate matching rule that will be used for 198 * attributes with this syntax. 199 * 200 * @return The default approximate matching rule that will be used for 201 * attributes with this syntax, or <CODE>null</CODE> if approximate 202 * matches will not be allowed for this type by default. 203 */ 204 public ApproximateMatchingRule getApproximateMatchingRule() 205 { 206 // There is no approximate matching rule by default. 207 return null; 208 } 209 210 211 212 /** 213 * Indicates whether the provided value is acceptable for use in an attribute 214 * with this syntax. If it is not, then the reason may be appended to the 215 * provided buffer. 216 * 217 * @param value The value for which to make the determination. 218 * @param invalidReason The buffer to which the invalid reason should be 219 * appended. 220 * 221 * @return <CODE>true</CODE> if the provided value is acceptable for use with 222 * this syntax, or <CODE>false</CODE> if not. 223 */ 224 public boolean valueIsAcceptable(ByteString value, 225 MessageBuilder invalidReason) 226 { 227 // All values will be acceptable for the certificate list syntax. 228 return true; 229 } 230 } 231