001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.security.ntlm.msrpc;
016    
017    import jcifs.dcerpc.DcerpcMessage;
018    import jcifs.dcerpc.ndr.NdrBuffer;
019    import jcifs.dcerpc.ndr.NdrException;
020    
021    /**
022     * @author Marcellus Tavares
023     */
024    public class NetrLogonSamLogon extends DcerpcMessage {
025    
026            public NetrLogonSamLogon(
027                    String logonServer, String computerName,
028                    NetlogonAuthenticator netlogonAuthenticator,
029                    NetlogonAuthenticator returnNetlogonAuthenticator, int logonLevel,
030                    NetlogonNetworkInfo netlogonNetworkInfo, int validationLevel,
031                    NetlogonValidationSamInfo netlogonValidationSamInfo,
032                    int authoritative) {
033    
034                    _logonServer = logonServer;
035                    _computerName = computerName;
036                    _authenticator = netlogonAuthenticator;
037                    _returnAuthenticator = returnNetlogonAuthenticator;
038                    _logonLevel = (short)logonLevel;
039                    _logonInformation = netlogonNetworkInfo;
040                    _validationLevel = (short)validationLevel;
041                    _validationInformation = netlogonValidationSamInfo;
042                    _authoritative = (byte)authoritative;
043    
044                    ptype = 0;
045                    flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG;
046            }
047            public void decode_out(NdrBuffer ndrBuffer) throws NdrException {
048                    int returnAuthenticator = ndrBuffer.dec_ndr_long();
049    
050                    if (returnAuthenticator > 0) {
051                            _returnAuthenticator.decode(ndrBuffer);
052                    }
053    
054                    ndrBuffer.dec_ndr_short();
055    
056                    int validationInformation = ndrBuffer.dec_ndr_long();
057    
058                    if (validationInformation > 0) {
059                            ndrBuffer = ndrBuffer.deferred;
060                            _validationInformation.decode(ndrBuffer);
061                    }
062    
063                    _authoritative = (byte)ndrBuffer.dec_ndr_small();
064                    _status = ndrBuffer.dec_ndr_long();
065            }
066            public void encode_in(NdrBuffer ndrBuffer) {
067                    ndrBuffer.enc_ndr_referent(_logonServer, 1);
068                    ndrBuffer.enc_ndr_string(_logonServer);
069    
070                    ndrBuffer.enc_ndr_referent(_computerName, 1);
071                    ndrBuffer.enc_ndr_string(_computerName);
072    
073                    ndrBuffer.enc_ndr_referent(_authenticator, 1);
074    
075                    _authenticator.encode(ndrBuffer);
076    
077                    ndrBuffer.enc_ndr_referent(_returnAuthenticator, 1);
078    
079                    _returnAuthenticator.encode(ndrBuffer);
080    
081                    ndrBuffer.enc_ndr_short(_logonLevel);
082                    ndrBuffer.enc_ndr_short(_logonLevel);
083    
084                    ndrBuffer.enc_ndr_referent(_logonInformation, 1);
085    
086                    _logonInformation.encode(ndrBuffer);
087    
088                    ndrBuffer.enc_ndr_short(_validationLevel);
089            }
090    
091            public NetlogonValidationSamInfo getNetlogonValidationSamInfo() {
092                    return _validationInformation;
093            }
094    
095            public int getOpnum() {
096                    return 2;
097            }
098    
099            public int getStatus() {
100                    return _status;
101            }
102    
103            private NetlogonAuthenticator _authenticator;
104    
105            @SuppressWarnings("unused")
106            private byte _authoritative;
107    
108            private String _computerName;
109            private NetlogonNetworkInfo _logonInformation;
110            private short _logonLevel;
111            private String _logonServer;
112            private NetlogonAuthenticator _returnAuthenticator;
113            private int _status;
114            private NetlogonValidationSamInfo _validationInformation;
115            private short _validationLevel;
116    
117    }