001    /**
002     * Copyright (c) 2000-2010 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            public void decode(NdrBuffer ndrBuffer) {
035                    ndrBuffer.align(4);
036    
037                    int index = ndrBuffer.index;
038    
039                    ndrBuffer.advance(8);
040    
041                    _timestamp = ndrBuffer.dec_ndr_long();
042    
043                    ndrBuffer = ndrBuffer.derive(index);
044    
045                    for (int i = 0; i < 8; i++) {
046                            _credential[i] = (byte) ndrBuffer.dec_ndr_small();
047                    }
048            }
049            public void encode(NdrBuffer ndrBuffer) {
050                    ndrBuffer.align(4);
051    
052                    int index = ndrBuffer.index;
053    
054                    ndrBuffer.advance(8);
055    
056                    ndrBuffer.enc_ndr_long(_timestamp);
057    
058                    ndrBuffer = ndrBuffer.derive(index);
059    
060                    for (int i = 0; i < 8; i++) {
061                            ndrBuffer.enc_ndr_small(_credential[i]);
062                    }
063            }
064    
065            private byte[] _credential;
066            private int _timestamp;
067    
068    }