바운시캐슬 java 라이브러리로 만든 TimeStamp(RFC3161,ISO18014-3) 규격 구현 자작 소스 입니다.

참고하시길...
AND

SHA1 해쉬 구하는 클래스

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHA1Utils {
    
    private static final String ALGORITHM = "SHA1";

	

    public static byte[] getHash(byte[] input) {
        try {
			MessageDigest md = MessageDigest.getInstance(ALGORITHM);
			return md.digest(input);
		} catch (NoSuchAlgorithmException e) {
			
			e.printStackTrace();
			return null;
		}
    }
    
 
    public static byte[] getHash(InputStream input) throws IOException {
        try {
			MessageDigest md = MessageDigest.getInstance(ALGORITHM);
			int read = -1;
			byte[] buffer = new byte[1024];
			while ((read = input.read(buffer)) != -1) {
				md.update(buffer, 0, read);
			}
			return md.digest();
		} catch (NoSuchAlgorithmException e) {
		
			e.printStackTrace();
			return null;
		}
    }
    
 
    public static byte[] getHash(File file) throws IOException {
		byte[] hash = null;
    	BufferedInputStream bis = null;
		try {
			bis = new BufferedInputStream(new FileInputStream(file));
			hash = getHash(bis);
		} finally {
			if (bis != null) try { bis.close(); } catch(IOException ie) {}
		}
		return hash;
    }


    public static String getHashHexString(byte[] input) {
		byte[] hash = getHash(input);
		StringBuffer sb = new StringBuffer(); 
		for (int i = 0; i < hash.length; i++) { 
			 sb.append(Integer.toString((hash[i] & 0xf0) >> 4, 16)); 
			 sb.append(Integer.toString(hash[i] & 0x0f, 16));
		} 
		return sb.toString();
    }
    
 
    public static String getHashHexString(String input) {
		return getHashHexString(input.getBytes());
    }
    
 
    public static String getHashHexString(String input, String charsetName) throws UnsupportedEncodingException {
		return getHashHexString(input.getBytes(charsetName));
    }
    
 
    public static String getHashHexString(InputStream input) throws IOException {
        byte[] hash = getHash(input);
        StringBuffer sb = new StringBuffer(hash.length * 2); 
        for (int i = 0; i < hash.length; i++) { 
			 sb.append(Integer.toString((hash[i] & 0xf0) >> 4, 16)); 
			 sb.append(Integer.toString(hash[i] & 0x0f, 16));
		} 
    	return sb.toString();
    }
    
    
 
    public static String getHashHexString(File file) throws IOException {
		byte[] hash = getHash(file);
		StringBuffer sb = new StringBuffer(hash.length * 2);
		for (int i = 0; i < hash.length; i++) { 
			 sb.append(Integer.toString((hash[i] & 0xf0) >> 4, 16)); 
			 sb.append(Integer.toString(hash[i] & 0x0f, 16));
		}
    	return sb.toString();
    }

}
AND


((Boolean) yourObject).booleanValue();

이렇게 하면 변환됨
AND


SimpleDateFormat dateF = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
String strdt=dateF.format(cert.getNotBefore());
System.out.println(strdt);

 2010-09-10 14:00:00  으로 출력


Letter Date or Time Component Presentation Examples
G Era designator Text AD
y Year Year 1996; 96
M Month in year Month July; Jul; 07
w Week in year Number 27
W Week in month Number 2
D Day in year Number 189
d Day in month Number 10
F Day of week in month Number 2
E Day in week Text Tuesday; Tue
a Am/pm marker Text PM
H Hour in day (0-23) Number 0
k Hour in day (1-24) Number 24
K Hour in am/pm (0-11) Number 0
h Hour in am/pm (1-12) Number 12
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978
z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
Z Time zone RFC 822 time zone -0800
AND


 ASN1EncodableVector whole = new ASN1EncodableVector();
 whole.add(new DERObjectIdentifier("1.3.6.1.5.5.7.19.2"));
 whole.add(seq_8);
 DERSet set = new DERSet(whole); 
        
 DERTaggedObject tagObj_16=new DERTaggedObject(false, 0, set);

이렇게 DERTaggedObject 생성자에 false를 주면 TaggedObject에 여러가지 object를
add 할 수 있다
AND