001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.extras.extended.startTls; 021 022 023import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl; 024import org.apache.directory.api.ldap.model.message.ResultCodeEnum; 025 026 027/** 028 * The RFC 4511 StartTLS response : 029 * 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 */ 032public class StartTlsResponseImpl extends ExtendedResponseImpl implements StartTlsResponse 033{ 034 /** 035 * Create a new instance for the StartTls response 036 * @param messageId The Message ID 037 * @param rcode The result code 038 * @param diagnosticMessage The diagnostic message 039 */ 040 public StartTlsResponseImpl( int messageId, ResultCodeEnum rcode, String diagnosticMessage ) 041 { 042 super( messageId, EXTENSION_OID ); 043 044 super.getLdapResult().setMatchedDn( null ); 045 super.getLdapResult().setResultCode( rcode ); 046 super.getLdapResult().setDiagnosticMessage( diagnosticMessage ); 047 } 048 049 050 /** 051 * Create a new instance for the StartTls response 052 * @param messageId The Message ID 053 * @param rcode The result code 054 */ 055 public StartTlsResponseImpl( int messageId, ResultCodeEnum rcode ) 056 { 057 super( messageId, EXTENSION_OID ); 058 059 super.getLdapResult().setMatchedDn( null ); 060 super.getLdapResult().setResultCode( rcode ); 061 } 062 063 064 /** 065 * Instantiates a new StartTls response. 066 * 067 * @param messageId the message id 068 */ 069 public StartTlsResponseImpl( int messageId ) 070 { 071 super( messageId, EXTENSION_OID ); 072 super.getLdapResult().setMatchedDn( null ); 073 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); 074 } 075 076 077 /** 078 * Instantiates a new StartTls response. 079 */ 080 public StartTlsResponseImpl() 081 { 082 super( EXTENSION_OID ); 083 super.getLdapResult().setMatchedDn( null ); 084 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); 085 } 086 087 088 /** 089 * @see Object#toString() 090 */ 091 @Override 092 public String toString() 093 { 094 StringBuilder sb = new StringBuilder(); 095 096 sb.append( "StartTlsResponse :" ); 097 sb.append( getLdapResult() ); 098 099 return sb.toString(); 100 } 101}