本文整理汇总了Java中org.opensaml.xml.signature.KeyName.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java KeyName.setValue方法的具体用法?Java KeyName.setValue怎么用?Java KeyName.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.xml.signature.KeyName
的用法示例。
在下文中一共展示了KeyName.setValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addKeyName
import org.opensaml.xml.signature.KeyName; //导入方法依赖的package包/类
/**
* Add a new {@link KeyName} value to a KeyInfo.
*
* @param keyInfo the KeyInfo to which to add the new value
* @param keyNameValue the new key name value to add
*/
public static void addKeyName(KeyInfo keyInfo, String keyNameValue) {
KeyName keyName = (KeyName) Configuration.getBuilderFactory()
.getBuilder(KeyName.DEFAULT_ELEMENT_NAME)
.buildObject(KeyName.DEFAULT_ELEMENT_NAME);
keyName.setValue(keyNameValue);
keyInfo.getKeyNames().add(keyName);
}
示例2: linkMultiplePeerKeys
import org.opensaml.xml.signature.KeyName; //导入方法依赖的package包/类
/**
* Link multiple "multicast" EncryptedKeys to the EncryptedData according
* to guidelines in SAML Errata E43.
*
* @param encData the EncryptedData
* @param encKeys the list of EncryptedKeys
*/
protected void linkMultiplePeerKeys(EncryptedData encData, List<EncryptedKey> encKeys) {
log.debug("Linking multiple peer EncryptedKeys with CarriedKeyName and DataReference");
// Get the name of the data encryption key
List<KeyName> dataEncKeyNames = encData.getKeyInfo().getKeyNames();
String carriedKeyNameValue;
if (dataEncKeyNames.size() == 0 || DatatypeHelper.isEmpty(dataEncKeyNames.get(0).getValue()) ) {
// If there isn't one, autogenerate a random key name.
String keyNameValue = idGenerator.generateIdentifier();
log.debug("EncryptedData encryption key had no KeyName, generated one for use in CarriedKeyName: {}",
keyNameValue);
KeyName keyName = dataEncKeyNames.get(0);
if (keyName == null) {
keyName = keyNameBuilder.buildObject();
dataEncKeyNames.add(keyName);
}
keyName.setValue(keyNameValue);
carriedKeyNameValue = keyNameValue;
} else {
carriedKeyNameValue = dataEncKeyNames.get(0).getValue();
}
// Set carried key name of the multicast key in each EncryptedKey
for (EncryptedKey encKey : encKeys) {
if (encKey.getCarriedKeyName() == null) {
encKey.setCarriedKeyName(carriedKeyNameBuilder.buildObject());
}
encKey.getCarriedKeyName().setValue(carriedKeyNameValue);
// Back reference from the EncryptedKeys to the EncryptedData
DataReference dr = dataReferenceBuilder.buildObject();
dr.setURI("#" + encData.getID());
encKey.getReferenceList().getDataReferences().add(dr);
}
}
示例3: createSignature
import org.opensaml.xml.signature.KeyName; //导入方法依赖的package包/类
/**
* Create a SAML signature with a given keyName.
*
* @param keyName
* The keyName
* @return The SAML signature with the given keyInfo
*/
public static Signature createSignature(String keyName) {
Signature signature = buildXMLObject(Signature.class);
signature.setKeyInfo(buildXMLObject(KeyInfo.class));
KeyName kn = buildXMLObject(KeyName.class);
kn.setValue(keyName);
signature.getKeyInfo().getKeyNames().add(kn);
return signature;
}
示例4: testNewID
import org.opensaml.xml.signature.KeyName; //导入方法依赖的package包/类
/**
* Test basic encryption with symmetric key, no key wrap,
* set key name in passed KeyInfo object.
*/
public void testNewID() {
NewID target = (NewID) buildXMLObject(NewID.DEFAULT_ELEMENT_NAME);
target.setNewID("SomeNewID");
KeyName keyName = (KeyName) buildXMLObject(org.opensaml.xml.signature.KeyName.DEFAULT_ELEMENT_NAME);
keyName.setValue(expectedKeyName);
keyInfo.getKeyNames().add(keyName);
encParams.setKeyInfoGenerator(new StaticKeyInfoGenerator(keyInfo));
encrypter = new Encrypter(encParams, kekParamsList);
NewEncryptedID encTarget = null;
XMLObject encObject = null;
try {
encObject = encrypter.encrypt(target);
} catch (EncryptionException e) {
fail("Object encryption failed: " + e);
}
assertNotNull("Encrypted object was null", encObject);
assertTrue("Encrypted object was not an instance of the expected type",
encObject instanceof NewEncryptedID);
encTarget = (NewEncryptedID) encObject;
assertEquals("Type attribute", EncryptionConstants.TYPE_ELEMENT, encTarget.getEncryptedData().getType());
assertEquals("Algorithm attribute", algoURI,
encTarget.getEncryptedData().getEncryptionMethod().getAlgorithm());
assertNotNull("KeyInfo", encTarget.getEncryptedData().getKeyInfo());
assertEquals("KeyName", expectedKeyName,
encTarget.getEncryptedData().getKeyInfo().getKeyNames().get(0).getValue());
assertEquals("Number of EncryptedKeys", 0,
encTarget.getEncryptedData().getKeyInfo().getEncryptedKeys().size());
assertFalse("EncryptedData ID attribute was empty",
DatatypeHelper.isEmpty(encTarget.getEncryptedData().getID()));
}