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 * https://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.response; 021 022 023import org.apache.directory.api.ldap.codec.api.LdapApiService; 024import org.apache.directory.api.ldap.model.message.BindResponse; 025import org.apache.directory.api.ldap.model.message.BindResponseImpl; 026import org.dom4j.Element; 027import org.dom4j.tree.DefaultElement; 028 029 030/** 031 * DSML Decorator for AuthResponse 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 */ 035public class BindResponseDsml extends AbstractResultResponseDsml<BindResponse> implements BindResponse 036{ 037 private static final String AUTH_RESPONSE_TAG = "authResponse"; 038 039 /** 040 * Creates a new getDecoratedMessage() of AuthResponseDsml. 041 * 042 * @param codec The LDAP Service to use 043 */ 044 public BindResponseDsml( LdapApiService codec ) 045 { 046 super( codec, new BindResponseImpl() ); 047 } 048 049 050 /** 051 * Creates a new getDecoratedMessage() of AuthResponseDsml. 052 * 053 * @param codec The LDAP Service to use 054 * @param ldapMessage the message to decorate 055 */ 056 public BindResponseDsml( LdapApiService codec, BindResponse ldapMessage ) 057 { 058 super( codec, ldapMessage ); 059 } 060 061 062 /** 063 * {@inheritDoc} 064 */ 065 @Override 066 public Element toDsml( Element root ) 067 { 068 Element element; 069 070 if ( root != null ) 071 { 072 element = root.addElement( AUTH_RESPONSE_TAG ); 073 } 074 else 075 { 076 element = new DefaultElement( AUTH_RESPONSE_TAG ); 077 } 078 079 080 LdapResultDsml ldapResultDsml = new LdapResultDsml( getCodecService(), 081 getDecorated().getLdapResult(), getDecorated() ); 082 ldapResultDsml.toDsml( element ); 083 return element; 084 } 085 086 087 /** 088 * {@inheritDoc} 089 */ 090 @Override 091 public byte[] getServerSaslCreds() 092 { 093 return getDecorated().getServerSaslCreds(); 094 } 095 096 097 /** 098 * {@inheritDoc} 099 */ 100 @Override 101 public void setServerSaslCreds( byte[] serverSaslCreds ) 102 { 103 getDecorated().setServerSaslCreds( serverSaslCreds ); 104 } 105}