001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.security.ntlm.msrpc;
016    
017    import jcifs.dcerpc.UnicodeString;
018    import jcifs.dcerpc.ndr.NdrBuffer;
019    import jcifs.dcerpc.ndr.NdrObject;
020    import jcifs.dcerpc.rpc;
021    
022    /**
023     * @author Marcellus Tavares
024     */
025    public class NetlogonIdentityInfo extends NdrObject {
026    
027            public NetlogonIdentityInfo(
028                    String logonDomainName, int parameterControl, int reservedLow,
029                    int reservedHigh, String userName, String workstation) {
030    
031                    _logonDomainName = new UnicodeString(logonDomainName, false);
032                    _parameterControl= parameterControl;
033                    _reservedLow = reservedLow;
034                    _reservedHigh = reservedHigh;
035                    _userName = new UnicodeString(userName, false);
036                    _workstation = new UnicodeString(workstation, false);
037            }
038    
039            public void decode(NdrBuffer ndrBuffer) {
040            }
041    
042            public void encode(NdrBuffer ndrBuffer) {
043                    ndrBuffer.enc_ndr_short(_logonDomainName.length);
044                    ndrBuffer.enc_ndr_short(_logonDomainName.maximum_length);
045                    ndrBuffer.enc_ndr_referent(_logonDomainName.buffer, 1);
046                    ndrBuffer.enc_ndr_long(_parameterControl);
047                    ndrBuffer.enc_ndr_long(_reservedLow);
048                    ndrBuffer.enc_ndr_long(_reservedHigh);
049                    ndrBuffer.enc_ndr_short(_userName.length);
050                    ndrBuffer.enc_ndr_short(_userName.maximum_length);
051                    ndrBuffer.enc_ndr_referent(_userName.buffer, 1);
052                    ndrBuffer.enc_ndr_short(_workstation.length);
053                    ndrBuffer.enc_ndr_short(_workstation.maximum_length);
054                    ndrBuffer.enc_ndr_referent(_workstation.buffer, 1);
055            }
056    
057            public void encodeLogonDomainName(NdrBuffer ndrBuffer) {
058                    encodeUnicodeString(ndrBuffer, _logonDomainName);
059            }
060    
061            public void encodeUserName(NdrBuffer ndrBuffer) {
062                    encodeUnicodeString(ndrBuffer, _userName);
063            }
064    
065            public void encodeWorkStationName(NdrBuffer ndrBuffer) {
066                    encodeUnicodeString(ndrBuffer, _workstation);
067            }
068    
069            protected void encodeUnicodeString(
070                    NdrBuffer ndrBuffer, rpc.unicode_string string ) {
071    
072                    ndrBuffer = ndrBuffer.deferred;
073    
074                    int stringBufferl = string.length / 2;
075                    int stringBuffers = string.maximum_length / 2;
076    
077                    ndrBuffer.enc_ndr_long(stringBuffers);
078                    ndrBuffer.enc_ndr_long(0);
079                    ndrBuffer.enc_ndr_long(stringBufferl);
080    
081                    int stringBufferIndex = ndrBuffer.index;
082    
083                    ndrBuffer.advance(2 * stringBufferl);
084    
085                    ndrBuffer = ndrBuffer.derive(stringBufferIndex);
086    
087                    for (int _i = 0; _i < stringBufferl; _i++) {
088                            ndrBuffer.enc_ndr_short(string.buffer[_i]);
089                    }
090            }
091    
092            private rpc.unicode_string _logonDomainName;
093            private int _parameterControl;
094            private int _reservedHigh;
095            private int _reservedLow;
096            private rpc.unicode_string _userName;
097            private rpc.unicode_string _workstation;
098    
099    }