|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectat.knowcenter.wag.egov.egiz.pdf.BinarySignature
Contains various extension functions to digitally sign documents.
These functions are used to replace parts of the original Egiz plain text signature mechanism.
| Field Summary | |
static byte[] |
BREV_ALG
The SIG_ALG brev. |
static byte[] |
BREV_DAT
The date brev. |
static byte[] |
BREV_ISS
The issure brev. |
static byte[] |
BREV_NIL
The nil brev used to define an unrecognized value. |
static byte[] |
BREV_SID
The SIG_ID brev. |
static byte[] |
BREV_SNR
The serial number brev. |
static byte[] |
BREV_VAL
The value brev. |
static int |
CERTIFICATE_PLACEHOLDER_LENGTH
The number of bytes left out for the certificate placeholder. |
static com.lowagie.text.pdf.PdfName |
EGIZ_BYTERANGES_NAME
The PDFName of the byte ranges array. |
static com.lowagie.text.pdf.PdfName |
EGIZ_CERTIFICATE_NAME
The PdfName of the certificate array. |
static com.lowagie.text.pdf.PdfName |
EGIZ_DATA_NAME
The PdfName of the data array that contains various egiz-dict data. |
static com.lowagie.text.pdf.PdfName |
EGIZ_DICT_NAME
The PDFName of the Egiz Dictionary. |
static com.lowagie.text.pdf.PdfName |
EGIZ_ENCODINGS_NAME
The PDFName of the /encodings field in an Egiz Dictionary. |
static com.lowagie.text.pdf.PdfName |
EGIZ_KZ_NAME
The PDFName of the Kennzeichnung attribute. |
static com.lowagie.text.pdf.PdfName |
EGIZ_ODS_NAME
The PDFName of the Original Document Size (ODS) field in an Egiz Dictionary. |
static com.lowagie.text.pdf.PdfName |
EGIZ_REPLACES_NAME
The PDFName of the /replaces field in an Egiz Dictionary. |
static com.lowagie.text.pdf.PdfName |
EGIZ_TIMESTAMP_NAME
The PdfName of the Timestamp |
static com.lowagie.text.pdf.PdfName |
EGIZ_XOBJ_NAME
The PDFName of the Signature XObject field in an Egiz Dictionary. |
static byte[] |
ENCODING_NIL
No explicit encoding. |
static byte[] |
ENCODING_URL
URL encoding. |
static byte[] |
ENCODING_WIN
PDF WinAnsiEncoding. |
static byte |
LAYOUT_PLACEHOLDER
The placeholder character used to fill out Strings in the layout process. |
static int |
LINE_BREAK_TOLERANCE
The tolerance area of the line break algorithm. |
protected static org.apache.commons.logging.Log |
logger
|
protected static com.lowagie.text.pdf.PdfNumber |
NUMBER_PLACEHOLDER
The number placeholder that is used to give numbers a fixed length. |
static byte |
SIGN_PLACEHOLDER
This placeholder is used to fill out holes between the byte ranges before the document is signed. |
static int |
TIMESTAMP_PLACEHOLDER_LENGTH
The number of bytes left out for the timestamp placeholder. |
| Constructor Summary | |
BinarySignature()
|
|
| Method Summary | |
static byte[] |
buildDigest(byte[] data,
int length)
Builds a digest of the given data. |
protected static int |
calcNumReps(List replaces)
Calculates the number of actual String replaces from a given ReplaceInfo list. |
protected static void |
createEgizDict(com.lowagie.text.pdf.PdfStamper stamper,
com.lowagie.text.pdf.PdfTemplate table_template,
IncrementalUpdateInformation iui,
List variable_field_definitions,
List all_field_definitions,
List invisible_field_definitions,
String invisibleKZString)
Creates the EGIZ Dictionary and adds it to the document. |
protected static List |
determineKZ(byte[] pdf,
int begin,
int end,
List field_definitions)
Determines the Kennzeichnug in the content stream. |
protected static List |
determineReplacesInContentStream(byte[] pdf,
int begin,
int end,
List field_definitions)
Determines the List of ReplaceInfo objects of replaces in the content stream regarding the given field definitions. |
static String |
extractSignatureTextOnly(com.lowagie.text.pdf.PdfDictionary egiz_dict)
Extracts the signature text only. |
protected static int |
findFirstNotPlaceholder(List strings,
int start)
Finds the first string after and at the given index not being a placeholder string. |
protected static int |
findIndex(List strings,
byte[] caption)
Finds the index of the StringInfo within the StringInfo list that has the given content (caption). |
protected static int |
getCertificatePlaceholderLength(IncrementalUpdateInformation iui)
|
static List |
getEgizDictChainFromReader(com.lowagie.text.pdf.PdfReader reader)
Retrieves the chain of Egiz Dictionaries from the reader. |
static com.lowagie.text.pdf.PdfDictionary |
getEgizDictFromReader(com.lowagie.text.pdf.PdfReader reader)
Retrieves the Egiz Dictionary from the document if present. |
static com.lowagie.text.pdf.PdfIndirectReference |
getEgizDictIndRefFromReader(com.lowagie.text.pdf.PdfReader reader)
Retrieves the Egiz Dictionary's indirect reference from the reader. |
protected static int |
getLineBreakTolerance(IncrementalUpdateInformation iui)
|
static int |
getOriginalDocumentSizeFromEgizDict(com.lowagie.text.pdf.PdfDictionary egiz_dict)
Retrieves the size of the original document from the Egiz Dictionary. |
static com.lowagie.text.pdf.PdfDictionary |
getPreviousFromEgizDict(com.lowagie.text.pdf.PdfDictionary egiz_dict)
Retrieves the previous Egiz dictionary from the given one, if a previous dictionary exists. |
protected static int |
getTimestampPlaceholderLength(IncrementalUpdateInformation iui)
|
protected static boolean |
isCaption(List strings,
int index,
byte[] caption)
|
protected static boolean |
isPlaceholder(StringInfo si,
byte placeholder)
Tells, if the given StringInfo contains only placeholder characters. |
static void |
markByteRanges(IncrementalUpdateInformation iui)
Updates the information in the egiz dictionary to reflect the real offsets of the byte ranges. |
static byte[] |
prepareDataToSign(byte[] data,
List byte_ranges)
Fills the holes in the byte ranges with the SIGN_PLACEHOLDER. |
static int |
readNumber(byte[] pdf,
int start_index,
int num_digits)
Reads an unsigned integer number. |
static List |
reconstructReplaces(byte[] pdf,
byte[][] brevs,
StringInfo[] sis,
byte[][] encodings)
Reconstructs the replaces from the PDF and forms suitable value strings. |
static void |
replaceCertificate(IncrementalUpdateInformation iui)
Replaces the certificate placeholder with the certificate from the signed Signature Object. |
static void |
replaceNumber(byte[] pdf,
int start_index,
int number,
int num_digits)
Replaces a number by the new value. |
static void |
replacePlaceholders(IncrementalUpdateInformation iui)
Replaces the placeholders with values from the signed SignatureObject. |
static void |
replaceTimestamp(IncrementalUpdateInformation iui)
Replaces the timestam placeholder with the timestamp from the signed Signature Object. |
static void |
restorePlaceholder(byte[] pdf,
StringInfo si,
byte placeholder)
Restores the given String to its placeholder. |
static String |
retrieveSignableTextFromData(byte[] data,
int ods)
Retrieves the signable text from the given document. |
protected static int |
skipStrings(List strings,
int index,
byte[] caption)
|
protected static boolean |
startsWithCaption(StringInfo si,
List field_definitions)
|
protected static byte[] |
typeToBrev(String type)
Converts a field name (type) to the corresponding BREV. |
static IncrementalUpdateInformation |
writeIncrementalUpdate(PdfDataSource original_document,
DataSink written_pdf,
com.lowagie.text.pdf.PdfPTable pdf_table,
String profile,
PositioningInstruction pi,
List variable_field_definitions,
List all_field_definitions,
List invisible_field_definitions,
String invisibleKZString,
TimeStamper timeStamper,
SignatorInformation si,
SignatureObject so)
Signs a document with the given signature table using the Incremental Update method. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static org.apache.commons.logging.Log logger
public static final int LINE_BREAK_TOLERANCE
Placeholder.replacePlaceholderWithTolerance(byte[], List, byte[], int),
Constant Field Valuespublic static final int CERTIFICATE_PLACEHOLDER_LENGTH
public static final int TIMESTAMP_PLACEHOLDER_LENGTH
public static final byte LAYOUT_PLACEHOLDER
public static final byte SIGN_PLACEHOLDER
public static final byte[] BREV_NIL
public static final byte[] BREV_DAT
public static final byte[] BREV_ISS
public static final byte[] BREV_SNR
public static final byte[] BREV_VAL
public static final byte[] BREV_SID
public static final byte[] BREV_ALG
public static final byte[] ENCODING_NIL
public static final byte[] ENCODING_WIN
public static final byte[] ENCODING_URL
public static final com.lowagie.text.pdf.PdfName EGIZ_DICT_NAME
Used to locate and identify the Egiz Dictionary in the document.
public static final com.lowagie.text.pdf.PdfName EGIZ_ODS_NAME
The ODS must be a positive integral number.
public static final com.lowagie.text.pdf.PdfName EGIZ_KZ_NAME
public static final com.lowagie.text.pdf.PdfName EGIZ_REPLACES_NAME
public static final com.lowagie.text.pdf.PdfName EGIZ_ENCODINGS_NAME
public static final com.lowagie.text.pdf.PdfName EGIZ_BYTERANGES_NAME
public static final com.lowagie.text.pdf.PdfName EGIZ_CERTIFICATE_NAME
public static final com.lowagie.text.pdf.PdfName EGIZ_TIMESTAMP_NAME
public static final com.lowagie.text.pdf.PdfName EGIZ_DATA_NAME
public static final com.lowagie.text.pdf.PdfName EGIZ_XOBJ_NAME
This must be an indirect reference to the XObject containing the Signature table.
protected static final com.lowagie.text.pdf.PdfNumber NUMBER_PLACEHOLDER
| Constructor Detail |
public BinarySignature()
| Method Detail |
public static String extractSignatureTextOnly(com.lowagie.text.pdf.PdfDictionary egiz_dict)
throws IOException
The signature text is the text of the Signature XObject.
egiz_dict - The Egiz Dictionary.
IOExceptionpublic static int getOriginalDocumentSizeFromEgizDict(com.lowagie.text.pdf.PdfDictionary egiz_dict)
egiz_dict - The Egiz Dictionary.
public static com.lowagie.text.pdf.PdfDictionary getPreviousFromEgizDict(com.lowagie.text.pdf.PdfDictionary egiz_dict)
egiz_dict - The Egiz Dictionary.
public static com.lowagie.text.pdf.PdfDictionary getEgizDictFromReader(com.lowagie.text.pdf.PdfReader reader)
reader - The reader to retrieve the dictionary from.
public static com.lowagie.text.pdf.PdfIndirectReference getEgizDictIndRefFromReader(com.lowagie.text.pdf.PdfReader reader)
reader - The reader.
public static List getEgizDictChainFromReader(com.lowagie.text.pdf.PdfReader reader)
The first element in the List will be the top most (oldest) Egiz Dictionary. The last element in the List will be the bottom most (latest) Egiz Dictionary. If the list is empty, no dictionary could be found at all, which means that the document is not digitally signed.
reader - The reader.
public static byte[] buildDigest(byte[] data,
int length)
throws PDFDocumentException
data - The data to be digested.length - The length of the data portion that should be used for digesting.
This allows to build the digest only over parts of the data.
PDFDocumentException - Forwarded exception.
public static String retrieveSignableTextFromData(byte[] data,
int ods)
data - The data.ods - The original document size.
public static byte[] prepareDataToSign(byte[] data,
List byte_ranges)
data - The given byte ranged data.byte_ranges - The byte ranges.
protected static int getLineBreakTolerance(IncrementalUpdateInformation iui)
throws PDFDocumentException
PDFDocumentException
protected static int getCertificatePlaceholderLength(IncrementalUpdateInformation iui)
throws SettingNotFoundException
SettingNotFoundException
protected static int getTimestampPlaceholderLength(IncrementalUpdateInformation iui)
throws SettingNotFoundException
SettingNotFoundException
public static IncrementalUpdateInformation writeIncrementalUpdate(PdfDataSource original_document,
DataSink written_pdf,
com.lowagie.text.pdf.PdfPTable pdf_table,
String profile,
PositioningInstruction pi,
List variable_field_definitions,
List all_field_definitions,
List invisible_field_definitions,
String invisibleKZString,
TimeStamper timeStamper,
SignatorInformation si,
SignatureObject so)
throws PresentableException
The table containing the signature text will be appended. As specified by the parameters, the signature will be appended to the last page, or a plain new page will be created for the signature to hold.
The table will be completely wrapped by an XObject, which will also be indirectly referenced by the Egiz Dictionary. This will ease the verification process.
An Egiz Dictionary will be added to the new document that contains information about the signature. Basically the size of the original document and the reference of the signature table.
original_document - The original document.pdf_table - The PdfPTable that contains the signature block.pi - The PositioningInstruction telling the algorithm where to place
the signature block.invisible_field_definitions - List of invisible field definitions to be added to the egiz dict.
May be null or empty, if there are no invisible fields.invisibleKZString - If not null, thins String is the KZ String to be written into the
/Data array.
PresentableException - Forwarded exception.
protected static void createEgizDict(com.lowagie.text.pdf.PdfStamper stamper,
com.lowagie.text.pdf.PdfTemplate table_template,
IncrementalUpdateInformation iui,
List variable_field_definitions,
List all_field_definitions,
List invisible_field_definitions,
String invisibleKZString)
throws IOException,
SettingNotFoundException,
CaptionNotFoundException
stamper - The PdfStamper.table_template - The Template of the Signature block.iui - The IncrementalUpdateInformation.variable_field_definitions - The field definitions.
IOException
SettingNotFoundException
CaptionNotFoundExceptionprotected static byte[] typeToBrev(String type)
type - The field name (type).
public static void markByteRanges(IncrementalUpdateInformation iui)
throws PDFDocumentException
This replaces the "dummy numbers" in the egiz dictionary with the correct values.
iui - The IncrementalUpdateInformation.
PDFDocumentException
public static void replaceCertificate(IncrementalUpdateInformation iui)
throws PDFDocumentException
iui - The IncrementalUpdateInformation.
PDFDocumentException
public static void replaceTimestamp(IncrementalUpdateInformation iui)
throws PDFDocumentException
iui - The IncrementalUpdateInformation.
PDFDocumentException
public static void replacePlaceholders(IncrementalUpdateInformation iui)
throws PDFDocumentException
iui - The IncrementalUpdateInformation.
PDFDocumentExceptionprotected static int calcNumReps(List replaces)
This is used to determine the number of actual replaces that has to be carried out. Accordingly to this number, entries in the dictionary are created.
replaces - The ReplaceInfo list.
protected static List determineReplacesInContentStream(byte[] pdf,
int begin,
int end,
List field_definitions)
throws CaptionNotFoundException
This method collects all variable String fields in a content stream and orders them according to their start offset.
pdf - The PDF.begin - The start of the content stream.end - The end of the content stream.field_definitions - The field definitions that are counceled to find out which and
where varaible strings are.
CaptionNotFoundException
protected static List determineKZ(byte[] pdf,
int begin,
int end,
List field_definitions)
throws SettingNotFoundException
pdf - The PDF.begin - The start of the content stream.end - The end of the content stream.field_definitions - The field definitions.
SettingNotFoundException - F.e.
protected static int findIndex(List strings,
byte[] caption)
strings - The list of StringInfos.caption - The text to be matched to the strings.
protected static boolean isCaption(List strings,
int index,
byte[] caption)
protected static int skipStrings(List strings,
int index,
byte[] caption)
protected static boolean isPlaceholder(StringInfo si,
byte placeholder)
si - The StringInfo.placeholder - The placeholder character.
protected static boolean startsWithCaption(StringInfo si,
List field_definitions)
protected static int findFirstNotPlaceholder(List strings,
int start)
strings - The list of StringInfos.start - The index where to start the search.
public static void restorePlaceholder(byte[] pdf,
StringInfo si,
byte placeholder)
pdf - The PDF.si - The string.placeholder - The placeholder the string should be filled with.
public static List reconstructReplaces(byte[] pdf,
byte[][] brevs,
StringInfo[] sis,
byte[][] encodings)
throws PDFDocumentException
pdf - The PDF.brevs - The brevs.sis - The StringInfo objects of the strings.
PDFDocumentException
public static int readNumber(byte[] pdf,
int start_index,
int num_digits)
pdf - The PDF.start_index - The start index of the number.num_digits - The number of digits.
public static void replaceNumber(byte[] pdf,
int start_index,
int number,
int num_digits)
pdf - The PDF.start_index - The start index of the number.number - The new number.num_digits - The number of digits.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||