1 3 package org.faceless.pdf; 4 5 import java.io.*; 6 import java.util.*; 7 import java.security.*; 8 import java.security.cert.*; 9 import java.security.spec.*; 10 11 232 public final class FormSignature extends FormElement 233 { 234 FormSignature(org.faceless.pdf2.FormSignature b) 235 { 236 super(b); 237 } 238 239 256 public static final int HANDLER_SELFSIGN = 0; 257 258 277 public static final int HANDLER_VERISIGN = 1; 278 279 287 public static final int STATE_SIGNED = 0; 288 289 297 public static final int STATE_PENDING = 1; 298 299 private org.faceless.pdf2.FormSignature sig; 300 301 318 public FormSignature(KeyStore keystore, String alias, char[] password, int handler) 319 throws GeneralSecurityException, IllegalArgumentException 320 { 321 super(new org.faceless.pdf2.FormSignature(keystore, alias, password, handler==HANDLER_VERISIGN ? org.faceless.pdf2.FormSignature.HANDLER_VERISIGN : org.faceless.pdf2.FormSignature.HANDLER_SELFSIGN)); 322 } 323 324 329 public int getState() 330 { 331 int state = ((org.faceless.pdf2.FormSignature)element).getState(); 332 if (state==org.faceless.pdf2.FormSignature.STATE_SIGNED) { 333 return STATE_SIGNED; 334 } else { 335 return STATE_PENDING; 336 } 337 } 338 339 347 public void setName(String name) 348 { 349 ((org.faceless.pdf2.FormSignature)element).setName(name); 350 } 351 352 356 public String getName() 357 { 358 return ((org.faceless.pdf2.FormSignature)element).getName(); 359 } 360 361 367 public void setReason(String reason) 368 { 369 ((org.faceless.pdf2.FormSignature)element).setReason(reason); 370 } 371 372 376 public String getReason() 377 { 378 return ((org.faceless.pdf2.FormSignature)element).getReason(); 379 } 380 381 387 public void setLocation(String location) 388 { 389 ((org.faceless.pdf2.FormSignature)element).setReason(location); 390 } 391 392 396 public String getLocation() 397 { 398 return ((org.faceless.pdf2.FormSignature)element).getLocation(); 399 } 400 401 405 public Calendar getSignDate() 406 { 407 return ((org.faceless.pdf2.FormSignature)element).getSignDate(); 408 } 409 410 420 public String getType() 421 { 422 return ((org.faceless.pdf2.FormSignature)element).getFilter(); 423 } 424 425 434 public X509Certificate[] getCertificates() 435 throws CertificateException 436 { 437 org.faceless.pdf2.PKCS7SignatureHandler handler; 438 handler = (org.faceless.pdf2.PKCS7SignatureHandler)((org.faceless.pdf2.FormSignature)element).getSignatureHandler(); 439 return handler.getCertificates(); 440 } 441 442 443 463 public boolean verify() 464 throws GeneralSecurityException 465 { 466 return ((org.faceless.pdf2.FormSignature)element).verify(); 467 } 468 469 470 483 public int getNumberOfRevisionsCovered() 484 { 485 return ((org.faceless.pdf2.FormSignature)element).getNumberOfRevisionsCovered(); 486 } 487 488 533 public X509Certificate verifyCertificates(KeyStore keystore, CRL crl) 534 throws GeneralSecurityException 535 { 536 org.faceless.pdf2.PKCS7SignatureHandler handler; 537 handler = (org.faceless.pdf2.PKCS7SignatureHandler)((org.faceless.pdf2.FormSignature)element).getSignatureHandler(); 538 X509Certificate[] certs = handler.getCertificates(); 539 Calendar signdate = getSignDate(); 540 return org.faceless.pdf2.FormSignature.verifyCertificates(certs, keystore, crl, signdate); 541 } 542 543 545 546 554 public static boolean isValidCertificate(X509Certificate cert, CRL crl, Date signdate) 555 { 556 return org.faceless.pdf2.FormSignature.isValidCertificate(cert, crl, signdate); 557 } 558 559 566 public static KeyStore loadDefaultKeyStore() 567 throws GeneralSecurityException 568 { 569 return org.faceless.pdf2.FormSignature.loadDefaultKeyStore(); 570 } 571 572 593 public static KeyStore loadAKFKeyStore(InputStream in) 594 throws IOException, GeneralSecurityException 595 { 596 return org.faceless.pdf2.FormSignature.loadAKFKeyStore(in); 597 } 598 599 622 public static KeyStore loadFDFKeyStore(InputStream in) 623 throws IOException, GeneralSecurityException 624 { 625 return org.faceless.pdf2.FormSignature.loadFDFKeyStore(in); 626 } 627 628 644 public static KeyStore loadPKCS7KeyStore(InputStream in) 645 throws IOException, GeneralSecurityException 646 { 647 return org.faceless.pdf2.FormSignature.loadPKCS7KeyStore(in); 648 } 649 650 672 public static String getIssuerField(X509Certificate cert, String field) 673 throws CertificateException 674 { 675 return org.faceless.pdf2.FormSignature.getIssuerField(cert, field); 676 } 677 678 691 public static String getSubjectField(X509Certificate cert, String field) 692 throws CertificateException 693 { 694 return org.faceless.pdf2.FormSignature.getSubjectField(cert, field); 695 } 696 } 697 | Popular Tags |