ESYAE-imza Kütüphaneleri

User Tools

Site Tools


en:esya:cades:imza-ozellikleri

Optional Attributes

You can add optional information such as signing time, adress as attributes into the signature. The list of attributes deifned in the API is as follows;

SigningTimeAttr Contains stated signing time. It does not guarantee the exact signing time and is only used for informational purposes.
SignerLocationAttr Includes information about signer's address. Country, city and postal code might be included. Since it is only for informational purposes, some of its fields can be null.
CommitmentTypeIndicationAttr Specifies the intention of the signature. You can indicate that the signed document is created by yourself, or that you just confirm the content of the document etc. CommitmentType values are defined as follows:
RECEIPT Indicates that the signature owner has received the signed document.
SENDER Indicates that the sender of the signed document is the signer of the original document. That does not mean any confirmation of the content of the document by the sender. Sender only confirms that the document is sent by himself.
APPROVAL Indicates that the signer confirms the content of the document.
APPROVAL, DELIVERY Indicates that a message is transferred successfully to the receiver. This type of messages are generally used by Trusted Service Providers (TSPs).
CREATION Indicates the signer confirms that the signed document is created by himself. It does not include content confirmation.
ORIGIN Indicates that the signer has created the document, confirmed its content and sent himself.
ContentIdentifierAttr Identifies the signed content. Especially when the signature is detached, it is used to match signed document and the original document. It can have any binary value.
ContentHintsAttr Provides additional information about the signed content.
SignerAttributesAttr Provides information about the signer. The claimed attributes or the attribute certificate of the signecan take place here.

When creating signatures, the attributes to be added into the signature is given to the API function as a list. They are added into the signature as follows;

List<IAttribute> optionalAttributes = new ArrayList<IAttribute>();
optionalAttributes.add(new SigningTimeAttr(Calendar.getInstance()));
optionalAttributes.add(new SignerLocationAttr("TURKEY", "KOCAELİ", new String[]{"TUBITAK UEKAE","GEBZE"}));
optionalAttributes.add(new CommitmentTypeIndicationAttr(CommitmentType.CREATION));
optionalAttributes.add(new ContentIdentifierAttr("PL123456789".getBytes("ASCII")));
				
bs.addSigner(ESignatureType.TYPE_BES, cert , signer, optionalAttributes, params);
						
SmartCardManager.getInstance().logout();
		 
//reading Attributes
BaseSignedData bs2 = new BaseSignedData(bs.getEncoded());
List<EAttribute> attrs ;
Signer aSigner = bs2.getSignerList().get(0);

attrs = aSigner.getAttribute(SigningTimeAttr.OID);
Calendar st = SigningTimeAttr.toTime(attrs.get(0));
System.out.println("Signing time: " + st.getTime());

attrs = aSigner.getAttribute(SignerLocationAttr.OID);
ESignerLocation sl = SignerLocationAttr.toSignerLocation(attrs.get(0));
StringBuilder sb = new StringBuilder();
for (String address : sl.getPostalAddress()) 
sb.append(" " + address);
System.out.println("\nCountry: " + sl.getCountry() +
		"\nCity: " + sl.getLocalityName() +"\nAdress: "	+ sb);
attrs = aSigner.getAttribute(ContentIdentifierAttr.OID);
byte [] ci = ContentIdentifierAttr.toIdentifier(attrs.get(0));
System.out.println("\n" + Arrays.toString(ci));

attrs = aSigner.getAttribute(CommitmentTypeIndicationAttr.OID);
CommitmentType ct = CommitmentTypeIndicationAttr.toCommitmentType(attrs.get(0));
System.out.println("\n" + ct);
List<IAttribute> optionalAttributes = new List<IAttribute>();
optionalAttributes.Add(new SigningTimeAttr(DateTime.UtcNow));
optionalAttributes.Add(new SignerLocationAttr("TURKEY", "KOCAELI", 
new String[] { "TUBITAK UEKAE", "GEBZE" }));
optionalAttributes.Add(new CommitmentTypeIndicationAttr(CommitmentType.CREATION));
optionalAttributes.Add(new ContentIdentifierAttr(
ASCIIEncoding.ASCII.GetBytes("PL123456789")));

bs.addSigner(ESignatureType.TYPE_BES, cert, signer, optionalAttributes, params_);
		
SmartCardManager.getInstance().logout();
		 
//reading Attributes
BaseSignedData bs2 = new BaseSignedData(bs.getEncoded());
List<EAttribute> attrs;
Signer aSigner = bs2.getSignerList()[0];

attrs = aSigner.getAttribute(SigningTimeAttr.OID);
DateTime? st = SigningTimeAttr.toTime(attrs[0]);
Console.WriteLine("Signing time: " + st.Value.ToLocalTime().ToString());

attrs = aSigner.getAttribute(SignerLocationAttr.OID);
ESignerLocation sl = SignerLocationAttr.toSignerLocation(attrs[0]);
StringBuilder sb = new StringBuilder();
foreach (String address in sl.getPostalAddress())
     sb.Append(" " + address);

Console.WriteLine("\nCountry: " + sl.getCountry() +
"\nCity: " + sl.getLocalityName() + "\nAdress: " + sb);

attrs = aSigner.getAttribute(ContentIdentifierAttr.OID);
byte[] ci = ContentIdentifierAttr.toIdentifier(attrs[0]);
Console.WriteLine("\n" + BitConverter.ToString(ci));

attrs = aSigner.getAttribute(CommitmentTypeIndicationAttr.OID);
CommitmentType ct = CommitmentTypeIndicationAttr.toCommitmentType(attrs[0]);
Console.WriteLine("\n" + ct);

en/esya/cades/imza-ozellikleri.txt · Son değiştirilme: 2013/09/02 10:24 Değiştiren: Dindar Öz