当前位置: 首页>>代码示例>>Java>>正文


Java KeySelector.singletonKeySelector方法代码示例

本文整理汇总了Java中javax.xml.crypto.KeySelector.singletonKeySelector方法的典型用法代码示例。如果您正苦于以下问题:Java KeySelector.singletonKeySelector方法的具体用法?Java KeySelector.singletonKeySelector怎么用?Java KeySelector.singletonKeySelector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.crypto.KeySelector的用法示例。


在下文中一共展示了KeySelector.singletonKeySelector方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testValidatePublicKey

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
@Test
public void testValidatePublicKey () throws Exception
{
    final AuthorizationRequest request = makeRequest ();

    final Document doc = this.builder.buildFromRequest ( request );
    this.signer.sign ( this.kp, doc );

    System.out.println ( "Key: " + this.kp.getPrivate () );

    final RequestValidator validator1 = new RequestValidator ( KeySelector.singletonKeySelector ( this.kp.getPublic () ) );
    final RequestValidator validator2 = new RequestValidator ( new KeyValueKeySelector () );

    Assert.assertTrue ( "XML Core Validation (Public Key)", validator1.validate ( doc ).isValid () );
    Assert.assertTrue ( "XML Core Validation (KeyValueKeySelector)", validator2.validate ( doc ).isValid () );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:SignatureRequestBuilderTest.java

示例2: getKeyAccessor

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
static KeyAccessor getKeyAccessor() {
    KeyAccessor accessor = new KeyAccessor() {

        @Override
        public KeySelector getKeySelector(Message message) throws Exception {
            return KeySelector.singletonKeySelector(getKeyFromKeystore());
        }

        @Override
        public KeyInfo getKeyInfo(Message mess, Node messageBody,
                                  KeyInfoFactory keyInfoFactory) throws Exception {
            return null;
        }
    };
    return accessor;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ECDSASignatureTest.java

示例3: main

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(false);
    dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
    Document doc = dbf.newDocumentBuilder().parse(new File(SIGNATURE));
    NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS,
            "Signature");
    if (nl.getLength() == 0) {
        throw new RuntimeException("Couldn't find 'Signature' element");
    }
    Element element = (Element) nl.item(0);

    byte[] keyBytes = Base64.getDecoder().decode(validationKey);
    X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
    KeyFactory kf = KeyFactory.getInstance("RSA");
    PublicKey key = kf.generatePublic(spec);
    KeySelector ks = KeySelector.singletonKeySelector(key);

    DOMValidateContext vc = new DOMValidateContext(ks, element);

    // disable secure validation mode
    vc.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.FALSE);

    // set a dummy dereferencer to be able to get content by references
    vc.setURIDereferencer(dereferencer);

    XMLSignatureFactory factory = XMLSignatureFactory.getInstance();
    XMLSignature signature = factory.unmarshalXMLSignature(vc);

    // run validation
    signature.validate(vc);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ErrorHandlerPermissions.java

示例4: testsetngetKeySelector

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
@org.junit.Test
public void testsetngetKeySelector() throws Exception {
    defContext.setKeySelector(null);
    assertNull(defContext.getKeySelector());
    KeySelector ks = KeySelector.singletonKeySelector(KEYS[0]);
    defContext.setKeySelector(ks);
    assertEquals(defContext.getKeySelector(), ks);
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:9,代码来源:XMLSignContextTest.java

示例5: getKeyAccessor

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
static KeyAccessor getKeyAccessor(final PrivateKey privateKey) {
    KeyAccessor accessor = new KeyAccessor() {

        @Override
        public KeySelector getKeySelector(Message message) throws Exception {
            return KeySelector.singletonKeySelector(privateKey);
        }

        @Override
        public KeyInfo getKeyInfo(Message mess, Node messageBody, KeyInfoFactory keyInfoFactory) throws Exception {
            return null;
        }
    };
    return accessor;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:XmlSignatureTest.java

示例6: getKeyAccessor

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
static KeyAccessor getKeyAccessor(final Key key) {
    KeyAccessor accessor = new KeyAccessor() {

        @Override
        public KeySelector getKeySelector(Message message) throws Exception {
            return KeySelector.singletonKeySelector(key);
        }

        @Override
        public KeyInfo getKeyInfo(Message mess, Node messageBody, KeyInfoFactory keyInfoFactory) throws Exception {
            return null;
        }
    };
    return accessor;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:SignatureAlgorithmTest.java

示例7: getDsaKeySelector

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
public static KeySelector getDsaKeySelector() {
    return KeySelector.singletonKeySelector(getKeyPair("DSA", 1024).getPublic());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:SpringXmlSignatureTest.java

示例8: getRsaKeySelector

import javax.xml.crypto.KeySelector; //导入方法依赖的package包/类
public static KeySelector getRsaKeySelector() {
    return KeySelector.singletonKeySelector(rsaPair.getPublic());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:SpringXmlSignatureTest.java


注:本文中的javax.xml.crypto.KeySelector.singletonKeySelector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。