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    package org.apache.directory.shared.dsmlv2.request;
021    
022    
023    import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
024    import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
025    import org.dom4j.Element;
026    
027    
028    /**
029     * DSML Decorator for BindRequest
030     *
031     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032     * @version $Rev$, $Date$
033     */
034    public class AuthRequestDsml extends AbstractRequestDsml
035    {
036        /**
037         * Creates a new instance of AuthRequestDsml.
038         */
039        public AuthRequestDsml()
040        {
041            super( new BindRequestCodec() );
042        }
043    
044    
045        /**
046         * Creates a new instance of AuthRequestDsml.
047         *
048         * @param ldapMessage
049         *      the message to decorate
050         */
051        public AuthRequestDsml( BindRequestCodec ldapMessage )
052        {
053            super( ldapMessage );
054        }
055    
056    
057        /**
058         * {@inheritDoc}
059         */
060        public MessageTypeEnum getMessageType()
061        {
062            return instance.getMessageType();
063        }
064    
065    
066        /**
067         * {@inheritDoc}
068         */
069        public Element toDsml( Element root )
070        {
071            Element element = super.toDsml( root );
072    
073            BindRequestCodec request = ( BindRequestCodec ) instance;
074    
075            // AbandonID
076            String name = request.getName().getName();
077            if ( ( name != null ) && ( !"".equals( name ) ) )
078            {
079                element.addAttribute( "principal", name );
080            }
081    
082            return element;
083        }
084    }