Search in sources :

Example 1 with OCTET_STRING

use of org.mozilla.jss.asn1.OCTET_STRING in project OpenAM by OpenRock.

the class SecureLogHelperJSSImpl method createBagAttrs.

/**
     * Creates bag attributes.
     * @param nickName The nickname of the key / signature
     * @param localKeyId A hash of the entry to uniquely identify the given
     * key / signature
     * @throws Exception if it fails to generate key identifier
     */
private SET createBagAttrs(String nickName, byte[] localKeyId) throws Exception {
    try {
        SET attrs = new SET();
        SEQUENCE nickNameAttr = new SEQUENCE();
        nickNameAttr.addElement(SafeBag.FRIENDLY_NAME);
        SET nickNameSet = new SET();
        nickNameSet.addElement(new BMPString(nickName));
        nickNameAttr.addElement(nickNameSet);
        attrs.addElement(nickNameAttr);
        SEQUENCE localKeyAttr = new SEQUENCE();
        localKeyAttr.addElement(SafeBag.LOCAL_KEY_ID);
        SET localKeySet = new SET();
        localKeySet.addElement(new OCTET_STRING(localKeyId));
        localKeyAttr.addElement(localKeySet);
        attrs.addElement(localKeyAttr);
        return attrs;
    } catch (Exception e) {
        Debug.error("SecureLogHelper.createBagAttrs() : " + " Exception : ", e);
        throw new Exception("Failed to create Key Bag - " + e.toString());
    }
}
Also used : SET(org.mozilla.jss.asn1.SET) OCTET_STRING(org.mozilla.jss.asn1.OCTET_STRING) SEQUENCE(org.mozilla.jss.asn1.SEQUENCE) BMPString(org.mozilla.jss.asn1.BMPString)

Example 2 with OCTET_STRING

use of org.mozilla.jss.asn1.OCTET_STRING in project OpenAM by OpenRock.

the class SecureLogHelperJSSImpl method AddToSecretStore.

/**
     * Adds  secret information to the secret Storage.
     * @param cryptoMaterial : The data to be added
     */
private SEQUENCE AddToSecretStore(byte[] cryptoMaterial, String DataType) throws Exception {
    SEQUENCE encSafeContents = new SEQUENCE();
    ASN1Value data = new OCTET_STRING(cryptoMaterial);
    byte[] localKeyId = createLocalKeyId(cryptoMaterial);
    SET keyAttrs = createBagAttrs(DataType, localKeyId);
    // attributes: user friendly name, Local Key ID
    SafeBag keyBag = new SafeBag(SafeBag.SECRET_BAG, data, keyAttrs);
    encSafeContents.addElement(keyBag);
    return encSafeContents;
}
Also used : ASN1Value(org.mozilla.jss.asn1.ASN1Value) OCTET_STRING(org.mozilla.jss.asn1.OCTET_STRING) SET(org.mozilla.jss.asn1.SET) SEQUENCE(org.mozilla.jss.asn1.SEQUENCE) SafeBag(org.mozilla.jss.pkcs12.SafeBag)

Aggregations

OCTET_STRING (org.mozilla.jss.asn1.OCTET_STRING)2 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)2 SET (org.mozilla.jss.asn1.SET)2 ASN1Value (org.mozilla.jss.asn1.ASN1Value)1 BMPString (org.mozilla.jss.asn1.BMPString)1 SafeBag (org.mozilla.jss.pkcs12.SafeBag)1