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


Java DerOutputStream.putOID方法代码示例

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


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

示例1: NamedCurve

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
NamedCurve(String name, String oid, EllipticCurve curve,
        ECPoint g, BigInteger n, int h) {
    super(curve, g, n, h);
    this.name = name;
    this.oid = oid;

    DerOutputStream out = new DerOutputStream();

    try {
        out.putOID(new ObjectIdentifier(oid));
    } catch (IOException e) {
        throw new RuntimeException("Internal error", e);
    }

    encoded = out.toByteArray();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:NamedCurve.java

示例2: encodeThis

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
private void encodeThis() throws IOException {
    if (keyUsages == null || keyUsages.isEmpty()) {
        this.extensionValue = null;
        return;
    }
    DerOutputStream os = new DerOutputStream();
    DerOutputStream tmp = new DerOutputStream();

    for (int i = 0; i < keyUsages.size(); i++) {
        tmp.putOID(keyUsages.elementAt(i));
    }

    os.write(DerValue.tag_Sequence, tmp);
    this.extensionValue = os.toByteArray();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:ExtendedKeyUsageExtension.java

示例3: encode

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
public byte[] encode() throws IOException {

        DerOutputStream request = new DerOutputStream();

        // encode version
        request.putInteger(version);

        // encode messageImprint
        DerOutputStream messageImprint = new DerOutputStream();
        hashAlgorithmId.encode(messageImprint);
        messageImprint.putOctetString(hashValue);
        request.write(DerValue.tag_Sequence, messageImprint);

        // encode optional elements

        if (policyId != null) {
            request.putOID(new ObjectIdentifier(policyId));
        }
        if (nonce != null) {
            request.putInteger(nonce);
        }
        if (returnCertificate) {
            request.putBoolean(true);
        }

        DerOutputStream out = new DerOutputStream();
        out.write(DerValue.tag_Sequence, request);
        return out.toByteArray();
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:TSRequest.java

示例4: encodeResponseBytes

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
private void encodeResponseBytes(DerOutputStream responseStream)
        throws IOException {
    DerOutputStream explicitZero = new DerOutputStream();
    DerOutputStream respItemStream = new DerOutputStream();

    respItemStream.putOID(OCSP_BASIC_RESPONSE_OID);

    byte[] basicOcspBytes = encodeBasicOcspResponse();
    respItemStream.putOctetString(basicOcspBytes);
    explicitZero.write(DerValue.tag_Sequence, respItemStream);
    responseStream.write(DerValue.createTag(DerValue.TAG_CONTEXT,
            true, (byte)0), explicitZero);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:SimpleOCSPServer.java

示例5: getDER

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
/**
 * Returns the full ASN.1 DER encoding for this oid object, which
 * includes the tag and length.
 *
 * @return byte array containing the DER encoding of this oid object.
 * @exception GSSException may be thrown when the oid can't be encoded
 */
public byte[] getDER() throws GSSException {

    if (derEncoding == null) {
        DerOutputStream dout = new DerOutputStream();
        try {
            dout.putOID(oid);
        } catch (IOException e) {
            throw new GSSException(GSSException.FAILURE, e.getMessage());
        }
        derEncoding = dout.toByteArray();
    }

    return derEncoding.clone();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Oid.java

示例6: GSSNameElement

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
GSSNameElement(byte[] nameBytes, Oid nameType, GSSLibStub stub)
    throws GSSException {
    assert(stub != null);
    if (nameBytes == null) {
        throw new GSSException(GSSException.BAD_NAME);
    }
    cStub = stub;
    byte[] name = nameBytes;

    if (nameType != null) {
        // Special handling the specified name type if
        // necessary
        nameType = getNativeNameType(nameType, stub);

        if (GSSName.NT_EXPORT_NAME.equals(nameType)) {
            // Need to add back the mech Oid portion (stripped
            // off by GSSNameImpl class prior to calling this
            // method) for "NT_EXPORT_NAME"
            byte[] mechBytes = null;
            DerOutputStream dout = new DerOutputStream();
            Oid mech = cStub.getMech();
            try {
                dout.putOID(new ObjectIdentifier(mech.toString()));
            } catch (IOException e) {
                throw new GSSExceptionImpl(GSSException.FAILURE, e);
            }
            mechBytes = dout.toByteArray();
            name = new byte[2 + 2 + mechBytes.length + 4 + nameBytes.length];
            int pos = 0;
            name[pos++] = 0x04;
            name[pos++] = 0x01;
            name[pos++] = (byte) (mechBytes.length>>>8);
            name[pos++] = (byte) mechBytes.length;
            System.arraycopy(mechBytes, 0, name, pos, mechBytes.length);
            pos += mechBytes.length;
            name[pos++] = (byte) (nameBytes.length>>>24);
            name[pos++] = (byte) (nameBytes.length>>>16);
            name[pos++] = (byte) (nameBytes.length>>>8);
            name[pos++] = (byte) nameBytes.length;
            System.arraycopy(nameBytes, 0, name, pos, nameBytes.length);
        }
    }
    pName = cStub.importName(name, nameType);
    setPrintables();

    SunNativeProvider.debug("Imported " + printableName + " w/ type " +
                            printableType);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:GSSNameElement.java

示例7: getBagAttributes

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
private byte[] getBagAttributes(String alias, byte[] keyId,
    ObjectIdentifier[] trustedUsage,
    Set<KeyStore.Entry.Attribute> attributes) throws IOException {

    byte[] localKeyID = null;
    byte[] friendlyName = null;
    byte[] trustedKeyUsage = null;

    // return null if all three attributes are null
    if ((alias == null) && (keyId == null) && (trustedKeyUsage == null)) {
        return null;
    }

    // SafeBag Attributes
    DerOutputStream bagAttrs = new DerOutputStream();

    // Encode the friendlyname oid.
    if (alias != null) {
        DerOutputStream bagAttr1 = new DerOutputStream();
        bagAttr1.putOID(PKCS9FriendlyName_OID);
        DerOutputStream bagAttrContent1 = new DerOutputStream();
        DerOutputStream bagAttrValue1 = new DerOutputStream();
        bagAttrContent1.putBMPString(alias);
        bagAttr1.write(DerValue.tag_Set, bagAttrContent1);
        bagAttrValue1.write(DerValue.tag_Sequence, bagAttr1);
        friendlyName = bagAttrValue1.toByteArray();
    }

    // Encode the localkeyId oid.
    if (keyId != null) {
        DerOutputStream bagAttr2 = new DerOutputStream();
        bagAttr2.putOID(PKCS9LocalKeyId_OID);
        DerOutputStream bagAttrContent2 = new DerOutputStream();
        DerOutputStream bagAttrValue2 = new DerOutputStream();
        bagAttrContent2.putOctetString(keyId);
        bagAttr2.write(DerValue.tag_Set, bagAttrContent2);
        bagAttrValue2.write(DerValue.tag_Sequence, bagAttr2);
        localKeyID = bagAttrValue2.toByteArray();
    }

    // Encode the trustedKeyUsage oid.
    if (trustedUsage != null) {
        DerOutputStream bagAttr3 = new DerOutputStream();
        bagAttr3.putOID(TrustedKeyUsage_OID);
        DerOutputStream bagAttrContent3 = new DerOutputStream();
        DerOutputStream bagAttrValue3 = new DerOutputStream();
        for (ObjectIdentifier usage : trustedUsage) {
            bagAttrContent3.putOID(usage);
        }
        bagAttr3.write(DerValue.tag_Set, bagAttrContent3);
        bagAttrValue3.write(DerValue.tag_Sequence, bagAttr3);
        trustedKeyUsage = bagAttrValue3.toByteArray();
    }

    DerOutputStream attrs = new DerOutputStream();
    if (friendlyName != null) {
        attrs.write(friendlyName);
    }
    if (localKeyID != null) {
        attrs.write(localKeyID);
    }
    if (trustedKeyUsage != null) {
        attrs.write(trustedKeyUsage);
    }

    if (attributes != null) {
        for (KeyStore.Entry.Attribute attribute : attributes) {
            String attributeName = attribute.getName();
            // skip friendlyName, localKeyId and trustedKeyUsage
            if (CORE_ATTRIBUTES[0].equals(attributeName) ||
                CORE_ATTRIBUTES[1].equals(attributeName) ||
                CORE_ATTRIBUTES[2].equals(attributeName)) {
                continue;
            }
            attrs.write(((PKCS12Attribute) attribute).getEncoded());
        }
    }

    bagAttrs.write(DerValue.tag_Set, attrs);
    return bagAttrs.toByteArray();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:82,代码来源:PKCS12KeyStore.java

示例8: GSSNameElement

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
GSSNameElement(byte[] nameBytes, Oid nameType, GSSLibStub stub)
    throws GSSException {
    assert(stub != null);
    if (nameBytes == null) {
        throw new GSSException(GSSException.BAD_NAME);
    }
    cStub = stub;
    byte[] name = nameBytes;

    if (nameType != null) {
        // Special handling the specified name type if
        // necessary
        nameType = getNativeNameType(nameType, stub);

        if (GSSName.NT_EXPORT_NAME.equals(nameType)) {
            // Need to add back the mech Oid portion (stripped
            // off by GSSNameImpl class prior to calling this
            // method) for "NT_EXPORT_NAME"
            byte[] mechBytes = null;
            DerOutputStream dout = new DerOutputStream();
            Oid mech = cStub.getMech();
            try {
                dout.putOID(new ObjectIdentifier(mech.toString()));
            } catch (IOException e) {
                throw new GSSExceptionImpl(GSSException.FAILURE, e);
            }
            mechBytes = dout.toByteArray();
            name = new byte[2 + 2 + mechBytes.length + 4 + nameBytes.length];
            int pos = 0;
            name[pos++] = 0x04;
            name[pos++] = 0x01;
            name[pos++] = (byte) (mechBytes.length>>>8);
            name[pos++] = (byte) mechBytes.length;
            System.arraycopy(mechBytes, 0, name, pos, mechBytes.length);
            pos += mechBytes.length;
            name[pos++] = (byte) (nameBytes.length>>>24);
            name[pos++] = (byte) (nameBytes.length>>>16);
            name[pos++] = (byte) (nameBytes.length>>>8);
            name[pos++] = (byte) nameBytes.length;
            System.arraycopy(nameBytes, 0, name, pos, nameBytes.length);
        }
    }
    pName = cStub.importName(name, nameType);
    setPrintables();

    SecurityManager sm = System.getSecurityManager();
    if (sm != null && !Realm.AUTODEDUCEREALM) {
        String krbName = getKrbName();
        int atPos = krbName.lastIndexOf('@');
        if (atPos != -1) {
            String atRealm = krbName.substring(atPos);
            // getNativeNameType() can modify NT_GSS_KRB5_PRINCIPAL to null
            if ((nameType == null
                        || nameType.equals(GSSUtil.NT_GSS_KRB5_PRINCIPAL))
                    && new String(nameBytes).endsWith(atRealm)) {
                // Created from Kerberos name with realm, no need to check
            } else {
                try {
                    sm.checkPermission(new ServicePermission(atRealm, "-"));
                } catch (SecurityException se) {
                    // Do not chain the actual exception to hide info
                    throw new GSSException(GSSException.FAILURE);
                }
            }
        }
    }

    SunNativeProvider.debug("Imported " + printableName + " w/ type " +
                            printableType);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:71,代码来源:GSSNameElement.java

示例9: encryptContent

import sun.security.util.DerOutputStream; //导入方法依赖的package包/类
private byte[] encryptContent(byte[] data, char[] password)
    throws IOException {

    byte[] encryptedData = null;

    // create AlgorithmParameters
    AlgorithmParameters algParams =
            getAlgorithmParameters("PBEWithSHA1AndRC2_40");
    DerOutputStream bytes = new DerOutputStream();
    AlgorithmId algId =
            new AlgorithmId(pbeWithSHAAnd40BitRC2CBC_OID, algParams);
    algId.encode(bytes);
    byte[] encodedAlgId = bytes.toByteArray();

    try {
        // Use JCE
        SecretKey skey = getPBEKey(password);
        Cipher cipher = Cipher.getInstance("PBEWithSHA1AndRC2_40");
        cipher.init(Cipher.ENCRYPT_MODE, skey, algParams);
        encryptedData = cipher.doFinal(data);

        if (debug != null) {
            debug.println("  (Cipher algorithm: " + cipher.getAlgorithm() +
                ")");
        }

    } catch (Exception e) {
        throw new IOException("Failed to encrypt" +
                " safe contents entry: " + e, e);
    }

    // create EncryptedContentInfo
    DerOutputStream bytes2 = new DerOutputStream();
    bytes2.putOID(ContentInfo.DATA_OID);
    bytes2.write(encodedAlgId);

    // Wrap encrypted data in a context-specific tag.
    DerOutputStream tmpout2 = new DerOutputStream();
    tmpout2.putOctetString(encryptedData);
    bytes2.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
                                    false, (byte)0), tmpout2);

    // wrap EncryptedContentInfo in a Sequence
    DerOutputStream out = new DerOutputStream();
    out.write(DerValue.tag_Sequence, bytes2);
    return out.toByteArray();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:48,代码来源:PKCS12KeyStore.java


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