Bu sayfanın seçili sürümü ile mevcut sürümü arasındaki farkları gösterir.
en:esya:ios:ios [2014/04/10 07:28] Süleyman Uslu |
en:esya:ios:ios [2014/04/10 08:10] (mevcut) Süleyman Uslu |
||
---|---|---|---|
Satır 40: | Satır 40: | ||
* Name of the license file must be ''license.dat''. | * Name of the license file must be ''license.dat''. | ||
* Files can be added to ''Documents'' folder using iTunes, but before that ''iTunes file sharing'' must be activated in ''plist'' file. | * Files can be added to ''Documents'' folder using iTunes, but before that ''iTunes file sharing'' must be activated in ''plist'' file. | ||
+ | |||
===== Code ===== | ===== Code ===== | ||
Satır 46: | Satır 47: | ||
* Interfaces are the same with JAVA and C# libraries. | * Interfaces are the same with JAVA and C# libraries. | ||
- | * Session opening process must be done in a seperated thread. Following line shows how to start a new thread. For more, refer to ''NSThread'' class reference of iOS library from Apple. | + | * Session opening process must be done in a seperated thread. Following line is where we start a new thread. For more, refer to ''NSThread'' class reference of iOS library from Apple. |
- | + | <sxh c> | |
- | <sxh objc> | + | |
[NSThread detachNewThreadSelector:@selector(login:) toTarget:(id)self withObject:nil]; | [NSThread detachNewThreadSelector:@selector(login:) toTarget:(id)self withObject:nil]; | ||
</sxh> | </sxh> | ||
+ | * An instance of SmartCardManager should be created first. | ||
- | * Öncelikle SmartCardManager sınıfı üretilir. | + | <sxh c> |
- | + | ||
- | + | ||
- | <sxh objc> | + | |
SmartCardManager smartCardManager; | SmartCardManager smartCardManager; | ||
</sxh> | </sxh> | ||
- | * Daha sonra session açılır. | + | * Then session is opened into smart card. |
- | <sxh objc> | + | <sxh c> |
smartCardManager.openSession(); | smartCardManager.openSession(); | ||
</sxh> | </sxh> | ||
- | * Şimdi imzalama işlemlerine geçilebilir. | + | * Certificate that is going to be used for signing is retrieved. |
- | + | ||
- | * İmzalamada kullanılacak sertifika alınır. | + | |
- | <sxh objc> | + | <sxh c> |
ECertificate cert = smartCardManager.getSignatureCertificate(); | ECertificate cert = smartCardManager.getSignatureCertificate(); | ||
</sxh> | </sxh> | ||
- | * İmzayı barındıracak "Container" oluşturulur. | + | * ''Container'' object is created to encapsulate the signature object. |
- | <sxh objc> | + | <sxh c> |
SignatureContainer *container = new CMSContainer(); | SignatureContainer *container = new CMSContainer(); | ||
</sxh> | </sxh> | ||
- | * Okunan sertifika ile imza oluşturulur. | + | * ''Signature'' object is created using the certificate retrieved before. |
- | <sxh objc> | + | <sxh c> |
Signature *signature = container->createSignature(cert); | Signature *signature = container->createSignature(cert); | ||
</sxh> | </sxh> | ||
- | * İmzalanacak content oluşturulur ve imzaya eklenir. Ayrıca content'in CAdES-BES içinde yer alıp almayacağı 'boolean' ile belirtilir. | + | * Content to be signed is generated and added to ''Signature'' object. Also whether the content is placed in the signature is determined by boolean value passed to ''addContent'' function. |
- | <sxh objc> | + | <sxh c> |
Signable *data = new SignableBytes(dataBytes); | Signable *data = new SignableBytes(dataBytes); | ||
signature->addContent(data, true); | signature->addContent(data, true); | ||
</sxh> | </sxh> | ||
- | * İmzalamayı yapacak 'Signer' objesi, akıllı kartın PIN'i ve imzalama yapılacak sertifika verilerek oluşturulur. | + | * ''Signer'' object, which will do signing, is generated by giving PIN of smart card and certificate. |
- | <sxh objc> | + | <sxh c> |
BaseSigner *signer = smartCardManager.getSigner("12345", cert); | BaseSigner *signer = smartCardManager.getSigner("12345", cert); | ||
</sxh> | </sxh> | ||
- | * Son olarak imzalama işlemi yapılır. | + | * In the end, ''sign'' function is called. |
- | <sxh objc> | + | <sxh c> |
signature->sign(signer); | signature->sign(signer); | ||
</sxh> | </sxh> | ||