001 /* 002 * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.11/src/java/org/apache/commons/ssl/ASN1Structure.java $ 003 * $Revision: 121 $ 004 * $Date: 2007-11-13 21:26:57 -0800 (Tue, 13 Nov 2007) $ 005 * 006 * ==================================================================== 007 * Licensed to the Apache Software Foundation (ASF) under one 008 * or more contributor license agreements. See the NOTICE file 009 * distributed with this work for additional information 010 * regarding copyright ownership. The ASF licenses this file 011 * to you under the Apache License, Version 2.0 (the 012 * "License"); you may not use this file except in compliance 013 * with the License. You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, 018 * software distributed under the License is distributed on an 019 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 020 * KIND, either express or implied. See the License for the 021 * specific language governing permissions and limitations 022 * under the License. 023 * ==================================================================== 024 * 025 * This software consists of voluntary contributions made by many 026 * individuals on behalf of the Apache Software Foundation. For more 027 * information on the Apache Software Foundation, please see 028 * <http://www.apache.org/>. 029 * 030 */ 031 032 package org.apache.commons.ssl; 033 034 import org.apache.commons.ssl.util.Hex; 035 036 import java.util.Iterator; 037 import java.util.LinkedList; 038 import java.util.List; 039 import java.util.Set; 040 import java.util.TreeSet; 041 042 /** 043 * @author Credit Union Central of British Columbia 044 * @author <a href="http://www.cucbc.com/">www.cucbc.com</a> 045 * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@cucbc.com</a> 046 * @since 16-Nov-2005 047 */ 048 class ASN1Structure { 049 List derIntegers = new LinkedList(); 050 Set oids = new TreeSet(); 051 String oid1; 052 String oid2; 053 String oid3; 054 byte[] salt; 055 byte[] iv; 056 int iterationCount; 057 int keySize; 058 byte[] bigPayload; 059 byte[] smallPayload; 060 061 public String toString() { 062 StringBuffer buf = new StringBuffer(256); 063 buf.append("------ ASN.1 PKCS Structure ------"); 064 buf.append("\noid1: "); 065 buf.append(oid1); 066 if (oid2 != null) { 067 buf.append("\noid2: "); 068 buf.append(oid2); 069 } 070 buf.append("\nsalt: "); 071 if (salt != null) { 072 buf.append(Hex.encode(salt)); 073 } else { 074 buf.append("[null]"); 075 } 076 buf.append("\nic: "); 077 buf.append(Integer.toString(iterationCount)); 078 if (keySize != 0) { 079 buf.append("\nkeySize: "); 080 buf.append(Integer.toString(keySize * 8)); 081 } 082 if (oid2 != null) { 083 buf.append("\noid3: "); 084 buf.append(oid3); 085 } 086 if (oid2 != null) { 087 buf.append("\niv: "); 088 if (iv != null) { 089 buf.append(Hex.encode(iv)); 090 } else { 091 buf.append("[null]"); 092 } 093 } 094 if (bigPayload != null) { 095 buf.append("\nbigPayload-length: "); 096 buf.append(bigPayload.length); 097 } 098 if (smallPayload != null) { 099 buf.append("\nsmallPayload-length: "); 100 buf.append(smallPayload.length); 101 } 102 if (!oids.isEmpty()) { 103 Iterator it = oids.iterator(); 104 buf.append("\nAll oids:"); 105 while (it.hasNext()) { 106 buf.append("\n"); 107 buf.append((String) it.next()); 108 } 109 } 110 return buf.toString(); 111 } 112 }