本文整理汇总了Java中com.sun.jna.NativeLong.equals方法的典型用法代码示例。如果您正苦于以下问题:Java NativeLong.equals方法的具体用法?Java NativeLong.equals怎么用?Java NativeLong.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.NativeLong
的用法示例。
在下文中一共展示了NativeLong.equals方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: slotEventHappened
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
protected void slotEventHappened(NativeLong id) throws Pkcs11Exception {
CK_SLOT_INFO slotInfo = new CK_SLOT_INFO();
NativeLong rv;
rv = RtPkcs11Library.getInstance().C_GetSlotInfo(id, slotInfo);
if (!rv.equals(Pkcs11Constants.CKR_OK)) {
throw Pkcs11Exception.exceptionWithCode(rv);
}
EventType event;
if ((Pkcs11Constants.CKF_TOKEN_PRESENT.intValue() & slotInfo.flags.intValue()) != 0x00) {
event = EventType.SD;
} else {
event = EventType.SR;
}
if (lastSlotEvent.get(id) == event) {
mHandler.post(new EventRunnable(oppositeEvent(event), id));
lastSlotEvent.put(id, oppositeEvent(event));
}
mHandler.post(new EventRunnable(event, id));
lastSlotEvent.put(id, event);
}
示例2: findObject
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
private NativeLong findObject(RtPkcs11 pkcs11, NativeLong session, CK_ATTRIBUTE[] template)
throws Pkcs11CallerException {
NativeLong rv = pkcs11.C_FindObjectsInit(session,
template, new NativeLong(template.length));
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
NativeLong objects[] = new NativeLong[1];
NativeLongByReference count =
new NativeLongByReference(new NativeLong(objects.length));
rv = pkcs11.C_FindObjects(session, objects, new NativeLong(objects.length),
count);
NativeLong rv2 = pkcs11.C_FindObjectsFinal(session);
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
else if (!rv2.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv2);
else if (count.getValue().intValue() <= 0) return null;
return objects[0];
}
示例3: Token
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
Token(NativeLong slotId) throws Pkcs11CallerException {
RtPkcs11 pkcs11 = RtPkcs11Library.getInstance();
synchronized (pkcs11) {
mId = slotId;
initTokenInfo();
NativeLongByReference session = new NativeLongByReference();
NativeLong rv = RtPkcs11Library.getInstance().C_OpenSession(mId,
Pkcs11Constants.CKF_SERIAL_SESSION, null, null, session);
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
mSession = session.getValue();
try {
initCertificatesList(pkcs11);
} catch (Pkcs11CallerException exception) {
try {
close();
} catch (Pkcs11CallerException exception2) {
}
throw exception;
}
}
}
示例4: getLocalizedDescription
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
private static String getLocalizedDescription(NativeLong code) {
if (code.equals(Pkcs11Constants.CKR_PIN_INCORRECT)) return "PIN incorrect";
else if (code.equals(Pkcs11Constants.CKR_PIN_INVALID)) return "PIN invalid";
else if (code.equals(Pkcs11Constants.CKR_PIN_LEN_RANGE)) return "Wrong PIN length";
else if (code.equals(Pkcs11Constants.CKR_PIN_LOCKED)) return "PIN locked";
else if (code.equals(Pkcs11Constants.CKR_USER_PIN_NOT_INITIALIZED)) return "PIN not initialized";
else return String.format("Unknown PKCS11 error %08x", code.intValue());
}
示例5: getCertificatesWithCategory
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
private Map<NativeLong, Certificate> getCertificatesWithCategory(RtPkcs11 pkcs11, CertificateCategory category) throws Pkcs11CallerException {
CK_ATTRIBUTE[] template = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(2);
NativeLongByReference certClass =
new NativeLongByReference(Pkcs11Constants.CKO_CERTIFICATE);
template[0].type = Pkcs11Constants.CKA_CLASS;
template[0].pValue = certClass.getPointer();
template[0].ulValueLen = new NativeLong(NativeLong.SIZE);
NativeLongByReference certCategory = new NativeLongByReference(new NativeLong(category.getValue()));
template[1].type = Pkcs11Constants.CKA_CERTIFICATE_CATEGORY;
template[1].pValue = certCategory.getPointer();
template[1].ulValueLen = new NativeLong(NativeLong.SIZE);
NativeLong rv =
pkcs11.C_FindObjectsInit(mSession, template, new NativeLong(template.length));
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
NativeLong[] objects = new NativeLong[30];
NativeLongByReference count = new NativeLongByReference(new NativeLong(objects.length));
ArrayList<NativeLong> certs = new ArrayList<NativeLong>();
do {
rv = pkcs11.C_FindObjects(mSession, objects, new NativeLong(objects.length), count);
if (!rv.equals(Pkcs11Constants.CKR_OK)) break;
certs.addAll(Arrays.asList(objects).subList(0, count.getValue().intValue()));
} while (count.getValue().intValue() == objects.length);
NativeLong rv2 = pkcs11.C_FindObjectsFinal(mSession);
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
else if (!rv2.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv2);
HashMap<NativeLong, Certificate> certificateMap = new HashMap<NativeLong, Certificate>();
for (NativeLong c : certs) {
certificateMap.put(c, new Certificate(pkcs11, mSession, c));
}
return certificateMap;
}
示例6: onTokenRemoved
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
protected void onTokenRemoved(NativeLong slotId) {
if (slotId == null) return;
if (slotId.equals(mSlotId)) {
if (mPaymentsCreated) {
mPaymentsCreated = false;
mDoWait = true;
mWaitCertificate = mCertificate;
mWaitToken = mToken;
}
resetSlotInfo();
if (mMainActivity != null) mMainActivity.updateScreen();
for (NativeLong slot : TokenManager.getInstance().slots()) {
if (!mSlotId.equals(NO_SLOT))
break;
processConnectedToken(slot, TokenManager.getInstance().tokenForSlot(slot));
}
if (mMainActivity == null) {
for (ManagedActivity activity : mActivities) {
activity.finishExternally();
}
mWaitingForMainActivity = true;
}
}
}
示例7: Certificate
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
public Certificate(RtPkcs11 pkcs11, NativeLong session, NativeLong object)
throws Pkcs11CallerException {
CK_ATTRIBUTE[] attributes = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(2);
attributes[0].type = Pkcs11Constants.CKA_SUBJECT;
attributes[1].type = Pkcs11Constants.CKA_VALUE;
NativeLong rv = pkcs11.C_GetAttributeValue(session, object,
attributes, new NativeLong(attributes.length));
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
for (CK_ATTRIBUTE attr : attributes) {
attr.pValue = new Memory(attr.ulValueLen.intValue());
}
rv = pkcs11.C_GetAttributeValue(session, object,
attributes, new NativeLong(attributes.length));
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
byte[] subjectValue =
attributes[0].pValue.getByteArray(0, attributes[0].ulValueLen.intValue());
mSubject = X500Name.getInstance(subjectValue);
if (mSubject == null) throw new CertNotFoundException();
byte[] keyValue = null;
try {
X509CertificateHolder certificateHolder = new X509CertificateHolder(
attributes[1].pValue.getByteArray(0, attributes[1].ulValueLen.intValue()));
SubjectPublicKeyInfo publicKeyInfo = certificateHolder.getSubjectPublicKeyInfo();
keyValue = publicKeyInfo.parsePublicKey().getEncoded();
} catch (IOException exception) {
throw new CertParsingException();
}
if (keyValue == null) throw new KeyNotFoundException();
// уберём заголовок ключа (первые 2 байта)
keyValue = Arrays.copyOfRange(keyValue, 2, keyValue.length);
CK_ATTRIBUTE[] template = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(2);
final NativeLongByReference keyClass =
new NativeLongByReference(Pkcs11Constants.CKO_PUBLIC_KEY);
template[0].type = Pkcs11Constants.CKA_CLASS;
template[0].pValue = keyClass.getPointer();
template[0].ulValueLen = new NativeLong(NativeLong.SIZE);
ByteBuffer valueBuffer = ByteBuffer.allocateDirect(keyValue.length);
valueBuffer.put(keyValue);
template[1].type = Pkcs11Constants.CKA_VALUE;
template[1].pValue = Native.getDirectBufferPointer(valueBuffer);
template[1].ulValueLen = new NativeLong(keyValue.length);
NativeLong pubKeyHandle = findObject(pkcs11, session, template);
if (pubKeyHandle == null) throw new KeyNotFoundException();
CK_ATTRIBUTE[] idTemplate = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(1);
idTemplate[0].type = Pkcs11Constants.CKA_ID;
rv = pkcs11.C_GetAttributeValue(session, pubKeyHandle,
idTemplate, new NativeLong(idTemplate.length));
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
idTemplate[0].pValue = new Memory(idTemplate[0].ulValueLen.intValue());
rv = pkcs11.C_GetAttributeValue(session, pubKeyHandle,
idTemplate, new NativeLong(idTemplate.length));
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
mKeyPairId = idTemplate[0].pValue.getByteArray(0, idTemplate[0].ulValueLen.intValue());
}
示例8: close
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
void close() throws Pkcs11Exception {
NativeLong rv = RtPkcs11Library.getInstance().C_CloseSession(mSession);
if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
}
示例9: initTokenInfo
import com.sun.jna.NativeLong; //导入方法依赖的package包/类
private void initTokenInfo() throws Pkcs11CallerException {
CK_TOKEN_INFO tokenInfo = new CK_TOKEN_INFO();
CK_TOKEN_INFO_EXTENDED tokenInfoEx = new CK_TOKEN_INFO_EXTENDED();
tokenInfoEx.ulSizeofThisStructure = new NativeLong(tokenInfoEx.size());
NativeLong rv = RtPkcs11Library.getInstance().C_GetTokenInfo(mId, tokenInfo);
if (!rv.equals(Pkcs11Constants.CKR_OK)) {
throw Pkcs11Exception.exceptionWithCode(rv);
}
rv = RtPkcs11Library.getInstance().C_EX_GetTokenInfoExtended(mId, tokenInfoEx);
if (!rv.equals(Pkcs11Constants.CKR_OK)) {
throw Pkcs11Exception.exceptionWithCode(rv);
}
mLabel = Utils.removeTrailingSpaces(tokenInfo.label);
mModel = Utils.removeTrailingSpaces(tokenInfo.model);
mSerialNumber = Utils.removeTrailingSpaces(tokenInfo.serialNumber);
int decSerial = Integer.parseInt(mSerialNumber, 16);
String decSerialString = String.valueOf(decSerial);
mShortDecSerialNumber = String.valueOf(decSerial % 100000);
mHardwareVersion = String.format("%d.%d.%d.%d",
tokenInfo.hardwareVersion.major, tokenInfo.hardwareVersion.minor,
tokenInfo.firmwareVersion.major, tokenInfo.firmwareVersion.minor);
mTotalMemory = tokenInfo.ulTotalPublicMemory.intValue();
mFreeMemory = tokenInfo.ulFreePublicMemory.intValue();
mCharge = tokenInfoEx.ulBatteryVoltage.intValue();
mUserPinRetriesLeft = tokenInfoEx.ulUserRetryCountLeft.intValue();
mAdminPinRetriesLeft = tokenInfoEx.ulAdminRetryCountLeft.intValue();
if (tokenInfoEx.ulBodyColor.equals(RtPkcs11Constants.TOKEN_BODY_COLOR_WHITE)) {
mColor = BodyColor.WHITE;
} else if (tokenInfoEx.ulBodyColor.equals(RtPkcs11Constants.TOKEN_BODY_COLOR_BLACK)) {
mColor = BodyColor.BLACK;
} else if (tokenInfoEx.ulBodyColor.equals(RtPkcs11Constants.TOKEN_BODY_COLOR_UNKNOWN)) {
mColor = BodyColor.UNKNOWN;
}
if (((tokenInfoEx.flags.intValue() & RtPkcs11Constants.TOKEN_FLAGS_ADMIN_CHANGE_USER_PIN.intValue()) != 0x00)
&& ((tokenInfoEx.flags.intValue() & RtPkcs11Constants.TOKEN_FLAGS_USER_CHANGE_USER_PIN.intValue()) != 0x00)) {
mUserPinChangePolicy = UserChangePolicy.BOTH;
} else if (((tokenInfoEx.flags.intValue() & RtPkcs11Constants.TOKEN_FLAGS_ADMIN_CHANGE_USER_PIN.intValue()) != 0x00)) {
mUserPinChangePolicy = UserChangePolicy.SO;
} else {
mUserPinChangePolicy = UserChangePolicy.USER;
}
mSupportsSM = ((tokenInfoEx.flags.intValue() & RtPkcs11Constants.TOKEN_FLAGS_SUPPORT_SM.intValue()) != 0);
}