You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SignatureService.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. /*
  16. * Based on the eID Applet Project code.
  17. * Original Copyright (C) 2008-2009 FedICT.
  18. */
  19. package org.apache.poi.ooxml.signature.service.spi;
  20. import java.security.NoSuchAlgorithmException;
  21. import java.security.cert.X509Certificate;
  22. import java.util.List;
  23. /**
  24. * Interface for signature service component.
  25. */
  26. public interface SignatureService {
  27. /**
  28. * Gives back the digest algorithm to be used for construction of the digest
  29. * infos of the preSign method. Return a digest algorithm here if you want
  30. * to let the client sign some locally stored files. Return
  31. * <code>null</code> if no pre-sign digest infos are required.
  32. *
  33. * @return
  34. * @see #preSign(List, List)
  35. */
  36. String getFilesDigestAlgorithm();
  37. /**
  38. * Pre-sign callback method. Depending on the configuration some parameters
  39. * are passed. The returned value will be signed by the eID Applet.
  40. *
  41. * <p>
  42. * TODO: service must be able to throw some exception on failure.
  43. * </p>
  44. *
  45. * @param digestInfos
  46. * the optional list of digest infos.
  47. * @param signingCertificateChain
  48. * the optional list of certificates.
  49. * @return the digest to be signed.
  50. * @throws NoSuchAlgorithmException
  51. */
  52. DigestInfo preSign(List<DigestInfo> digestInfos, List<X509Certificate> signingCertificateChain) throws NoSuchAlgorithmException;
  53. /**
  54. * Post-sign callback method. Received the signature value. Depending on the
  55. * configuration the signing certificate chain is also obtained.
  56. *
  57. * <p>
  58. * TODO: service must be able to throw some exception on failure.
  59. * </p>
  60. *
  61. * @param signatureValue
  62. * @param signingCertificateChain
  63. * the optional chain of signing certificates.
  64. */
  65. void postSign(byte[] signatureValue, List<X509Certificate> signingCertificateChain);
  66. }