1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.security.ntlm.msrpc;
16  
17  import jcifs.dcerpc.DcerpcMessage;
18  import jcifs.dcerpc.ndr.NdrBuffer;
19  
20  /**
21   * <a href="NetrServerReqChallenge.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Marcellus Tavares
24   */
25  public class NetrServerReqChallenge extends DcerpcMessage {
26  
27      public NetrServerReqChallenge(
28          String primaryName, String computerName, byte[] clientChallenge,
29          byte[] serverChallenge) {
30  
31          _primaryName = primaryName;
32          _computerName = computerName;
33          _clientChallenge = clientChallenge;
34          _serverChallenge = serverChallenge;
35  
36           ptype = 0;
37           flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG;
38      }
39  
40      public void decode_out(NdrBuffer ndrBuffer) {
41          int index = ndrBuffer.index;
42  
43          ndrBuffer.advance(8);
44  
45          ndrBuffer = ndrBuffer.derive(index);
46  
47          for (int i = 0; i < 8; i++) {
48              _serverChallenge[i] = (byte) ndrBuffer.dec_ndr_small();
49          }
50  
51          _status = ndrBuffer.dec_ndr_long();
52      }
53  
54      public void encode_in(NdrBuffer ndrBuffer) {
55          ndrBuffer.enc_ndr_referent(_primaryName, 1);
56          ndrBuffer.enc_ndr_string(_primaryName);
57          ndrBuffer.enc_ndr_string(_computerName);
58  
59          int index = ndrBuffer.index;
60  
61          ndrBuffer.advance(8);
62  
63          ndrBuffer = ndrBuffer.derive(index);
64  
65          for (int i = 0; i < 8; i++) {
66              ndrBuffer.enc_ndr_small(_clientChallenge[i]);
67          }
68      }
69  
70      public int getOpnum() {
71          return 4;
72      }
73  
74      public byte[] getServerChallenge() {
75          return _serverChallenge;
76      }
77  
78      public int getStatus() {
79          return _status;
80      }
81  
82      private byte[] _clientChallenge;
83      private String _computerName;
84      private String _primaryName;
85      private byte[] _serverChallenge;
86      private int _status;
87  
88  }