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.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    }