Exemple #1
0
  static SignatureRequestDecoder test(String file, boolean outdata) throws Exception {

    byte[] data = ArrayUtil.readFile(file);

    XMLSchemaCache schema_cache = new XMLSchemaCache();
    schema_cache.addWrapper(SignatureRequestDecoder.class);
    schema_cache.addWrapper(XDSProfileRequestDecoder.class);

    SignatureRequestDecoder sreq = (SignatureRequestDecoder) schema_cache.parse(data);

    boolean signed = sreq.isSigned();

    KeyStoreVerifier verifier = new KeyStoreVerifier(DemoKeyStore.getCAKeyStore());
    verifier.setTrustedRequired(false);

    if (signed) {
      sreq.verifySignature(verifier);
    }

    StringBuffer s = new StringBuffer();

    for (SignatureProfileDecoder spd : sreq.getSignatureProfilesDecoders()) {
      s.append("\nSIGNATUREPROFILE:\n" + spd + "\nSIGNATUREPROFILE\n");
    }

    for (CertificateFilter cf : sreq.getCertificateFilters()) {
      printcf(cf, s);
    }

    print("MAIN_VIEW", sreq.getMainDocument(), s);

    print("DETAIL_VIEW", sreq.getDetailDocument(), s);

    print("PROCESSING_VIEW", sreq.getProcessingDocument(), s);

    for (SignatureRequestDecoder.BaseDocument d : sreq.getEmbeddedObjects()) {
      print("EMBEDDED", d, s);
    }

    for (SignatureRequestDecoder.BaseDocument d : sreq.getAttachments()) {
      print("ATTACHMENT", d, s);
    }

    s.append("\nID=" + sreq.getID() + "\n");

    if (sreq.getLanguages() != null)
      s.append("\nLanguages=" + StringUtil.tokenList(sreq.getLanguages()) + "\n");

    s.append("\nMESSAGEDIGEST:\n" + sreq.getDocumentSignatures(null, null) + "\nMESSAGEDIGEST\n");

    if (signed) {
      s.append("\nSIGNATURE\n" + verifier.getSignerCertificateInfo().toString() + "\nSIGNATURE");
    }

    if (outdata) {
      System.out.println(s.toString());
    }
    return sreq;
  }
 static {
   allowedChars = StringUtil.charSet(" '+,-./:=?()");
   for (char c = 'a'; c <= 'z'; c++) {
     allowedChars.set(c);
   }
   for (char c = 'A'; c <= 'Z'; c++) {
     allowedChars.set(c);
   }
   for (char c = '0'; c <= '9'; c++) {
     allowedChars.set(c);
   }
 }
 /**
  * Checks if a string contains only characters allowable in a PrintableString.
  *
  * <p>The folliwing characters are allowed (taken from section 3.3.3 of RFC1148)
  *
  * <pre>  printablestring  = *( ps-char )
  *   ps-restricted-char = 1DIGIT /  1ALPHA / " " / "'" / "+"
  *                    / "," / "-" / "." / "/" / ":" / "=" / "?"
  *   ps-delim         = "(" / ")"
  *   ps-char          = ps-delim / ps-restricted-char</pre>
  *
  * @return true iff <code><i>s</i></code> contains only characters allowable in a PrintableString.
  */
 public static boolean isPrintableString(String s) {
   return StringUtil.hasOnlyLegalChars(s, allowedChars);
 }
 public ASN1PrintableString(String value) {
   super(PRINTABLESTRING, value);
   StringUtil.checkAllowedChars(value, allowedChars);
 }
 /*
  * TODO: To be documented.
  */
 public String[] getListConditional(String name) throws NoSuchElementException {
   String s = getStringConditional(name);
   return s != null ? StringUtil.tokenVector(s) : null;
 }
 /*
  * TODO: To be documented.
  */
 public String[] getList(String name) throws NoSuchElementException {
   return StringUtil.tokenVector(getString(name));
 }