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 NetrServerReqChallenge extends DcerpcMessage {
024    
025            public NetrServerReqChallenge(
026                    String primaryName, String computerName, byte[] clientChallenge,
027                    byte[] serverChallenge) {
028    
029                    _primaryName = primaryName;
030                    _computerName = computerName;
031                    _clientChallenge = clientChallenge;
032                    _serverChallenge = serverChallenge;
033    
034                     ptype = 0;
035                     flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG;
036            }
037    
038            public void decode_out(NdrBuffer ndrBuffer) {
039                    int index = ndrBuffer.index;
040    
041                    ndrBuffer.advance(8);
042    
043                    ndrBuffer = ndrBuffer.derive(index);
044    
045                    for (int i = 0; i < 8; i++) {
046                            _serverChallenge[i] = (byte) ndrBuffer.dec_ndr_small();
047                    }
048    
049                    _status = ndrBuffer.dec_ndr_long();
050            }
051    
052            public void encode_in(NdrBuffer ndrBuffer) {
053                    ndrBuffer.enc_ndr_referent(_primaryName, 1);
054                    ndrBuffer.enc_ndr_string(_primaryName);
055                    ndrBuffer.enc_ndr_string(_computerName);
056    
057                    int index = ndrBuffer.index;
058    
059                    ndrBuffer.advance(8);
060    
061                    ndrBuffer = ndrBuffer.derive(index);
062    
063                    for (int i = 0; i < 8; i++) {
064                            ndrBuffer.enc_ndr_small(_clientChallenge[i]);
065                    }
066            }
067    
068            public int getOpnum() {
069                    return 4;
070            }
071    
072            public byte[] getServerChallenge() {
073                    return _serverChallenge;
074            }
075    
076            public int getStatus() {
077                    return _status;
078            }
079    
080            private byte[] _clientChallenge;
081            private String _computerName;
082            private String _primaryName;
083            private byte[] _serverChallenge;
084            private int _status;
085    
086    }