當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyName.setValue方法代碼示例

本文整理匯總了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);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:KeyInfoHelper.java

示例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);
        
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:44,代碼來源:Encrypter.java

示例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;
}
 
開發者ID:amagdenko,項目名稱:oiosaml.java,代碼行數:16,代碼來源:SAMLUtil.java

示例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()));
    
}
 
開發者ID:apigee,項目名稱:java-opensaml2,代碼行數:43,代碼來源:SimpleEncryptionTest.java


注:本文中的org.opensaml.xml.signature.KeyName.setValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。