not-yet-commons-ssl-0.3.11

tends FilterOutputStream
  implements DERTags
{
  public DEROutputStream(OutputStream os)
  {
    super(os);
  }
  
  private void writeLength(int length)
    throws IOException
  {
    if (length > 127)
    {
      int size = 1;
      int val = length;
      while (val >>>= 8 != 0) {
        size++;
      }
      write((byte)(size | 0x80));
      for (int i = (size - 1) * 8; i >= 0; i -= 8) {
        write((byte)(length >> i));
      }
    }
    else
    {
      write((byte)length);
    }
  }
  
  void writeEncoded(int tag, byte[] bytes)
    throws IOException
  {
    write(tag);
    writeLength(bytes.length);
    write(bytes);
  }
  
  protected void writeNull()
    throws IOException
  {
    write(5);
    write(0);
  }
  
  public void write(byte[] buf)
    throws IOException
  {
    out.write(buf, 0, buf.length);
  }
  
  public void write(byte[] buf, int offSet, int len)
    throws IOException
  {
    out.write(buf, offSet, len);
  }
  
  public void writeObject(Object obj)
    throws IOException
  {
    if (obj == null) {
      writeNull();
    } else if ((obj instanceof DERObject)) {
      ((DERObject)obj).encode(this);
    } else if ((obj instanceof DEREncodable)) {
      ((DEREncodable)obj).getDERObject().encode(this);
    } else {
      throw new IOException("object not DEREncodable");
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DEROutputStream
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.IOException;

public class DERPrintableString
  extends ASN1Object
  implements DERString
{
  String string;
  
  public static DERPrintableString getInstance(Object obj)
  {
    if ((obj == null) || ((obj instanceof DERPrintableString))) {
      return (DERPrintableString)obj;
    }
    if ((obj instanceof ASN1OctetString)) {
      return new DERPrintableString(((ASN1OctetString)obj).getOctets());
    }
    if ((obj instanceof ASN1TaggedObject)) {
      return getInstance(((ASN1TaggedObject)obj).getObject());
    }
    throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
  }
  
  public static DERPrintableString getInstance(ASN1TaggedObject obj, boolean explicit)
  {
    return getInstance(obj.getObject());
  }
  
  public DERPrintableString(byte[] string)
  {
    char[] cs = new char[string.length];
    for (int i = 0; i != cs.length; i++) {
      cs[i] = ((char)(string[i] & 0xFF));
    }
    this.string = new String(cs);
  }
  
  public DERPrintableString(String string)
  {
    this(string, false);
  }
  
  public DERPrintableString(String string, boolean validate)
  {
    if ((validate) && (!isPrintableString(string))) {
      throw new IllegalArgumentException("string contains illegal characters");
    }
    this.string = string;
  }
  
  public String getString()
  {
    return string;
  }
  
  public byte[] getOctets()
  {
    char[] cs = string.toCharArray();
    byte[] bs = new byte[cs.length];
    for (int i = 0; i != cs.length; i++) {
      bs[i] = ((byte)cs[i]);
    }
    return bs;
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    out.writeEncoded(19, getOctets());
  }
  
  public int hashCode()
  {
    return getString().hashCode();
  }
  
  boolean asn1Equals(DERObject o)
  {
    if (!(o instanceof DERPrintableString)) {
      return false;
    }
    DERPrintableString s = (DERPrintableString)o;
    
    return getString().equals(s.getString());
  }
  
  public String toString()
  {
    return string;
  }
  
  public static boolean isPrintableString(String str)
  {
    for (int i = str.length() - 1; i >= 0; i--)
    {
      char ch = str.charAt(i);
      if (ch > '') {
        return false;
      }
      if (('a' > ch) || (ch > 'z')) {
        if (('A' > ch) || (ch > 'Z')) {
          if (('0' > ch) || (ch > '9')) {
            switch (ch)
            {
            case ' ': 
            case '\'': 
            case '(': 
            case ')': 
            case '+': 
            case ',': 
            case '-': 
            case '.': 
            case '/': 
            case ':': 
            case '=': 
            case '?': 
              break;
            case '!': 
            case '"': 
            case '#': 
            case '$': 
            case '%': 
            case '&': 
            case '*': 
            case '0': 
            case '1': 
            case '2': 
            case '3': 
            case '4': 
            case '5': 
            case '6': 
            case '7': 
            case '8': 
            case '9': 
            case ';': 
            case '<': 
            case '>': 
            default: 
              return false;
            }
          }
        }
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERPrintableString
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Enumeration;

public class DERSequence
  extends ASN1Sequence
{
  public DERSequence() {}
  
  public DERSequence(DEREncodable obj)
  {
    addObject(obj);
  }
  
  public DERSequence(DEREncodableVector v)
  {
    for (int i = 0; i != v.size(); i++) {
      addObject(v.get(i));
    }
  }
  
  public DERSequence(ASN1Encodable[] a)
  {
    for (int i = 0; i != a.length; i++) {
      addObject(a[i]);
    }
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    DEROutputStream dOut = new DEROutputStream(bOut);
    Enumeration e = getObjects();
    while (e.hasMoreElements())
    {
      Object obj = e.nextElement();
      
      dOut.writeObject(obj);
    }
    dOut.close();
    
    byte[] bytes = bOut.toByteArray();
    
    out.writeEncoded(48, bytes);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERSequence
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class DERSequenceGenerator
  extends DERGenerator
{
  private final ByteArrayOutputStream _bOut = new ByteArrayOutputStream();
  
  public DERSequenceGenerator(OutputStream out)
    throws IOException
  {
    super(out);
  }
  
  public DERSequenceGenerator(OutputStream out, int tagNo, boolean isExplicit)
    throws IOException
  {
    super(out, tagNo, isExplicit);
  }
  
  public void addObject(DEREncodable object)
    throws IOException
  {
    object.getDERObject().encode(new DEROutputStream(_bOut));
  }
  
  public OutputStream getRawOutputStream()
  {
    return _bOut;
  }
  
  public void close()
    throws IOException
  {
    writeDEREncoded(48, _bOut.toByteArray());
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERSequenceGenerator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Enumeration;

public class DERSet
  extends ASN1Set
{
  public DERSet() {}
  
  public DERSet(DEREncodable obj)
  {
    addObject(obj);
  }
  
  public DERSet(DEREncodableVector v)
  {
    this(v, true);
  }
  
  public DERSet(ASN1Encodable[] a)
  {
    for (int i = 0; i != a.length; i++) {
      addObject(a[i]);
    }
    sort();
  }
  
  DERSet(DEREncodableVector v, boolean needsSorting)
  {
    for (int i = 0; i != v.size(); i++) {
      addObject(v.get(i));
    }
    if (needsSorting) {
      sort();
    }
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    DEROutputStream dOut = new DEROutputStream(bOut);
    Enumeration e = getObjects();
    while (e.hasMoreElements())
    {
      Object obj = e.nextElement();
      
      dOut.writeObject(obj);
    }
    dOut.close();
    
    byte[] bytes = bOut.toByteArray();
    
    out.writeEncoded(49, bytes);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERSet
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

public abstract interface DERString
{
  public abstract String getString();
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERString
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.IOException;

public class DERT61String
  extends ASN1Object
  implements DERString
{
  String string;
  
  public static DERT61String getInstance(Object obj)
  {
    if ((obj == null) || ((obj instanceof DERT61String))) {
      return (DERT61String)obj;
    }
    if ((obj instanceof ASN1OctetString)) {
      return new DERT61String(((ASN1OctetString)obj).getOctets());
    }
    if ((obj instanceof ASN1TaggedObject)) {
      return getInstance(((ASN1TaggedObject)obj).getObject());
    }
    throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
  }
  
  public static DERT61String getInstance(ASN1TaggedObject obj, boolean explicit)
  {
    return getInstance(obj.getObject());
  }
  
  public DERT61String(byte[] string)
  {
    char[] cs = new char[string.length];
    for (int i = 0; i != cs.length; i++) {
      cs[i] = ((char)(string[i] & 0xFF));
    }
    this.string = new String(cs);
  }
  
  public DERT61String(String string)
  {
    this.string = string;
  }
  
  public String getString()
  {
    return string;
  }
  
  public String toString()
  {
    return string;
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    out.writeEncoded(20, getOctets());
  }
  
  public byte[] getOctets()
  {
    char[] cs = string.toCharArray();
    byte[] bs = new byte[cs.length];
    for (int i = 0; i != cs.length; i++) {
      bs[i] = ((byte)cs[i]);
    }
    return bs;
  }
  
  boolean asn1Equals(DERObject o)
  {
    if (!(o instanceof DERT61String)) {
      return false;
    }
    return getString().equals(((DERT61String)o).getString());
  }
  
  public int hashCode()
  {
    return getString().hashCode();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERT61String
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class DERTaggedObject
  extends ASN1TaggedObject
{
  public DERTaggedObject(int tagNo, DEREncodable obj)
  {
    super(tagNo, obj);
  }
  
  public DERTaggedObject(boolean explicit, int tagNo, DEREncodable obj)
  {
    super(explicit, tagNo, obj);
  }
  
  public DERTaggedObject(int tagNo)
  {
    super(false, tagNo, new DERSequence());
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    if (!empty)
    {
      ByteArrayOutputStream bOut = new ByteArrayOutputStream();
      DEROutputStream dOut = new DEROutputStream(bOut);
      
      dOut.writeObject(obj);
      dOut.close();
      
      byte[] bytes = bOut.toByteArray();
      if (explicit)
      {
        out.writeEncoded(0xA0 | tagNo, bytes);
      }
      else
      {
        if ((bytes[0] & 0x20) != 0) {
          bytes[0] = ((byte)(0xA0 | tagNo));
        } else {
          bytes[0] = ((byte)(0x80 | tagNo));
        }
        out.write(bytes);
      }
    }
    else
    {
      out.writeEncoded(0xA0 | tagNo, new byte[0]);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERTaggedObject
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

public abstract interface DERTags
{
  public static final int BOOLEAN = 1;
  public static final int INTEGER = 2;
  public static final int BIT_STRING = 3;
  public static final int OCTET_STRING = 4;
  public static final int NULL = 5;
  public static final int OBJECT_IDENTIFIER = 6;
  public static final int EXTERNAL = 8;
  public static final int ENUMERATED = 10;
  public static final int SEQUENCE = 16;
  public static final int SEQUENCE_OF = 16;
  public static final int SET = 17;
  public static final int SET_OF = 17;
  public static final int NUMERIC_STRING = 18;
  public static final int PRINTABLE_STRING = 19;
  public static final int T61_STRING = 20;
  public static final int VIDEOTEX_STRING = 21;
  public static final int IA5_STRING = 22;
  public static final int UTC_TIME = 23;
  public static final int GENERALIZED_TIME = 24;
  public static final int GRAPHIC_STRING = 25;
  public static final int VISIBLE_STRING = 26;
  public static final int GENERAL_STRING = 27;
  public static final int UNIVERSAL_STRING = 28;
  public static final int BMP_STRING = 30;
  public static final int UTF8_STRING = 12;
  public static final int CONSTRUCTED = 32;
  public static final int APPLICATION = 64;
  public static final int TAGGED = 128;
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERTags
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;

public class DERUTCTime
  extends ASN1Object
{
  String time;
  
  public static DERUTCTime getInstance(Object obj)
  {
    if ((obj == null) || ((obj instanceof DERUTCTime))) {
      return (DERUTCTime)obj;
    }
    if ((obj instanceof ASN1OctetString)) {
      return new DERUTCTime(((ASN1OctetString)obj).getOctets());
    }
    throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
  }
  
  public static DERUTCTime getInstance(ASN1TaggedObject obj, boolean explicit)
  {
    return getInstance(obj.getObject());
  }
  
  public DERUTCTime(String time)
  {
    this.time = time;
    try
    {
      getDate();
    }
    catch (ParseException e)
    {
      throw new IllegalArgumentException("invalid date string: " + e.getMessage());
    }
  }
  
  public DERUTCTime(Date time)
  {
    SimpleDateFormat dateF = new SimpleDateFormat("yyMMddHHmmss'Z'");
    
    dateF.setTimeZone(new SimpleTimeZone(0, "Z"));
    
    this.time = dateF.format(time);
  }
  
  DERUTCTime(byte[] bytes)
  {
    char[] dateC = new char[bytes.length];
    for (int i = 0; i != dateC.length; i++) {
      dateC[i] = ((char)(bytes[i] & 0xFF));
    }
    time = new String(dateC);
  }
  
  public Date getDate()
    throws ParseException
  {
    SimpleDateFormat dateF = new SimpleDateFormat("yyMMddHHmmssz");
    
    return dateF.parse(getTime());
  }
  
  public Date getAdjustedDate()
    throws ParseException
  {
    SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmssz");
    
    dateF.setTimeZone(new SimpleTimeZone(0, "Z"));
    
    return dateF.parse(getAdjustedTime());
  }
  
  public String getTime()
  {
    if ((time.indexOf('-') < 0) && (time.indexOf('+') < 0))
    {
      if (time.length() == 11) {
        return time.substring(0, 10) + "00GMT+00:00";
      }
      return time.substring(0, 12) + "GMT+00:00";
    }
    int index = time.indexOf('-');
    if (index < 0) {
      index = time.indexOf('+');
    }
    String d = time;
    if (index == time.length() - 3) {
      d = d + "00";
    }
    if (index == 10) {
      return d.substring(0, 10) + "00GMT" + d.substring(10, 13) + ":" + d.substring(13, 15);
    }
    return d.substring(0, 12) + "GMT" + d.substring(12, 15) + ":" + d.substring(15, 17);
  }
  
  public String getAdjustedTime()
  {
    String d = getTime();
    if (d.charAt(0) < '5') {
      return "20" + d;
    }
    return "19" + d;
  }
  
  private byte[] getOctets()
  {
    char[] cs = time.toCharArray();
    byte[] bs = new byte[cs.length];
    for (int i = 0; i != cs.length; i++) {
      bs[i] = ((byte)cs[i]);
    }
    return bs;
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    out.writeEncoded(23, getOctets());
  }
  
  boolean asn1Equals(DERObject o)
  {
    if (!(o instanceof DERUTCTime)) {
      return false;
    }
    return time.equals(time);
  }
  
  public int hashCode()
  {
    return time.hashCode();
  }
  
  public String toString()
  {
    return time;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERUTCTime
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.IOException;

public class DERUTF8String
  extends ASN1Object
  implements DERString
{
  String string;
  
  public static DERUTF8String getInstance(Object obj)
  {
    if ((obj == null) || ((obj instanceof DERUTF8String))) {
      return (DERUTF8String)obj;
    }
    if ((obj instanceof ASN1OctetString)) {
      return new DERUTF8String(((ASN1OctetString)obj).getOctets());
    }
    if ((obj instanceof ASN1TaggedObject)) {
      return getInstance(((ASN1TaggedObject)obj).getObject());
    }
    throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
  }
  
  public static DERUTF8String getInstance(ASN1TaggedObject obj, boolean explicit)
  {
    return getInstance(obj.getObject());
  }
  
  DERUTF8String(byte[] string)
  {
    this.string = Strings.fromUTF8ByteArray(string);
  }
  
  public DERUTF8String(String string)
  {
    this.string = string;
  }
  
  public String getString()
  {
    return string;
  }
  
  public String toString()
  {
    return string;
  }
  
  public int hashCode()
  {
    return getString().hashCode();
  }
  
  boolean asn1Equals(DERObject o)
  {
    if (!(o instanceof DERUTF8String)) {
      return false;
    }
    DERUTF8String s = (DERUTF8String)o;
    
    return getString().equals(s.getString());
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    out.writeEncoded(12, Strings.toUTF8ByteArray(string));
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERUTF8String
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class DERUniversalString
  extends ASN1Object
  implements DERString
{
  private static final char[] table = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
  private byte[] string;
  
  public static DERUniversalString getInstance(Object obj)
  {
    if ((obj == null) || ((obj instanceof DERUniversalString))) {
      return (DERUniversalString)obj;
    }
    if ((obj instanceof ASN1OctetString)) {
      return new DERUniversalString(((ASN1OctetString)obj).getOctets());
    }
    throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
  }
  
  public static DERUniversalString getInstance(ASN1TaggedObject obj, boolean explicit)
  {
    return getInstance(obj.getObject());
  }
  
  public DERUniversalString(byte[] string)
  {
    this.string = string;
  }
  
  public String getString()
  {
    StringBuffer buf = new StringBuffer("#");
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    ASN1OutputStream aOut = new ASN1OutputStream(bOut);
    try
    {
      aOut.writeObject(this);
    }
    catch (IOException e)
    {
      throw new RuntimeException("internal error encoding BitString");
    }
    byte[] string = bOut.toByteArray();
    for (int i = 0; i != string.length; i++)
    {
      buf.append(table[(string[i] >>> 4 & 0xF)]);
      buf.append(table[(string[i] & 0xF)]);
    }
    return buf.toString();
  }
  
  public String toString()
  {
    return getString();
  }
  
  public byte[] getOctets()
  {
    return string;
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    out.writeEncoded(28, getOctets());
  }
  
  boolean asn1Equals(DERObject o)
  {
    if (!(o instanceof DERUniversalString)) {
      return false;
    }
    return getString().equals(((DERUniversalString)o).getString());
  }
  
  public int hashCode()
  {
    return getString().hashCode();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERUniversalString
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.IOException;

public class DERUnknownTag
  extends DERObject
{
  int tag;
  byte[] data;
  
  public DERUnknownTag(int tag, byte[] data)
  {
    this.tag = tag;
    this.data = data;
  }
  
  public int getTag()
  {
    return tag;
  }
  
  public byte[] getData()
  {
    return data;
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    out.writeEncoded(tag, data);
  }
  
  public boolean equals(Object o)
  {
    if (!(o instanceof DERUnknownTag)) {
      return false;
    }
    DERUnknownTag other = (DERUnknownTag)o;
    if (tag != tag) {
      return false;
    }
    if (data.length != data.length) {
      return false;
    }
    for (int i = 0; i < data.length; i++) {
      if (data[i] != data[i]) {
        return false;
      }
    }
    return true;
  }
  
  public int hashCode()
  {
    byte[] b = getData();
    int value = 0;
    for (int i = 0; i != b.length; i++) {
      value ^= (b[i] & 0xFF) << i % 4;
    }
    return value ^ getTag();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERUnknownTag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.IOException;

public class DERVisibleString
  extends ASN1Object
  implements DERString
{
  String string;
  
  public static DERVisibleString getInstance(Object obj)
  {
    if ((obj == null) || ((obj instanceof DERVisibleString))) {
      return (DERVisibleString)obj;
    }
    if ((obj instanceof ASN1OctetString)) {
      return new DERVisibleString(((ASN1OctetString)obj).getOctets());
    }
    if ((obj instanceof ASN1TaggedObject)) {
      return getInstance(((ASN1TaggedObject)obj).getObject());
    }
    throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
  }
  
  public static DERVisibleString getInstance(ASN1TaggedObject obj, boolean explicit)
  {
    return getInstance(obj.getObject());
  }
  
  public DERVisibleString(byte[] string)
  {
    char[] cs = new char[string.length];
    for (int i = 0; i != cs.length; i++) {
      cs[i] = ((char)(string[i] & 0xFF));
    }
    this.string = new String(cs);
  }
  
  public DERVisibleString(String string)
  {
    this.string = string;
  }
  
  public String getString()
  {
    return string;
  }
  
  public String toString()
  {
    return string;
  }
  
  public byte[] getOctets()
  {
    char[] cs = string.toCharArray();
    byte[] bs = new byte[cs.length];
    for (int i = 0; i != cs.length; i++) {
      bs[i] = ((byte)cs[i]);
    }
    return bs;
  }
  
  void encode(DEROutputStream out)
    throws IOException
  {
    out.writeEncoded(26, getOctets());
  }
  
  boolean asn1Equals(DERObject o)
  {
    if (!(o instanceof DERVisibleString)) {
      return false;
    }
    return getString().equals(((DERVisibleString)o).getString());
  }
  
  public int hashCode()
  {
    return getString().hashCode();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DERVisibleString
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;

class DefiniteLengthInputStream
  extends LimitedInputStream
{
  private int _length;
  
  DefiniteLengthInputStream(InputStream in, int length)
  {
    super(in);
    if (length < 0) {
      throw new IllegalArgumentException("negative lengths not allowed");
    }
    _length = length;
  }
  
  public int read()
    throws IOException
  {
    if (_length > 0)
    {
      int b = _in.read();
      if (b < 0) {
        throw new EOFException();
      }
      _length -= 1;
      return b;
    }
    setParentEofDetect(true);
    
    return -1;
  }
  
  public int read(byte[] buf, int off, int len)
    throws IOException
  {
    if (_length > 0)
    {
      int toRead = Math.min(len, _length);
      int numRead = _in.read(buf, off, toRead);
      if (numRead < 0) {
        throw new EOFException();
      }
      _length -= numRead;
      return numRead;
    }
    setParentEofDetect(true);
    
    return -1;
  }
  
  byte[] toByteArray()
    throws IOException
  {
    byte[] bytes = new byte[_length];
    if (_length > 0)
    {
      int pos = 0;
      do
      {
        int read = _in.read(bytes, pos, _length - pos);
        if (read < 0) {
          throw new EOFException();
        }
        pos += read;
      } while (pos < _length);
      _length = 0;
    }
    setParentEofDetect(true);
    
    return bytes;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.DefiniteLengthInputStream
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.IOException;
import java.io.InputStream;

class IndefiniteLengthInputStream
  extends LimitedInputStream
{
  private int _b1;
  private int _b2;
  private boolean _eofReached = false;
  private boolean _eofOn00 = true;
  
  IndefiniteLengthInputStream(InputStream in)
    throws IOException
  {
    super(in);
    
    _b1 = in.read();
    _b2 = in.read();
    _eofReached = (_b2 < 0);
  }
  
  void setEofOn00(boolean eofOn00)
  {
    _eofOn00 = eofOn00;
  }
  
  boolean checkForEof()
  {
    if ((_eofOn00) && (_b1 == 0) && (_b2 == 0))
    {
      _eofReached = true;
      setParentEofDetect(true);
    }
    return _eofReached;
  }
  
  public int read(byte[] b, int off, int len)
    throws IOException
  {
    if ((_eofOn00) || (len < 3)) {
      return super.read(b, off, len);
    }
    if (_eofReached) {
      return -1;
    }
    int numRead = _in.read(b, off + 2, len - 2);
    if (numRead < 0)
    {
      _eofReached = true;
      return -1;
    }
    b[off] = ((byte)_b1);
    b[(off + 1)] = ((byte)_b2);
    
    _b1 = _in.read();
    _b2 = _in.read();
    if (_b2 < 0) {
      _eofReached = true;
    }
    return numRead + 2;
  }
  
  public int read()
    throws IOException
  {
    if (checkForEof()) {
      return -1;
    }
    int b = _in.read();
    if (b < 0)
    {
      _eofReached = true;
      
      return -1;
    }
    int v = _b1;
    
    _b1 = _b2;
    _b2 = b;
    
    return v;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.IndefiniteLengthInputStream
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.InputStream;

abstract class LimitedInputStream
  extends InputStream
{
  protected final InputStream _in;
  
  LimitedInputStream(InputStream in)
  {
    _in = in;
  }
  
  InputStream getUnderlyingStream()
  {
    return _in;
  }
  
  protected void setParentEofDetect(boolean on)
  {
    if ((_in instanceof IndefiniteLengthInputStream)) {
      ((IndefiniteLengthInputStream)_in).setEofOn00(on);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.LimitedInputStream
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

public class OIDTokenizer
{
  private String oid;
  private int index;
  
  public OIDTokenizer(String oid)
  {
    this.oid = oid;
    index = 0;
  }
  
  public boolean hasMoreTokens()
  {
    return index != -1;
  }
  
  public String nextToken()
  {
    if (index == -1) {
      return null;
    }
    int end = oid.indexOf('.', index);
    if (end == -1)
    {
      String token = oid.substring(index);
      index = -1;
      return token;
    }
    String token = oid.substring(index, end);
    
    index = (end + 1);
    return token;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.OIDTokenizer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.asn1;

import java.io.ByteArrayOutputStream;
import java.util.Vector;

public final class Strings
{
  public static String fromUTF8ByteArray(byte[] bytes)
  {
    int i = 0;
    int length = 0;
    while (i < bytes.length)
    {
      length++;
      if ((bytes[i] & 0xF0) == 240)
      {
        length++;
        i += 4;
      }
      else if ((bytes[i] & 0xE0) == 224)
      {
        i += 3;
      }
      else if ((bytes[i] & 0xC0) == 192)
      {
        i += 2;
      }
      else
      {
        i++;
      }
    }
    char[] cs = new char[length];
    
    i = 0;
    length = 0;
    while (i < bytes.length)
    {
      char ch;
      if ((bytes[i] & 0xF0) == 240)
      {
        int codePoint = (bytes[i] & 0x3) << 18 | (bytes[(i + 1)] & 0x3F) << 12 | (bytes[(i + 2)] & 0x3F) << 6 | bytes[(i + 3)] & 0x3F;
        int U = codePoint - 65536;
        char W1 = (char)(0xD800 | U >> 10);
        char W2 = (char)(0xDC00 | U & 0x3FF);
        cs[(length++)] = W1;
        char ch = W2;
        i += 4;
      }
      else if ((bytes[i] & 0xE0) == 224)
      {
        char ch = (char)((bytes[i] & 0xF) << 12 | (bytes[(i + 1)] & 0x3F) << 6 | bytes[(i + 2)] & 0x3F);
        
        i += 3;
      }
      else if ((bytes[i] & 0xD0) == 208)
      {
        char ch = (char)((bytes[i] & 0x1F) << 6 | bytes[(i + 1)] & 0x3F);
        i += 2;
      }
      else if ((bytes[i] & 0xC0) == 192)
      {
        char ch = (char)((bytes[i] & 0x1F) << 6 | bytes[(i + 1)] & 0x3F);
        i += 2;
      }
      else
      {
        ch = (char)(bytes[i] & 0xFF);
        i++;
      }
      cs[(length++)] = ch;
    }
    return new String(cs);
  }
  
  public static byte[] toUTF8ByteArray(String string)
  {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    char[] c = string.toCharArray();
    int i = 0;
    while (i < c.length)
    {
      char ch = c[i];
      if (ch < '?')
      {
        bOut.write(ch);
      }
      else if (ch < '?')
      {
        bOut.write(0xC0 | ch >> '\006');
        bOut.write(0x80 | ch & 0x3F);
      }
      else if ((ch >= 55296) && (ch <= 57343))
      {
        if (i + 1 >= c.length) {
          throw new IllegalStateException("invalid UTF-16 codepoint");
        }
        char W1 = ch;
        ch = c[(++i)];
        char W2 = ch;
        if (W1 > 56319) {
          throw new IllegalStateException("invalid UTF-16 codepoint");
        }
        int codePoint = ((W1 & 0x3FF) << '\n' | W2 & 0x3FF) + 65536;
        bOut.write(0xF0 | codePoint >> 18);
        bOut.write(0x80 | codePoint >> 12 & 0x3F);
        bOut.write(0x80 | codePoint >> 6 & 0x3F);
        bOut.write(0x80 | codePoint & 0x3F);
      }
      else
      {
        bOut.write(0xE0 | ch >> '\f');
        bOut.write(0x80 | ch >> '\006' & 0x3F);
        bOut.write(0x80 | ch & 0x3F);
      }
      i++;
    }
    return bOut.toByteArray();
  }
  
  public static String toUpperCase(String string)
  {
    boolean changed = false;
    char[] chars = string.toCharArray();
    for (int i = 0; i != chars.length; i++)
    {
      char ch = chars[i];
      if (('a' <= ch) && ('z' >= ch))
      {
        changed = true;
        chars[i] = ((char)(ch - 'a' + 65));
      }
    }
    if (changed) {
      return new String(chars);
    }
    return string;
  }
  
  public static String toLowerCase(String string)
  {
    boolean changed = false;
    char[] chars = string.toCharArray();
    for (int i = 0; i != chars.length; i++)
    {
      char ch = chars[i];
      if (('A' <= ch) && ('Z' >= ch))
      {
        changed = true;
        chars[i] = ((char)(ch - 'A' + 97));
      }
    }
    if (changed) {
      return new String(chars);
    }
    return string;
  }
  
  public static byte[] toByteArray(String string)
  {
    byte[] bytes = new byte[string.length()];
    for (int i = 0; i != bytes.length; i++)
    {
      char ch = string.charAt(i);
      
      bytes[i] = ((byte)ch);
    }
    return bytes;
  }
  
  public static String[] split(String input, char delimiter)
  {
    Vector v = new Vector();
    boolean moreTokens = true;
    while (moreTokens)
    {
      int tokenLocation = input.indexOf(delimiter);
      if (tokenLocation > 0)
      {
        String subString = input.substring(0, tokenLocation);
        v.addElement(subString);
        input = input.substring(tokenLocation + 1);
      }
      else
      {
        moreTokens = false;
        v.addElement(input);
      }
    }
    String[] res = new String[v.size()];
    for (int i = 0; i != res.length; i++) {
      res[i] = ((String)v.elementAt(i));
    }
    return res;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.asn1.Strings
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.rmi;

import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Date;

public class DateRMI
  extends UnicastRemoteObject
  implements Remote, Serializable, RemoteDate
{
  private Date d;
  
  public DateRMI()
    throws RemoteException
  {
    d = new Date();
  }
  
  public Date getDate()
    throws RemoteException
  {
    return d;
  }
  
  public boolean equals(Object o)
  {
    RemoteDate rd = (RemoteDate)o;
    try
    {
      return d.equals(rd.getDate());
    }
    catch (RemoteException re) {}
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.rmi.DateRMI
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.rmi;

import java.io.IOException;
import java.io.ObjectOutput;
import java.rmi.MarshalException;
import java.rmi.Remote;
import java.rmi.UnmarshalException;
import java.rmi.server.Operation;
import java.rmi.server.RemoteCall;
import java.rmi.server.Skeleton;
import java.rmi.server.SkeletonMismatchException;
import java.util.Date;

public final class DateRMI_Skel
  implements Skeleton
{
  private static final Operation[] operations = { new Operation("java.util.Date getDate()") };
  private static final long interfaceHash = 501963159252253344L;
  
  public void dispatch(Remote paramRemote, RemoteCall paramRemoteCall, int paramInt, long paramLong)
    throws Exception
  {
    if (paramInt < 0)
    {
      if (paramLong == -1017285815713287420L) {
        paramInt = 0;
      } else {
        throw new UnmarshalException("invalid method hash");
      }
    }
    else if (paramLong != 501963159252253344L) {
      throw new SkeletonMismatchException("interface hash mismatch");
    }
    DateRMI localDateRMI = (DateRMI)paramRemote;
    switch (paramInt)
    {
    case 0: 
      paramRemoteCall.releaseInputStream();
      Date localDate = localDateRMI.getDate();
      try
      {
        ObjectOutput localObjectOutput = paramRemoteCall.getResultStream(true);
        localObjectOutput.writeObject(localDate);
      }
      catch (IOException localIOException)
      {
        throw new MarshalException("error marshalling return", localIOException);
      }
    default: 
      throw new UnmarshalException("invalid method number");
    }
  }
  
  public Operation[] getOperations()
  {
    return (Operation[])operations.clone();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.rmi.DateRMI_Skel
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.rmi;

import java.io.IOException;
import java.io.ObjectInput;
import java.lang.reflect.Method;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.UnexpectedException;
import java.rmi.UnmarshalException;
import java.rmi.server.Operation;
import java.rmi.server.RemoteCall;
import java.rmi.server.RemoteObject;
import java.rmi.server.RemoteRef;
import java.rmi.server.RemoteStub;
import java.util.Date;

public final class DateRMI_Stub
  extends RemoteStub
  implements Remote, RemoteDate
{
  private static final Operation[] operations = { new Operation("java.util.Date getDate()") };
  private static final long interfaceHash = 501963159252253344L;
  private static final long serialVersionUID = 2L;
  private static boolean useNewInvoke;
  private static Method $method_getDate_0;
  
  static
  {
    try
    {
      RemoteRef.class.getMethod("invoke", new Class[] { Remote.class, Method.class, new Object[0].getClass(), Long.TYPE });
      useNewInvoke = true;
      $method_getDate_0 = RemoteDate.class.getMethod("getDate", new Class[0]);
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      useNewInvoke = false;
    }
  }
  
  public DateRMI_Stub() {}
  
  public DateRMI_Stub(RemoteRef paramRemoteRef)
  {
    super(paramRemoteRef);
  }
  
  public Date getDate()
    throws RemoteException
  {
    try
    {
      if (useNewInvoke)
      {
        localObject1 = ref.invoke(this, $method_getDate_0, null, -1017285815713287420L);
        return (Date)localObject1;
      }
      Object localObject1 = ref.newCall(this, operations, 0, 501963159252253344L);
      ref.invoke((RemoteCall)localObject1);
      Date localDate;
      try
      {
        ObjectInput localObjectInput = ((RemoteCall)localObject1).getInputStream();
        localDate = (Date)localObjectInput.readObject();
      }
      catch (IOException localIOException)
      {
        throw new UnmarshalException("error unmarshalling return", localIOException);
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new UnmarshalException("error unmarshalling return", localClassNotFoundException);
      }
      finally
      {
        ref.done((RemoteCall)localObject1);
      }
      return localDate;
    }
    catch (RuntimeException localRuntimeException)
    {
      throw localRuntimeException;
    }
    catch (RemoteException localRemoteException)
    {
      throw localRemoteException;
    }
    catch (Exception localException)
    {
      throw new UnexpectedException("undeclared checked exception", localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.rmi.DateRMI_Stub
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.rmi;

import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class IntegerRMI
  extends UnicastRemoteObject
  implements Remote, Serializable, RemoteInteger
{
  private int i;
  
  public IntegerRMI()
    throws RemoteException
  {
    i = ((int)Math.round(Math.random() * 1000000.0D));
  }
  
  public int getInt()
    throws RemoteException
  {
    return i;
  }
  
  public boolean equals(Object o)
  {
    RemoteInteger ri = (RemoteInteger)o;
    try
    {
      return i == ri.getInt();
    }
    catch (RemoteException re) {}
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.ssl.rmi.IntegerRMI
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.ssl.rmi;

import java.io.DataOutput;
import java.io.IOException;
import java.io.ObjectOutput;
import java.rmi.MarshalException;
import java.rmi.Remote;
import java.rmi.UnmarshalException;
import java.rmi.server.Operation;
import java.rmi.server.RemoteCall;
import java.rmi.server.Skeleton;
import java.rmi.server.SkeletonMismatchException;

public final class IntegerRMI_Skel
  implements Skeleton
{
  private static final Operation[] operations = { new Operation("int getInt()") };
  private static final long interfaceHash = 6856628635405599356L;
  
  public void dispatch(Remote paramRemote, RemoteCall paramRemoteCall, int paramInt, long paramLong)
    throws Exception
  {
    if (paramInt < 0)
    {
      if (paramLong == 8565631889465877029L) {
        paramInt = 0;
      } else {
        throw new UnmarshalException("invalid method hash");
      }
    }
    else if (paramLong != 6856628635405599356L) {
      throw new SkeletonMismatchException("interface hash mismatch");
    }
    IntegerRMI localIntegerRMI
1 2 3 4 5 6 7 8 9 10 11 12 13

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd