本文整理汇总了Java中org.opensaml.xml.signature.KeyName类的典型用法代码示例。如果您正苦于以下问题:Java KeyName类的具体用法?Java KeyName怎么用?Java KeyName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyName类属于org.opensaml.xml.signature包,在下文中一共展示了KeyName类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeyNames
import org.opensaml.xml.signature.KeyName; //导入依赖的package包/类
/**
* Get the set of key names inside the specified {@link KeyInfo} as a list of strings.
*
* @param keyInfo {@link KeyInfo} to retrieve key names from
*
* @return a list of key name strings
*/
public static List<String> getKeyNames(KeyInfo keyInfo) {
List<String> keynameList = new LinkedList<String>();
if (keyInfo == null) {
return keynameList;
}
List<KeyName> keyNames = keyInfo.getKeyNames();
for (KeyName keyName : keyNames) {
if (keyName.getValue() != null) {
keynameList.add(keyName.getValue());
}
}
return keynameList;
}
示例2: init
import org.opensaml.xml.signature.KeyName; //导入依赖的package包/类
/**
* Helper method for constructors.
*/
private void init() {
builderFactory = Configuration.getBuilderFactory();
keyInfoBuilder =
(XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);
dataReferenceBuilder =
(XMLEncryptionBuilder<DataReference>) builderFactory.getBuilder(DataReference.DEFAULT_ELEMENT_NAME);
referenceListBuilder =
(XMLEncryptionBuilder<ReferenceList>) builderFactory.getBuilder(ReferenceList.DEFAULT_ELEMENT_NAME);
retrievalMethodBuilder =
(XMLSignatureBuilder<RetrievalMethod>) builderFactory.getBuilder(RetrievalMethod.DEFAULT_ELEMENT_NAME);
keyNameBuilder =
(XMLSignatureBuilder<KeyName>) builderFactory.getBuilder(KeyName.DEFAULT_ELEMENT_NAME);
carriedKeyNameBuilder =
(XMLEncryptionBuilder<CarriedKeyName>) builderFactory.getBuilder(CarriedKeyName.DEFAULT_ELEMENT_NAME);
try{
idGenerator = new SecureRandomIdentifierGenerator();
}catch(NoSuchAlgorithmException e){
log.error("JVM does not support SHA1PRNG random number generation algorithm.");
}
keyPlacement = KeyPlacement.PEER;
}
示例3: processKeyInfoChildren
import org.opensaml.xml.signature.KeyName; //导入依赖的package包/类
/**
* Use registered providers to process the non-KeyValue/DEREncodedKeyValue children of KeyInfo.
*
* Each child element is processed in document order. Each child element is processed by each provider in the
* ordered list of providers. The credential or credentials resolved by the first provider to successfully do so are
* added to the effective set resolved by the KeyInfo resolver.
*
* @param kiContext KeyInfo resolution context
* @param criteriaSet the credential criteria used to resolve credentials
* @param credentials the list which will store the resolved credentials
* @throws SecurityException thrown if there is a provider error processing the KeyInfo children
*/
protected void processKeyInfoChildren(KeyInfoResolutionContext kiContext, CriteriaSet criteriaSet,
List<Credential> credentials) throws SecurityException {
for (XMLObject keyInfoChild : kiContext.getKeyInfo().getXMLObjects()) {
if (keyInfoChild instanceof KeyValue || keyInfoChild instanceof DEREncodedKeyValue) {
continue;
}
log.debug("Processing KeyInfo child with qname: {}", keyInfoChild.getElementQName());
Collection<Credential> childCreds = processKeyInfoChild(kiContext, criteriaSet, keyInfoChild);
if (childCreds != null && !childCreds.isEmpty()) {
credentials.addAll(childCreds);
} else {
// Not really an error or warning if KeyName doesn't produce a credential
if (keyInfoChild instanceof KeyName) {
log.debug("KeyName, with value {}, did not independently produce a credential based on any registered providers",
((KeyName) keyInfoChild).getValue());
} else {
log.warn("No credentials could be extracted from KeyInfo child with qname {} by any registered provider",
keyInfoChild.getElementQName());
}
}
}
}
示例4: 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);
}
示例5: 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);
}
}
示例6: 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;
}
示例7: 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()));
}
示例8: buildObject
import org.opensaml.xml.signature.KeyName; //导入依赖的package包/类
/** {@inheritDoc} */
public KeyName buildObject(String namespaceURI, String localName, String namespacePrefix) {
return new KeyNameImpl(namespaceURI, localName, namespacePrefix);
}
示例9: getKeyNames
import org.opensaml.xml.signature.KeyName; //导入依赖的package包/类
/** {@inheritDoc} */
public List<KeyName> getKeyNames() {
return (List<KeyName>) indexedChildren.subList(KeyName.DEFAULT_ELEMENT_NAME);
}