001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2011-2016 ForgeRock AS. 016 */ 017package org.opends.server.schema; 018 019import static org.opends.server.schema.SchemaConstants.*; 020 021import org.forgerock.opendj.config.server.ConfigException; 022import org.forgerock.opendj.ldap.schema.Schema; 023import org.forgerock.opendj.ldap.schema.SchemaBuilder; 024import org.forgerock.opendj.ldap.schema.Syntax; 025import org.forgerock.opendj.server.config.server.AttributeSyntaxCfg; 026import org.opends.server.api.AttributeSyntax; 027import org.opends.server.core.ServerContext; 028import org.opends.server.types.DirectoryException; 029import org.opends.server.types.Schema.SchemaUpdater; 030 031/** 032 * This class implements the access control information (aci) attribute syntax. 033 */ 034public class AciSyntax 035 extends AttributeSyntax<AttributeSyntaxCfg> 036{ 037 /** 038 * Creates a new instance of this syntax. Note that the only thing that 039 * should be done here is to invoke the default constructor for the 040 * superclass. All initialization should be performed in the 041 * <CODE>initializeSyntax</CODE> method. 042 */ 043 public AciSyntax() 044 { 045 super(); 046 } 047 048 @Override 049 public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) 050 throws ConfigException, DirectoryException 051 { 052 // Add the Aci syntax to the "new" schema 053 serverContext.getSchema().updateSchema(new SchemaUpdater() 054 { 055 @Override 056 public Schema update(SchemaBuilder builder) 057 { 058 return addAciSyntax(builder).toSchema(); 059 } 060 }); 061 } 062 063 /** 064 * Adds the ACI syntax to the provided schema builder. 065 * 066 * @param builder 067 * where to add the ACI syntax 068 * @return the provided builder 069 */ 070 public static SchemaBuilder addAciSyntax(SchemaBuilder builder) 071 { 072 return builder 073 .buildSyntax(SYNTAX_ACI_OID) 074 .description(SYNTAX_ACI_DESCRIPTION) 075 .implementation(new AciSyntaxImpl()) 076 .addToSchema(); 077 } 078 079 @Override 080 public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) 081 { 082 return schema.getSyntax(SchemaConstants.SYNTAX_ACI_OID); 083 } 084 085 @Override 086 public String getName() 087 { 088 return SYNTAX_ACI_NAME; 089 } 090 091 @Override 092 public String getOID() 093 { 094 return SYNTAX_ACI_OID; 095 } 096 097 @Override 098 public String getDescription() 099 { 100 return SYNTAX_ACI_DESCRIPTION; 101 } 102} 103