当前位置: 首页>>代码示例>>Java>>正文


Java NativeLong.SIZE属性代码示例

本文整理汇总了Java中com.sun.jna.NativeLong.SIZE属性的典型用法代码示例。如果您正苦于以下问题:Java NativeLong.SIZE属性的具体用法?Java NativeLong.SIZE怎么用?Java NativeLong.SIZE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.sun.jna.NativeLong的用法示例。


在下文中一共展示了NativeLong.SIZE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPrivateKeyHandle

public NativeLong getPrivateKeyHandle(RtPkcs11 pkcs11, NativeLong session)
        throws Pkcs11CallerException {
    CK_ATTRIBUTE[] template = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(2);

    final NativeLongByReference keyClass =
            new NativeLongByReference(Pkcs11Constants.CKO_PRIVATE_KEY);
    template[0].type = Pkcs11Constants.CKA_CLASS;
    template[0].pValue = keyClass.getPointer();
    template[0].ulValueLen = new NativeLong(NativeLong.SIZE);

    ByteBuffer idBuffer = ByteBuffer.allocateDirect(mKeyPairId.length);
    idBuffer.put(mKeyPairId);
    template[1].type = Pkcs11Constants.CKA_ID;
    template[1].pValue = Native.getDirectBufferPointer(idBuffer);
    template[1].ulValueLen = new NativeLong(mKeyPairId.length);

    return findObject(pkcs11, session, template);
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:18,代码来源:Certificate.java

示例2: checkHandle

private boolean checkHandle(long playHandle)
{
    if (4 == NativeLong.SIZE)
    {
        if (4294967295L < playHandle || -2147483648L > playHandle)
        {
            return false;
        }
    }
    return true;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:11,代码来源:RealPlayService.java

示例3: checkHandle

private boolean checkHandle(long playHandle) {
	if (IVSConstant.IVS_OS_32 == NativeLong.SIZE) {
		if (IVSConstant.IVS_INT_MAX < playHandle || IVSConstant.IVS_INT_MIN > playHandle) {
			return false;
		}
	}
	return true;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:8,代码来源:BusinessMgrCability.java

示例4: getCertificatesWithCategory

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;
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:38,代码来源:Token.java

示例5: getValue

/**
 * @return The value of this {@link CFNumberRef} as a {@link Number}.
 */
public Number getValue() {
	if (this.getPointer() == null) {
		return null;
	}
	CFNumberType numberType = INSTANCE.CFNumberGetType(this);
	Memory value = new Memory(8);
	INSTANCE.CFNumberGetValue(this, numberType, value);
	switch (numberType) {
		case kCFNumberCFIndexType:
		case kCFNumberSInt32Type:
			return value.getInt(0);
		case kCFNumberCGFloatType:
		case kCFNumberMaxType:
			if (NativeLong.SIZE == 8) {
				return value.getDouble(0);
			}
			return value.getFloat(0);
		case kCFNumberCharType:
			return (int) value.getChar(0);
		case kCFNumberDoubleType:
		case kCFNumberFloat64Type:
			return value.getDouble(0);
		case kCFNumberFloatType:
		case kCFNumberFloat32Type:
			return value.getFloat(0);
		case kCFNumberLongLongType:
		case kCFNumberSInt64Type:
			return value.getLong(0);
		case kCFNumberIntType:
		case kCFNumberLongType:
		case kCFNumberNSIntegerType:
			return value.getNativeLong(0);
		case kCFNumberSInt16Type:
		case kCFNumberShortType:
			return value.getShort(0);
		case kCFNumberSInt8Type:
			return value.getByte(0);
		default:
			throw new IllegalStateException("Unimplemented value " + numberType);
	}
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:44,代码来源:CoreFoundation.java

示例6: Certificate

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());
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:70,代码来源:Certificate.java


注:本文中的com.sun.jna.NativeLong.SIZE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。