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     */
020    
021    package org.apache.directory.shared.dsmlv2.reponse;
022    
023    
024    import org.apache.directory.shared.dsmlv2.DsmlDecorator;
025    import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
026    import org.apache.directory.shared.ldap.codec.bind.BindResponseCodec;
027    import org.dom4j.Element;
028    
029    
030    /**
031     * DSML Decorator for AuthResponse
032     *
033     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034     * @version $Rev$, $Date$
035     */
036    public class AuthResponseDsml extends LdapResponseDecorator implements DsmlDecorator
037    {
038        /**
039         * Creates a new instance of AuthResponseDsml.
040         */
041        public AuthResponseDsml()
042        {
043            super( new BindResponseCodec() );
044        }
045    
046    
047        /**
048         * Creates a new instance of AuthResponseDsml.
049         *
050         * @param ldapMessage
051         *      the message to decorate
052         */
053        public AuthResponseDsml( BindResponseCodec ldapMessage )
054        {
055            super( ldapMessage );
056        }
057    
058    
059        /* (non-Javadoc)
060         * @see org.apache.directory.shared.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
061         */
062        public MessageTypeEnum getMessageType()
063        {
064            return instance.getMessageType();
065        }
066    
067    
068        /* (non-Javadoc)
069         * @see org.apache.directory.shared.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
070         */
071        public Element toDsml( Element root )
072        {
073            Element element = root.addElement( "authResponse" );
074    
075            LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( BindResponseCodec ) instance ).getLdapResult(), instance );
076            ldapResultDsml.toDsml( element );
077            return element;
078        }
079    }