Пример #1
0
        public override String ToString()
        {
            String s = "Certificate name:\n";

            s += "  " + getName().toUri() + "\n";
            s += "Validity:\n";

            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss");

            dateFormat.setTimeZone(System.Collections.TimeZone.getTimeZone("UTC"));
            String notBeforeStr = dateFormat
                                  .format(net.named_data.jndn.util.Common.millisecondsSince1970ToDate((long)Math.Round(getNotBefore(), MidpointRounding.AwayFromZero)));
            String notAfterStr = dateFormat.format(net.named_data.jndn.util.Common
                                                   .millisecondsSince1970ToDate((long)Math.Round(getNotAfter(), MidpointRounding.AwayFromZero)));

            s += "  NotBefore: " + notBeforeStr + "\n";
            s += "  NotAfter: " + notAfterStr + "\n";
            for (int i = 0; i < subjectDescriptionList_.Count; ++i)
            {
                CertificateSubjectDescription sd = (CertificateSubjectDescription)subjectDescriptionList_[i];
                s += "Subject Description:\n";
                s += "  " + sd.getOidString() + ": " + sd.getValue() + "\n";
            }

            s += "Public key bits:\n";
            Blob   keyDer     = getPublicKeyDer();
            String encodedKey = net.named_data.jndn.util.Common.base64Encode(keyDer.getImmutableArray());

            for (int i_0 = 0; i_0 < encodedKey.Length; i_0 += 64)
            {
                s += encodedKey.Substring(i_0, (Math.Min(i_0 + 64, encodedKey.Length)) - (i_0))
                     + "\n";
            }

            if (extensionList_.Count > 0)
            {
                s += "Extensions:\n";
                for (int i_1 = 0; i_1 < extensionList_.Count; ++i_1)
                {
                    CertificateExtension ext = (CertificateExtension)extensionList_[i_1];
                    s += "  OID: " + ext.getOid() + "\n";
                    s += "  Is critical: " + ((ext.getIsCritical()) ? 'Y' : 'N')
                         + "\n";

                    s += "  Value: " + ext.getValue().toHex() + "\n";
                }
            }

            return(s);
        }