1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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  }