LastReqEntry.java revision 0
328N/A/*
328N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
328N/A *
328N/A * This code is free software; you can redistribute it and/or modify it
328N/A * under the terms of the GNU General Public License version 2 only, as
328N/A * published by the Free Software Foundation. Sun designates this
328N/A * particular file as subject to the "Classpath" exception as provided
328N/A * by Sun in the LICENSE file that accompanied this code.
328N/A *
328N/A * This code is distributed in the hope that it will be useful, but WITHOUT
328N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
328N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
328N/A * version 2 for more details (a copy is included in the LICENSE file that
328N/A * accompanied this code).
328N/A *
328N/A * You should have received a copy of the GNU General Public License version
328N/A * 2 along with this work; if not, write to the Free Software Foundation,
328N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
328N/A *
328N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
328N/A * CA 95054 USA or visit www.sun.com if you need additional information or
328N/A * have any questions.
3661N/A */
328N/A
328N/A/*
328N/A *
328N/A * (C) Copyright IBM Corp. 1999 All Rights Reserved.
328N/A * Copyright 1997 The Open Group Research Institute. All rights reserved.
1195N/A */
328N/A
328N/Apackage sun.security.krb5.internal;
328N/A
844N/Aimport sun.security.util.*;
1195N/Aimport sun.security.krb5.Asn1Exception;
328N/Aimport java.io.IOException;
1273N/A
328N/Apublic class LastReqEntry {
3661N/A private int lrType;
3661N/A private KerberosTime lrValue;
328N/A
328N/A private LastReqEntry() {
328N/A }
328N/A
1195N/A public LastReqEntry(int Type, KerberosTime time){
1195N/A lrType = Type;
1195N/A lrValue = time;
328N/A // XXX check the type and time.
328N/A }
328N/A
328N/A /**
2238N/A * Constructs a LastReqEntry object.
328N/A * @param encoding a Der-encoded data.
328N/A * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
480N/A * @exception IOException if an I/O error occurs while reading encoded data.
480N/A */
480N/A public LastReqEntry(DerValue encoding) throws Asn1Exception, IOException {
328N/A if (encoding.getTag() != DerValue.tag_Sequence) {
328N/A throw new Asn1Exception(Krb5.ASN1_BAD_ID);
328N/A }
882N/A DerValue der;
2238N/A der = encoding.getData().getDerValue();
2238N/A if ((der.getTag() & 0x1F) == 0x00){
2238N/A lrType = der.getData().getBigInteger().intValue();
1195N/A }
328N/A else
328N/A throw new Asn1Exception(Krb5.ASN1_BAD_ID);
328N/A
328N/A lrValue = KerberosTime.parse(encoding.getData(), (byte)0x01, false);
328N/A if (encoding.getData().available() > 0)
328N/A throw new Asn1Exception(Krb5.ASN1_BAD_ID);
328N/A }
328N/A
1195N/A /**
1195N/A * Encodes an LastReqEntry object.
1195N/A * @return the byte array of encoded LastReqEntry object.
1195N/A * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
1195N/A * @exception IOException if an I/O error occurs while reading encoded data.
1195N/A */
1195N/A public byte[] asn1Encode() throws Asn1Exception, IOException {
1195N/A DerOutputStream bytes = new DerOutputStream();
1195N/A DerOutputStream temp = new DerOutputStream();
1195N/A temp.putInteger(lrType);
1195N/A bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
1195N/A bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), lrValue.asn1Encode());
1195N/A temp = new DerOutputStream();
1195N/A temp.write(DerValue.tag_Sequence, bytes);
1195N/A return temp.toByteArray();
1195N/A }
1195N/A
328N/A public Object clone() {
328N/A LastReqEntry newEntry = new LastReqEntry();
328N/A newEntry.lrType = lrType;
328N/A newEntry.lrValue = (KerberosTime)lrValue.clone();
328N/A return newEntry;
328N/A }
328N/A}
328N/A