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="NetrServerAuthenticate3.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Marcellus Tavares
24   */
25  public class NetrServerAuthenticate3 extends DcerpcMessage {
26  
27      public NetrServerAuthenticate3(
28          String primaryName, String accountName, int secureChannelType,
29          String computerName, byte[] clientCredential, byte[] serverCredential,
30          int negotiateFlags) {
31  
32          _primaryName = primaryName;
33          _accountName = accountName;
34          _secureChannelType = (short) secureChannelType;
35          _computerName = computerName;
36          _clientCredential = clientCredential;
37          _serverCredential = serverCredential;
38          _negotiateFlags = negotiateFlags;
39  
40          ptype = 0;
41          flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG;
42      }
43  
44      public void decode_out(NdrBuffer ndrBuffer) {
45          int index = ndrBuffer.index;
46  
47          ndrBuffer.advance(8);
48  
49          ndrBuffer = ndrBuffer.derive(index);
50  
51          for (int i = 0; i < 8; i++) {
52              _serverCredential[i] = (byte) ndrBuffer.dec_ndr_small();
53          }
54  
55          _negotiateFlags = ndrBuffer.dec_ndr_long();
56          _accountRid = ndrBuffer.dec_ndr_long();
57          _status = ndrBuffer.dec_ndr_long();
58      }
59  
60      public void encode_in(NdrBuffer ndrBuffer) {
61          ndrBuffer.enc_ndr_referent(_primaryName, 1);
62          ndrBuffer.enc_ndr_string(_primaryName);
63          ndrBuffer.enc_ndr_string(_accountName);
64          ndrBuffer.enc_ndr_short(_secureChannelType);
65          ndrBuffer.enc_ndr_string(_computerName);
66  
67          int index = ndrBuffer.index;
68  
69          ndrBuffer.advance(8);
70  
71          NdrBuffer derivedNrdBuffer = ndrBuffer.derive(index);
72  
73          for (int i = 0; i < 8; i++) {
74              derivedNrdBuffer.enc_ndr_small(_clientCredential[i]);
75          }
76  
77          ndrBuffer.enc_ndr_long(_negotiateFlags);
78      }
79  
80      public int getAccountRid() {
81          return _accountRid;
82      }
83  
84      public int getNegotiatedFlags() {
85          return _negotiateFlags;
86      }
87  
88      public int getOpnum() {
89          return 26;
90      }
91  
92      public byte[] getServerCredential() {
93          return _serverCredential;
94      }
95  
96      public int getStatus() {
97          return _status;
98      }
99  
100     private String _accountName;
101     private int _accountRid;
102     private byte[] _clientCredential;
103     private String _computerName;
104     private int _negotiateFlags;
105     private String _primaryName;
106     private short _secureChannelType;
107     private byte[] _serverCredential;
108     private int _status;
109 
110 }