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    
020    /**
021     * @author Marcellus Tavares
022     */
023    public class NetrServerAuthenticate3 extends DcerpcMessage {
024    
025            public NetrServerAuthenticate3(
026                    String primaryName, String accountName, int secureChannelType,
027                    String computerName, byte[] clientCredential, byte[] serverCredential,
028                    int negotiateFlags) {
029    
030                    _primaryName = primaryName;
031                    _accountName = accountName;
032                    _secureChannelType = (short) secureChannelType;
033                    _computerName = computerName;
034                    _clientCredential = clientCredential;
035                    _serverCredential = serverCredential;
036                    _negotiateFlags = negotiateFlags;
037    
038                    ptype = 0;
039                    flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG;
040            }
041    
042            public void decode_out(NdrBuffer ndrBuffer) {
043                    int index = ndrBuffer.index;
044    
045                    ndrBuffer.advance(8);
046    
047                    ndrBuffer = ndrBuffer.derive(index);
048    
049                    for (int i = 0; i < 8; i++) {
050                            _serverCredential[i] = (byte) ndrBuffer.dec_ndr_small();
051                    }
052    
053                    _negotiateFlags = ndrBuffer.dec_ndr_long();
054                    _accountRid = ndrBuffer.dec_ndr_long();
055                    _status = ndrBuffer.dec_ndr_long();
056            }
057    
058            public void encode_in(NdrBuffer ndrBuffer) {
059                    ndrBuffer.enc_ndr_referent(_primaryName, 1);
060                    ndrBuffer.enc_ndr_string(_primaryName);
061                    ndrBuffer.enc_ndr_string(_accountName);
062                    ndrBuffer.enc_ndr_short(_secureChannelType);
063                    ndrBuffer.enc_ndr_string(_computerName);
064    
065                    int index = ndrBuffer.index;
066    
067                    ndrBuffer.advance(8);
068    
069                    NdrBuffer derivedNrdBuffer = ndrBuffer.derive(index);
070    
071                    for (int i = 0; i < 8; i++) {
072                            derivedNrdBuffer.enc_ndr_small(_clientCredential[i]);
073                    }
074    
075                    ndrBuffer.enc_ndr_long(_negotiateFlags);
076            }
077    
078            public int getAccountRid() {
079                    return _accountRid;
080            }
081    
082            public int getNegotiatedFlags() {
083                    return _negotiateFlags;
084            }
085    
086            public int getOpnum() {
087                    return 26;
088            }
089    
090            public byte[] getServerCredential() {
091                    return _serverCredential;
092            }
093    
094            public int getStatus() {
095                    return _status;
096            }
097    
098            private String _accountName;
099            private int _accountRid;
100            private byte[] _clientCredential;
101            private String _computerName;
102            private int _negotiateFlags;
103            private String _primaryName;
104            private short _secureChannelType;
105            private byte[] _serverCredential;
106            private int _status;
107    
108    }