Package apple.cryptotokenkit
Class TKSmartCard
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.cryptotokenkit.TKSmartCard
-
- All Implemented Interfaces:
NSObject
public class TKSmartCard extends NSObject
Represents SmartCard inserted in the slot. Once the card is physically removed from the slot, the session object is invalid and will always fail the operation invoked on it. In order to communicate with the card, an exclusive session must be established.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTKSmartCard.Block_beginSessionWithReplystatic interfaceTKSmartCard.Block_inSessionWithErrorExecuteBlockstatic interfaceTKSmartCard.Block_sendInsP1P2DataLeReplystatic interfaceTKSmartCard.Block_transmitRequestReply-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTKSmartCard(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccessInstanceVariablesDirectly()static TKSmartCardalloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)longallowedProtocols()Bitmask containing allowed protocols to be used when communicating with the card.static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)voidbeginSessionWithReply(TKSmartCard.Block_beginSessionWithReply reply)Begins session with the card.static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)bytecla()CLA byte which will be used for sendIns: APDU transmits.static NSArray<java.lang.String>classFallbacksForKeyedArchiver()static org.moe.natj.objc.ClassclassForKeyedUnarchiver()java.lang.Objectcontext()User-specified context kept as long as the card is powered.longcurrentProtocol()Protocol used for communication with the SmartCard.static java.lang.StringdebugDescription_static()static java.lang.Stringdescription_static()voidendSession()Terminates the transaction.static longhash_static()TKSmartCardinit()booleaninSessionWithErrorExecuteBlock(org.moe.natj.general.ptr.Ptr<NSError> error, TKSmartCard.Block_inSessionWithErrorExecuteBlock block)Synchronous variant of session creation.static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)static java.lang.Objectnew_objc()static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)voidsendInsP1P2DataLeReply(byte ins, byte p1, byte p2, NSData requestData, NSNumber le, TKSmartCard.Block_sendInsP1P2DataLeReply reply)Transmits APDU to the card and returns response.NSDatasendInsP1P2DataLeSwError(byte ins, byte p1, byte p2, NSData requestData, NSNumber le, org.moe.natj.general.ptr.CharPtr sw, org.moe.natj.general.ptr.Ptr<NSError> error)Transmits APDU to the card and returns response.booleansensitive()Flag indicating whether card session should be considered as sensitive.voidsetAllowedProtocols(long value)Bitmask containing allowed protocols to be used when communicating with the card.voidsetCla(byte value)CLA byte which will be used for sendIns: APDU transmits.voidsetContext(java.lang.Object value)User-specified context kept as long as the card is powered.voidsetSensitive(boolean value)Flag indicating whether card session should be considered as sensitive.voidsetUseCommandChaining(boolean value)Flag indicating whether command chaining of APDU with data field longer than 255 bytes can be used.voidsetUseExtendedLength(boolean value)Flag indicating whether extended length APDUs should be used.static voidsetVersion_static(long aVersion)TKSmartCardSlotslot()Slot in which is this card inserted.static org.moe.natj.objc.Classsuperclass_static()voidtransmitRequestReply(NSData request, TKSmartCard.Block_transmitRequestReply reply)Transmits raw command to the card.booleanuseCommandChaining()Flag indicating whether command chaining of APDU with data field longer than 255 bytes can be used.booleanuseExtendedLength()Flag indicating whether extended length APDUs should be used.TKSmartCardUserInteractionForSecurePINChangeuserInteractionForSecurePINChangeWithPINFormatAPDUCurrentPINByteOffsetNewPINByteOffset(TKSmartCardPINFormat PINFormat, NSData APDU, long currentPINByteOffset, long newPINByteOffset)Creates a new user interaction object for secure PIN change using the SmartCard reader facilities (typically a HW keypad).TKSmartCardUserInteractionForSecurePINVerificationuserInteractionForSecurePINVerificationWithPINFormatAPDUPINByteOffset(TKSmartCardPINFormat PINFormat, NSData APDU, long PINByteOffset)Creates a new user interaction object for secure PIN verification using the SmartCard reader facilities (typically a HW keypad).booleanvalid()Flag indicating whether card is valid, i.e. it was not removed from the reader.static longversion_static()-
Methods inherited from class apple.NSObject
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static TKSmartCard alloc()
-
allocWithZone
public static java.lang.Object allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
-
allowedProtocols
public long allowedProtocols()
Bitmask containing allowed protocols to be used when communicating with the card. This property is consulted only during connection to the card, changes are not propagated to already connected session. By default, any protocol can be used.
-
automaticallyNotifiesObserversForKey
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
-
beginSessionWithReply
public void beginSessionWithReply(TKSmartCard.Block_beginSessionWithReply reply)
Begins session with the card. When session exists, other requests for sessions from other card objects to the same card are blocked. Session is reference-counted, the same amount of 'end' calls must be done to really terminate the session. Note that finishing session does not automatically mean that the card is disconnected; it only happens when another session from different card object is requested.- Parameters:
success- Signals whether session was successfully started.error- More information about error preventing the transaction to start
-
cancelPreviousPerformRequestsWithTarget
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
-
cancelPreviousPerformRequestsWithTargetSelectorObject
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)
-
cla
public byte cla()
CLA byte which will be used for sendIns: APDU transmits. Default value is 0x00.
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
context
public java.lang.Object context()
User-specified context kept as long as the card is powered. Once the card is removed or another TKSmartCard object opens session, this property is automatically set to nil.
-
currentProtocol
public long currentProtocol()
Protocol used for communication with the SmartCard. If no card session is established, TKSmartCardProtocolNone is set.
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
endSession
public void endSession()
Terminates the transaction. If no transaction is pending any more, the connection will be closed if there is another session in the system waiting for the transaction.
-
hash_static
public static long hash_static()
-
inSessionWithErrorExecuteBlock
public boolean inSessionWithErrorExecuteBlock(org.moe.natj.general.ptr.Ptr<NSError> error, TKSmartCard.Block_inSessionWithErrorExecuteBlock block)
Synchronous variant of session creation. Begins the session, executes given block and ends session.- Parameters:
error- Error receiving more information when transaction failed to start or block failed for some reason.block- Block to be executed when the session was successfully begun.- Returns:
- Returns YES if the session was successfully begun and block returned YES, otherwise NO.
-
init
public TKSmartCard init()
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
instanceMethodSignatureForSelector
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
-
instancesRespondToSelector
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
-
isSubclassOfClass
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
new_objc
public static java.lang.Object new_objc()
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
sendInsP1P2DataLeReply
public void sendInsP1P2DataLeReply(byte ins, byte p1, byte p2, NSData requestData, NSNumber le, TKSmartCard.Block_sendInsP1P2DataLeReply reply)Transmits APDU to the card and returns response. Asynchronous high level variant of command for transmitting APDU to the card. Handles all ISO7816-4 APDU cases translation to proper sequences according to used protocol. Consults useExtendedAPDU and useCommandChaining properties and uses these modes whenever appropriate and beneficial for sending requested APDU request.- Parameters:
ins- INS code of the APDUp1- P1 code of the APDUp2- P2 code of the APDUrequestData- Data field of the APDU, or nil if no input data field should be present (i.e case1 or case2 APDUs). Length of the data serves as Lc field of the APDU.le- Expected number of bytes to be returned, or nil if no output data are expected (i.e. case1 or case3 APDUs). To get as much bytes as card provides, pass @0.replyData- Block of returned data without SW1SW2 bytes, or nil if an error occured.sw- SW1SW2 result code, first two bytes of returned card's reply.error- Contains error details when nil is returned. Specific error is also filled in if there was no communication error, but card returned other SW code than 0x9000.
-
sendInsP1P2DataLeSwError
public NSData sendInsP1P2DataLeSwError(byte ins, byte p1, byte p2, NSData requestData, NSNumber le, org.moe.natj.general.ptr.CharPtr sw, org.moe.natj.general.ptr.Ptr<NSError> error)
Transmits APDU to the card and returns response. Synchronous high level variant of command for transmitting APDU to the card. Handles all ISO7816-4 APDU cases translation to proper sequences according to used protocol. Should be used in block passed to -[TKSmartCard inSessionWithError:executeBlock:] method.- Parameters:
ins- INS code of the APDUp1- P1 code of the APDUp2- P2 code of the APDUdata- Data field of the APDU. Length of the data serves as Lc field of the APDUle- Expected number of bytes to be returned, or nil if no output data are expected (i.e. case1 or case3 APDUs). To get as much bytes as card provides, pass @0.sw- On output, filled with SW1SW2 result codeerror- Contains error details when nil is returned. Specific error is also filled in if there was no communication error, but card returned other SW code than 0x9000.- Returns:
- Returned data field, excluding SW status bytes. If an error occured, returns nil.
-
sensitive
public boolean sensitive()
Flag indicating whether card session should be considered as sensitive. Sensitive session always gets card after reset before communicating with it and never leaves card without reset to be used by another SmartCard object. This might be important in case that card session contain some important state which should not leak to another SmartCard object (possibly running in another, foreign application). Default is NO.
-
setAllowedProtocols
public void setAllowedProtocols(long value)
Bitmask containing allowed protocols to be used when communicating with the card. This property is consulted only during connection to the card, changes are not propagated to already connected session. By default, any protocol can be used.
-
setCla
public void setCla(byte value)
CLA byte which will be used for sendIns: APDU transmits. Default value is 0x00.
-
setContext
public void setContext(java.lang.Object value)
User-specified context kept as long as the card is powered. Once the card is removed or another TKSmartCard object opens session, this property is automatically set to nil.
-
setSensitive
public void setSensitive(boolean value)
Flag indicating whether card session should be considered as sensitive. Sensitive session always gets card after reset before communicating with it and never leaves card without reset to be used by another SmartCard object. This might be important in case that card session contain some important state which should not leak to another SmartCard object (possibly running in another, foreign application). Default is NO.
-
setUseCommandChaining
public void setUseCommandChaining(boolean value)
Flag indicating whether command chaining of APDU with data field longer than 255 bytes can be used. It is automatically enabled when card announces that command chaining is supported in its ATR. However, caller can explicitly override this decision.
-
setUseExtendedLength
public void setUseExtendedLength(boolean value)
Flag indicating whether extended length APDUs should be used. It is automatically enabled only when used slot supports transmitting extended length commands and card announces that extended length APDU are supported in its ATR. However, caller can explicitly override this decision.
-
setVersion_static
public static void setVersion_static(long aVersion)
-
slot
public TKSmartCardSlot slot()
Slot in which is this card inserted.
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
transmitRequestReply
public void transmitRequestReply(NSData request, TKSmartCard.Block_transmitRequestReply reply)
Transmits raw command to the card. This call is allowed only inside session.- Parameters:
request- Request part of APDUreponse- Response part of APDU, or nil if communication with the card failederror- Error details when communication with the card failed
-
useCommandChaining
public boolean useCommandChaining()
Flag indicating whether command chaining of APDU with data field longer than 255 bytes can be used. It is automatically enabled when card announces that command chaining is supported in its ATR. However, caller can explicitly override this decision.
-
useExtendedLength
public boolean useExtendedLength()
Flag indicating whether extended length APDUs should be used. It is automatically enabled only when used slot supports transmitting extended length commands and card announces that extended length APDU are supported in its ATR. However, caller can explicitly override this decision.
-
userInteractionForSecurePINChangeWithPINFormatAPDUCurrentPINByteOffsetNewPINByteOffset
public TKSmartCardUserInteractionForSecurePINChange userInteractionForSecurePINChangeWithPINFormatAPDUCurrentPINByteOffsetNewPINByteOffset(TKSmartCardPINFormat PINFormat, NSData APDU, long currentPINByteOffset, long newPINByteOffset)
Creates a new user interaction object for secure PIN change using the SmartCard reader facilities (typically a HW keypad). [@note] This interaction is only allowed within a session.- Parameters:
PINFormat- PIN format descriptor.APDU- Predefined APDU in which the SmartCard reader fills in the PIN(s).currentPINByteOffset- Offset in bytes within APDU data field to mark a location of a PIN block for filling in the current PIN.newPINByteOffset- Offset in bytes within APDU data field to mark a location of a PIN block for filling in the new PIN.- Returns:
- A new user interaction object, or nil if this feature is not supported by the SmartCard reader. After the interaction has been successfully completed the operation result is available in the result properites.
-
userInteractionForSecurePINVerificationWithPINFormatAPDUPINByteOffset
public TKSmartCardUserInteractionForSecurePINVerification userInteractionForSecurePINVerificationWithPINFormatAPDUPINByteOffset(TKSmartCardPINFormat PINFormat, NSData APDU, long PINByteOffset)
Creates a new user interaction object for secure PIN verification using the SmartCard reader facilities (typically a HW keypad). [@note] This interaction is only allowed within a session.- Parameters:
PINFormat- PIN format descriptor.APDU- Predefined APDU in which the SmartCard reader fills in the PIN.PINByteOffset- Offset in bytes within APDU data field to mark a location of a PIN block for filling in the entered PIN (currently unused, must be 0).- Returns:
- A new user interaction object, or nil if this feature is not supported by the SmartCard reader. After the interaction has been successfully completed the operation result is available in the result properites.
-
valid
public boolean valid()
Flag indicating whether card is valid, i.e. it was not removed from the reader. Use Key-Value-Observing to be notified about card removal.
-
version_static
public static long version_static()
-
-