001    /**
002     * Copyright (c) 2000-2012 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.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    
048            @Override
049            public void decode_out(NdrBuffer ndrBuffer) throws NdrException {
050                    int returnAuthenticator = ndrBuffer.dec_ndr_long();
051    
052                    if (returnAuthenticator > 0) {
053                            _returnAuthenticator.decode(ndrBuffer);
054                    }
055    
056                    ndrBuffer.dec_ndr_short();
057    
058                    int validationInformation = ndrBuffer.dec_ndr_long();
059    
060                    if (validationInformation > 0) {
061                            ndrBuffer = ndrBuffer.deferred;
062                            _validationInformation.decode(ndrBuffer);
063                    }
064    
065                    _authoritative = (byte)ndrBuffer.dec_ndr_small();
066                    _status = ndrBuffer.dec_ndr_long();
067            }
068    
069            @Override
070            public void encode_in(NdrBuffer ndrBuffer) {
071                    ndrBuffer.enc_ndr_referent(_logonServer, 1);
072                    ndrBuffer.enc_ndr_string(_logonServer);
073    
074                    ndrBuffer.enc_ndr_referent(_computerName, 1);
075                    ndrBuffer.enc_ndr_string(_computerName);
076    
077                    ndrBuffer.enc_ndr_referent(_authenticator, 1);
078    
079                    _authenticator.encode(ndrBuffer);
080    
081                    ndrBuffer.enc_ndr_referent(_returnAuthenticator, 1);
082    
083                    _returnAuthenticator.encode(ndrBuffer);
084    
085                    ndrBuffer.enc_ndr_short(_logonLevel);
086                    ndrBuffer.enc_ndr_short(_logonLevel);
087    
088                    ndrBuffer.enc_ndr_referent(_logonInformation, 1);
089    
090                    _logonInformation.encode(ndrBuffer);
091    
092                    ndrBuffer.enc_ndr_short(_validationLevel);
093            }
094    
095            public NetlogonValidationSamInfo getNetlogonValidationSamInfo() {
096                    return _validationInformation;
097            }
098    
099            @Override
100            public int getOpnum() {
101                    return 2;
102            }
103    
104            public int getStatus() {
105                    return _status;
106            }
107    
108            private NetlogonAuthenticator _authenticator;
109    
110            @SuppressWarnings("unused")
111            private byte _authoritative;
112    
113            private String _computerName;
114            private NetlogonNetworkInfo _logonInformation;
115            private short _logonLevel;
116            private String _logonServer;
117            private NetlogonAuthenticator _returnAuthenticator;
118            private int _status;
119            private NetlogonValidationSamInfo _validationInformation;
120            private short _validationLevel;
121    
122    }