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 2009 Sun Microsystems, Inc. 025 */ 026 027package org.forgerock.opendj.ldap.requests; 028 029import java.util.List; 030 031import org.forgerock.opendj.ldap.ByteString; 032import org.forgerock.opendj.ldap.DecodeException; 033import org.forgerock.opendj.ldap.DecodeOptions; 034import org.forgerock.opendj.ldap.controls.Control; 035import org.forgerock.opendj.ldap.controls.ControlDecoder; 036import org.forgerock.opendj.ldap.responses.ExtendedResult; 037import org.forgerock.opendj.ldap.responses.ExtendedResultDecoder; 038 039/** 040 * The Extended operation allows additional operations to be defined for 041 * services not already available in the protocol; for example, to implement an 042 * operation which installs transport layer security (see 043 * {@link StartTLSExtendedRequest}). 044 * <p> 045 * To determine whether a directory server supports a given extension, read the 046 * list of supported extensions from the root DSE to get a collection of 047 * extension OIDs, and then check for a match. For example: 048 * 049 * <pre> 050 * Connection connection = ...; 051 * Collection<String> supported = 052 * RootDSE.readRootDSE(connection).getSupportedExtendedOperations(); 053 * 054 * ExtendedRequest extension = ...; 055 * String OID = extension.getOID(); 056 * if (supported != null && !supported.isEmpty() && supported.contains(OID)) { 057 * // The extension is supported. Use it here... 058 * } 059 * </pre> 060 * 061 * @param <S> 062 * The type of result. 063 */ 064public interface ExtendedRequest<S extends ExtendedResult> extends Request { 065 066 @Override 067 ExtendedRequest<S> addControl(Control control); 068 069 @Override 070 <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options) 071 throws DecodeException; 072 073 @Override 074 List<Control> getControls(); 075 076 /** 077 * Returns the numeric OID associated with this extended request. 078 * 079 * @return The numeric OID associated with this extended request. 080 */ 081 String getOID(); 082 083 /** 084 * Returns a decoder which can be used to decoded responses to this extended 085 * request. 086 * 087 * @return A decoder which can be used to decoded responses to this extended 088 * request. 089 */ 090 ExtendedResultDecoder<S> getResultDecoder(); 091 092 /** 093 * Returns the value, if any, associated with this extended request. Its 094 * format is defined by the specification of this extended request. 095 * 096 * @return The value associated with this extended request, or {@code null} 097 * if there is no value. 098 */ 099 ByteString getValue(); 100 101 /** 102 * Returns {@code true} if this extended request has a value. In some 103 * circumstances it may be useful to determine if a extended request has a 104 * value, without actually calculating the value and incurring any 105 * performance costs. 106 * 107 * @return {@code true} if this extended request has a value, or 108 * {@code false} if there is no value. 109 */ 110 boolean hasValue(); 111 112}