/*  GetPrincipalInfo.java by Mark D. LaDue */

/*  April 12, 1998 */

/*  Copyright (c) 1998 Mark D. LaDue
    You may study, use, modify, and distribute this example for any purpose.
    This example is provided WITHOUT WARRANTY either expressed or implied.  */

/*  This is the simple "encoder" used by the Impostor to exploit the
    Principal.encode() method.  Who said that an encoder has to encode?  */

import netscape.applet.*;
import netscape.security.*;
import netscape.util.*;

public class GetPrincipalInfo implements netscape.util.Encoder {

    public int itsType;
    public int itsHashCode;
    public String itsStringRep;
    public byte itsBinaryRep[];
    public byte itsFingerprint[];
    public byte itsCertKey[];

    public int intcount = 0;
    public int strcount = 0;
    public int bacount = 0;

    public void encodeInt(String s, int i)
    throws CodingException {
        if (intcount == 0) {itsType = i;}
        if (intcount == 1) {itsHashCode = i;}
        intcount++;
    }

    public void encodeString(String s, String s1)
    throws CodingException {
        if (strcount == 0) {itsStringRep = s1;}
        strcount++;
    }

    public void encodeByteArray(String s, byte abyte0[], int i, int j)
    throws CodingException {
        if (bacount == 0) {itsBinaryRep = abyte0;}
        if (bacount == 1) {itsFingerprint = abyte0;}
        if (bacount == 2) {itsCertKey = abyte0;}
        bacount++;
    }

    public void printInfo() {
        System.out.println("itsType = " + itsType);
        System.out.println("itsHashCode = " + itsHashCode);
        if (itsStringRep != null) {
            System.out.println("itsStringRep = " + itsStringRep);
        }
        else {System.out.println("itsStringRep = null");}
        if (itsBinaryRep != null) {
            System.out.println("itsBinaryRep = " + itsBinaryRep.toString());
        }
        else {System.out.println("itsBinaryRep = null");}
        if (itsFingerprint != null) {
            System.out.println("itsFingerprint = " + itsFingerprint.toString());
        }
        else {System.out.println("itsFingerprint = null");}
        if (itsCertKey != null) {
            System.out.println("itsCertKey = " + itsCertKey.toString());
        }
        else {System.out.println("itsCertKey = null");}
        System.out.println();
    }

    public void encodeBoolean(String s, boolean flag)
    throws CodingException {}

    public void encodeBooleanArray(String s, boolean aflag[], int i, int j)
    throws CodingException {}

    public void encodeChar(String s, char c)
    throws CodingException {}

    public void encodeCharArray(String s, char ac[], int i, int j)
    throws CodingException {}

    public void encodeByte(String s, byte byte0)
    throws CodingException {}

    public void encodeShort(String s, short word0)
    throws CodingException {}

    public void encodeShortArray(String s, short aword0[], int i, int j)
    throws CodingException {}

    public void encodeIntArray(String s, int ai[], int i, int j)
    throws CodingException {}

    public void encodeLong(String s, long l)
    throws CodingException {}

    public void encodeLongArray(String s, long al[], int i, int j)
    throws CodingException {}

    public void encodeFloat(String s, float f)
    throws CodingException {}

    public void encodeFloatArray(String s, float af[], int i, int j)
    throws CodingException {}

    public void encodeDouble(String s, double d)
    throws CodingException {}

    public void encodeDoubleArray(String s, double ad[], int i, int j)
    throws CodingException {}

    public void encodeStringArray(String s, String as[], int i, int j)
    throws CodingException {}

    public void encodeObject(String s, Object obj)
    throws CodingException {}

    public void encodeObjectArray(String s, Object aobj[], int i, int j)
    throws CodingException {}



}

