Java Code Examples for sun.security.timestamp.Timestamper

Following code examples demonstrate how to use sun.security.timestamp.Timestamperfrom java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use sun.security.timestamp.Timestamperand various code implementation of this class.

    
    protected Timestamper getTimestamper()
    {
        return new HttpTimestamper(getTSAUrl());
    } 


    public static String getTimestampingUrl(X509Certificate tsaCertificate) {
        if (tsaCertificate == null) {
            return null;
        }
        try {
            byte[] extensionValue = tsaCertificate.getExtensionValue(SUBJECT_INFO_ACCESS_OID);
            if (extensionValue == null) {
                return null;
            }
            DerInputStream der = new DerInputStream(extensionValue);
            der = new DerInputStream(der.getOctetString());
            DerValue[] derValue = der.getSequence(5);
            AccessDescription description;
            GeneralName location;
            URIName uri;
            for (int i = 0; i < derValue.length; i++) {
                description = new AccessDescription(derValue[i]);
                if (description.getAccessMethod().equals(AD_TIMESTAMPING_Id)) {
                    location = description.getAccessLocation();
                    if (location.getType() == GeneralNameInterface.NAME_URI) {
                        uri = (URIName) location.getName();
                        if (uri.getScheme().equalsIgnoreCase("http")) {
                            return uri.getName();
                        }
                    }
                }
            }
        } catch (IOException ioe) {
        }
        return null;
    } 

    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException1)
    {
      throw new IllegalArgumentException(localNoSuchAlgorithmException1);
    } 

Advertisement
Javadoc
A timestamping service which conforms to the Time-Stamp Protocol (TSP) defined in: RFC 3161. Individ

ual timestampers may communicate with a Timestamping Authority (TSA) over different transport machanisms. TSP permits at least the following transports: HTTP, Internet mail, file-based and socket-based. @author Vincent Ryan @see HttpTimestamper

Read More
Advertisement