001    /**
002     * Copyright (c) 2000-2013 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.ndr.NdrBuffer;
018    import jcifs.dcerpc.ndr.NdrObject;
019    
020    /**
021     * @author Marcellus Tavares
022     */
023    public class NetlogonAuthenticator extends NdrObject {
024    
025            public NetlogonAuthenticator() {
026                    _credential = new byte[8];
027            }
028    
029            public NetlogonAuthenticator(byte[] credential, int timestamp) {
030                    _credential = credential;
031                    _timestamp = timestamp;
032            }
033    
034            @Override
035            public void decode(NdrBuffer ndrBuffer) {
036                    ndrBuffer.align(4);
037    
038                    int index = ndrBuffer.index;
039    
040                    ndrBuffer.advance(8);
041    
042                    _timestamp = ndrBuffer.dec_ndr_long();
043    
044                    ndrBuffer = ndrBuffer.derive(index);
045    
046                    for (int i = 0; i < 8; i++) {
047                            _credential[i] = (byte)ndrBuffer.dec_ndr_small();
048                    }
049            }
050    
051            @Override
052            public void encode(NdrBuffer ndrBuffer) {
053                    ndrBuffer.align(4);
054    
055                    int index = ndrBuffer.index;
056    
057                    ndrBuffer.advance(8);
058    
059                    ndrBuffer.enc_ndr_long(_timestamp);
060    
061                    ndrBuffer = ndrBuffer.derive(index);
062    
063                    for (int i = 0; i < 8; i++) {
064                            ndrBuffer.enc_ndr_small(_credential[i]);
065                    }
066            }
067    
068            private byte[] _credential;
069            private int _timestamp;
070    
071    }