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.dsmlv2.request; 021 022 023import org.apache.directory.api.ldap.codec.api.LdapApiService; 024import org.apache.directory.api.ldap.model.message.BindRequest; 025import org.apache.directory.api.ldap.model.message.BindRequestImpl; 026import org.apache.directory.api.ldap.model.message.BindResponse; 027import org.apache.directory.api.ldap.model.message.Control; 028import org.apache.directory.api.ldap.model.message.MessageTypeEnum; 029import org.apache.directory.api.ldap.model.name.Dn; 030import org.dom4j.Element; 031 032 033/** 034 * DSML Decorator for BindRequest 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 */ 038public class BindRequestDsml 039 extends AbstractResultResponseRequestDsml<BindRequest, BindResponse> 040 implements BindRequest 041{ 042 /** 043 * Creates a new getDecoratedMessage() of AuthRequestDsml. 044 * 045 * @param codec The LDAP Service to use 046 */ 047 public BindRequestDsml( LdapApiService codec ) 048 { 049 super( codec, new BindRequestImpl() ); 050 } 051 052 053 /** 054 * Creates a new getDecoratedMessage() of AuthRequestDsml. 055 * 056 * @param codec The LDAP Service to use 057 * @param ldapMessage the message to decorate 058 */ 059 public BindRequestDsml( LdapApiService codec, BindRequest ldapMessage ) 060 { 061 super( codec, ldapMessage ); 062 } 063 064 065 /** 066 * {@inheritDoc} 067 */ 068 @Override 069 public MessageTypeEnum getType() 070 { 071 return getDecorated().getType(); 072 } 073 074 075 /** 076 * {@inheritDoc} 077 */ 078 @Override 079 public Element toDsml( Element root ) 080 { 081 Element element = super.toDsml( root ); 082 083 BindRequest request = getDecorated(); 084 085 // Principal 086 Dn dn = request.getDn(); 087 088 if ( !Dn.isNullOrEmpty( dn ) ) 089 { 090 // A DN has been provided 091 092 element.addAttribute( "principal", dn.getName() ); 093 } 094 else 095 { 096 // No DN has been provided, let's use the name as a string instead 097 098 String name = request.getName(); 099 100 element.addAttribute( "principal", name ); 101 } 102 103 return element; 104 } 105 106 107 /** 108 * {@inheritDoc} 109 */ 110 @Override 111 public MessageTypeEnum getResponseType() 112 { 113 return getDecorated().getResponseType(); 114 } 115 116 117 /** 118 * {@inheritDoc} 119 */ 120 @Override 121 public boolean isSimple() 122 { 123 return getDecorated().isSimple(); 124 } 125 126 127 /** 128 * {@inheritDoc} 129 */ 130 @Override 131 public boolean getSimple() 132 { 133 return getDecorated().getSimple(); 134 } 135 136 137 /** 138 * {@inheritDoc} 139 */ 140 @Override 141 public BindRequest setSimple( boolean isSimple ) 142 { 143 getDecorated().setSimple( isSimple ); 144 145 return this; 146 } 147 148 149 /** 150 * {@inheritDoc} 151 */ 152 @Override 153 public byte[] getCredentials() 154 { 155 return getDecorated().getCredentials(); 156 } 157 158 159 /** 160 * {@inheritDoc} 161 */ 162 @Override 163 public BindRequest setCredentials( String credentials ) 164 { 165 getDecorated().setCredentials( credentials ); 166 167 return this; 168 } 169 170 171 /** 172 * {@inheritDoc} 173 */ 174 @Override 175 public BindRequest setCredentials( byte[] credentials ) 176 { 177 getDecorated().setCredentials( credentials ); 178 179 return this; 180 } 181 182 183 /** 184 * {@inheritDoc} 185 */ 186 @Override 187 public String getName() 188 { 189 return getDecorated().getName(); 190 } 191 192 193 /** 194 * {@inheritDoc} 195 */ 196 @Override 197 public BindRequest setName( String name ) 198 { 199 getDecorated().setName( name ); 200 201 return this; 202 } 203 204 205 /** 206 * {@inheritDoc} 207 */ 208 @Override 209 public Dn getDn() 210 { 211 return getDecorated().getDn(); 212 } 213 214 215 /** 216 * {@inheritDoc} 217 */ 218 @Override 219 public BindRequest setDn( Dn dn ) 220 { 221 getDecorated().setDn( dn ); 222 223 return this; 224 } 225 226 227 /** 228 * {@inheritDoc} 229 */ 230 @Override 231 public boolean isVersion3() 232 { 233 return getDecorated().isVersion3(); 234 } 235 236 237 /** 238 * {@inheritDoc} 239 */ 240 @Override 241 public boolean getVersion3() 242 { 243 return getDecorated().getVersion3(); 244 } 245 246 247 /** 248 * {@inheritDoc} 249 */ 250 @Override 251 public BindRequest setVersion3( boolean isVersion3 ) 252 { 253 getDecorated().setVersion3( isVersion3 ); 254 255 return this; 256 } 257 258 259 /** 260 * {@inheritDoc} 261 */ 262 @Override 263 public String getSaslMechanism() 264 { 265 return getDecorated().getSaslMechanism(); 266 } 267 268 269 /** 270 * {@inheritDoc} 271 */ 272 @Override 273 public BindRequest setSaslMechanism( String saslMechanism ) 274 { 275 getDecorated().setSaslMechanism( saslMechanism ); 276 277 return this; 278 } 279 280 281 /** 282 * {@inheritDoc} 283 */ 284 @Override 285 public BindRequest setMessageId( int messageId ) 286 { 287 super.setMessageId( messageId ); 288 289 return this; 290 } 291 292 293 /** 294 * {@inheritDoc} 295 */ 296 @Override 297 public BindRequest addControl( Control control ) 298 { 299 return ( BindRequest ) super.addControl( control ); 300 } 301 302 303 /** 304 * {@inheritDoc} 305 */ 306 @Override 307 public BindRequest addAllControls( Control[] controls ) 308 { 309 return ( BindRequest ) super.addAllControls( controls ); 310 } 311 312 313 /** 314 * {@inheritDoc} 315 */ 316 @Override 317 public BindRequest removeControl( Control control ) 318 { 319 return ( BindRequest ) super.removeControl( control ); 320 } 321}