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());
}
}
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;
}