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


Java Configuration.getBuilderFactory方法代码示例

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


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

示例1: buildRSAKeyValue

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Builds an {@link RSAKeyValue} XMLObject from the Java security RSA public key type.
 * 
 * @param rsaPubKey a native Java {@link RSAPublicKey}
 * @return an {@link RSAKeyValue} XMLObject
 */
public static RSAKeyValue buildRSAKeyValue(RSAPublicKey rsaPubKey) {
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
    RSAKeyValue rsaKeyValue = (RSAKeyValue) builderFactory
        .getBuilder(RSAKeyValue.DEFAULT_ELEMENT_NAME)
        .buildObject(RSAKeyValue.DEFAULT_ELEMENT_NAME);
    Modulus modulus = (Modulus) builderFactory
        .getBuilder(Modulus.DEFAULT_ELEMENT_NAME)
        .buildObject(Modulus.DEFAULT_ELEMENT_NAME);
    Exponent exponent = (Exponent) builderFactory
        .getBuilder(Exponent.DEFAULT_ELEMENT_NAME)
        .buildObject(Exponent.DEFAULT_ELEMENT_NAME);
    
    modulus.setValueBigInt(rsaPubKey.getModulus());
    rsaKeyValue.setModulus(modulus);
    
    exponent.setValueBigInt(rsaPubKey.getPublicExponent());
    rsaKeyValue.setExponent(exponent);
    
    return rsaKeyValue;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:KeyInfoHelper.java

示例2: buildDSAKeyValue

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Builds a {@link DSAKeyValue} XMLObject from the Java security DSA public key type.
 * 
 * @param dsaPubKey a native Java {@link DSAPublicKey}
 * @return an {@link DSAKeyValue} XMLObject
 */
public static DSAKeyValue buildDSAKeyValue(DSAPublicKey dsaPubKey) {
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
    DSAKeyValue dsaKeyValue = (DSAKeyValue) builderFactory
        .getBuilder(DSAKeyValue.DEFAULT_ELEMENT_NAME)
        .buildObject(DSAKeyValue.DEFAULT_ELEMENT_NAME);
    Y y = (Y) builderFactory.getBuilder(Y.DEFAULT_ELEMENT_NAME).buildObject(Y.DEFAULT_ELEMENT_NAME);
    G g = (G) builderFactory.getBuilder(G.DEFAULT_ELEMENT_NAME).buildObject(G.DEFAULT_ELEMENT_NAME);
    P p = (P) builderFactory.getBuilder(P.DEFAULT_ELEMENT_NAME).buildObject(P.DEFAULT_ELEMENT_NAME);
    Q q = (Q) builderFactory.getBuilder(Q.DEFAULT_ELEMENT_NAME).buildObject(Q.DEFAULT_ELEMENT_NAME);
    
    y.setValueBigInt(dsaPubKey.getY());
    dsaKeyValue.setY(y);
    
    g.setValueBigInt(dsaPubKey.getParams().getG());
    dsaKeyValue.setG(g);
    
    p.setValueBigInt(dsaPubKey.getParams().getP());
    dsaKeyValue.setP(p);
    
    q.setValueBigInt(dsaPubKey.getParams().getQ());
    dsaKeyValue.setQ(q);
    
    return dsaKeyValue;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:KeyInfoHelper.java

示例3: Encrypter

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 */
public Encrypter() {
    UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
    encryptedDataUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedData.DEFAULT_ELEMENT_NAME);
    encryptedKeyUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedKey.DEFAULT_ELEMENT_NAME);

    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
    keyInfoBuilder = (XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);

    jcaProviderName = null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:Encrypter.java

示例4: SOAP11Encoder

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/** Constructor. */
@SuppressWarnings("unchecked")
public SOAP11Encoder() {
    super();
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
    envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
    bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SOAP11Encoder.java

示例5: HandlerChainAwareHTTPSOAP11Encoder

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/** Constructor. */
public HandlerChainAwareHTTPSOAP11Encoder() {
    super();
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
    envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
    bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:HandlerChainAwareHTTPSOAP11Encoder.java

示例6: createSamlObject

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Utility method for creating an OpenSAML object given its element name.
 * 
 * @param clazz
 *          the class to create
 * @param elementName
 *          the element name for the XML object to create
 * @return the XML object
 */
public static <T extends XMLObject> T createSamlObject(Class<T> clazz, QName elementName) {
  if (!XMLObject.class.isAssignableFrom(clazz)) {
    throw new RuntimeException(String.format("%s is not a XMLObject class", clazz.getName()));
  }
  XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
  XMLObjectBuilder<?> builder = builderFactory.getBuilder(elementName);
  if (builder == null) {
    // No builder registered for the given element name. Try creating a builder for the default element name.
    builder = builderFactory.getBuilder(getDefaultElementName(clazz));
  }
  Object object = builder.buildObject(elementName);
  return clazz.cast(object);
}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:23,代码来源:OpenSAMLTestBase.java

示例7: testMarshallAndUnmarshallStructured

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Tests marshalling and unmarshalling of {@code CurrentAddressStructuredType}.
 * 
 * @throws Exception
 *           for errors
 */
@Test
public void testMarshallAndUnmarshallStructured() throws Exception {

  XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();

  Object object = builderFactory.getBuilder(CurrentAddressStructuredType.TYPE_NAME).buildObject(CurrentAddressStructuredType.TYPE_NAME
    .getNamespaceURI(), CurrentAddressStructuredType.TYPE_NAME.getLocalPart(), "eidas");
  CurrentAddressStructuredType address = CurrentAddressStructuredType.class.cast(object);

  fill(address);

  // Marshall
  Element element = OpenSAMLTestBase.marshall(address);
  Assert.assertNotNull(element);

  // Unmarshall element
  CurrentAddressStructuredType address2 = OpenSAMLTestBase.unmarshall(element, CurrentAddressStructuredType.class);

  verify(address, address2);

  // Test unmarshall again
  String xml = XMLHelper.prettyPrintXML(element);
  Document doc = Configuration.getParserPool().parse(new ByteArrayInputStream(xml.toString().getBytes("UTF-8")));

  CurrentAddressStructuredType address3 = OpenSAMLTestBase.unmarshall(doc.getDocumentElement(), CurrentAddressStructuredType.class);
  verify(address, address3);
}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:34,代码来源:CurrentAddressTypeTest.java

示例8: testMarshallAndUnmarshall

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Tests marshalling and unmarshalling of {@code CurrentAddressType}.
 * 
 * @throws Exception
 *           for errors
 */
@Test
public void testMarshallAndUnmarshall() throws Exception {

  XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();

  Object object = builderFactory.getBuilder(CurrentAddressType.TYPE_NAME).buildObject(CurrentAddressType.TYPE_NAME.getNamespaceURI(),
    CurrentAddressType.TYPE_NAME.getLocalPart(), "eidas");
  CurrentAddressType address = CurrentAddressType.class.cast(object);

  fill(address);

  // Marshall
  Element element = OpenSAMLTestBase.marshall(address);
  Assert.assertNotNull(element);

  // Verify that we got one child element that is the Base64 encoding.
  NodeList childs = element.getChildNodes();
  Assert.assertEquals(1, childs.getLength());
  String base64 = childs.item(0).getNodeValue();
  byte[] bytes = Base64.decode(base64);
  Assert.assertTrue((new String(bytes)).startsWith("<eidas:"));

  // Unmarshall element
  CurrentAddressType address2 = OpenSAMLTestBase.unmarshall(element, CurrentAddressType.class);

  verify(address, address2);
  
  String swedishEidString = address2.toSwedishEidString();
  Assert.assertEquals("LocatorDesignator=6%20tr;LocatorName=10;Thoroughfare=Korta%20gatan;PostName=Solna;PostCode=19174", swedishEidString);    

  // Test unmarshall again
  String xml = XMLHelper.prettyPrintXML(element);
  Document doc = Configuration.getParserPool().parse(new ByteArrayInputStream(xml.toString().getBytes("UTF-8")));

  CurrentAddressType address3 = OpenSAMLTestBase.unmarshall(doc.getDocumentElement(), CurrentAddressType.class);
  verify(address, address3);

}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:45,代码来源:CurrentAddressTypeTest.java

示例9: getMetadata

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Gets the metadata from every registered provider and places each within a newly created EntitiesDescriptor.
 * 
 * {@inheritDoc}
 */
public XMLObject getMetadata() throws MetadataProviderException {
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
    SAMLObjectBuilder<EntitiesDescriptor> builder = (SAMLObjectBuilder<EntitiesDescriptor>) builderFactory
            .getBuilder(EntitiesDescriptor.DEFAULT_ELEMENT_NAME);
    EntitiesDescriptor metadataRoot = builder.buildObject();

    Lock readLock = providerLock.readLock();
    readLock.lock();

    XMLObject providerMetadata;
    try {
        for (MetadataProvider provider : providers) {
            providerMetadata = provider.getMetadata();
            if (providerMetadata instanceof EntitiesDescriptor) {
                metadataRoot.getEntitiesDescriptors().add((EntitiesDescriptor) providerMetadata);
            } else if (providerMetadata instanceof EntityDescriptor) {
                metadataRoot.getEntityDescriptors().add((EntityDescriptor) providerMetadata);
            }
        }
    } catch (MetadataProviderException e) {
        throw e;
    } finally {
        readLock.unlock();
    }

    return metadataRoot;
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:33,代码来源:ChainingMetadataProvider.java

示例10: generateSOAPEnvelope

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 *
 * @param artifactResolutionRequest
 * @return
 */
protected Envelope generateSOAPEnvelope(ArtifactResolve artifactResolutionRequest) {
    XMLObjectBuilderFactory xmlObjectBuilderFactory = Configuration.getBuilderFactory();
    Envelope envelope = (Envelope) xmlObjectBuilderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME).buildObject(Envelope.DEFAULT_ELEMENT_NAME);
    Body body = (Body) xmlObjectBuilderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME).buildObject(Body.DEFAULT_ELEMENT_NAME);

    body.getUnknownXMLObjects().add(artifactResolutionRequest);
    envelope.setBody(body);

    return envelope;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:16,代码来源:ArtifactBindingHelper.java

示例11: buildSOAP11Fault

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Build a SOAP 1.1. Fault element.
 * 
 * @param faultCode the 'faultcode' QName (required)
 * @param faultString the 'faultstring' value (required)
 * @param faultActor the 'faultactor' value (may be null)
 * @param detailChildren the 'detail' child elements
 * @param detailAttributes the 'detail' element attributes
 * @return the new Fault element object
 */
public static Fault buildSOAP11Fault(QName faultCode, String faultString, String faultActor,
        List<XMLObject> detailChildren, Map<QName, String> detailAttributes) {
    if (faultCode == null) {
        throw new IllegalArgumentException("Argument for 'faultcode' may not be null");
    }
    if (faultString == null) {
        throw new IllegalArgumentException("Argument for 'faultstring' may not be null");
    }
    
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); 
    
    Fault faultObj =  (Fault) builderFactory.getBuilder(Fault.DEFAULT_ELEMENT_NAME)
        .buildObject(Fault.DEFAULT_ELEMENT_NAME);
    FaultCode faultCodeObj =  (FaultCode) builderFactory.getBuilder(FaultCode.DEFAULT_ELEMENT_NAME)
        .buildObject(FaultCode.DEFAULT_ELEMENT_NAME);
    FaultString faultStringObj =  (FaultString) builderFactory.getBuilder(FaultString.DEFAULT_ELEMENT_NAME)
        .buildObject(FaultString.DEFAULT_ELEMENT_NAME);
    
    faultCodeObj.setValue(faultCode);
    faultObj.setCode(faultCodeObj);
    
    faultStringObj.setValue(faultString);
    faultObj.setMessage(faultStringObj);
    
    if (faultActor != null) {
        FaultActor faultActorObj =  (FaultActor) builderFactory.getBuilder(FaultActor.DEFAULT_ELEMENT_NAME)
            .buildObject(FaultActor.DEFAULT_ELEMENT_NAME);
        faultActorObj.setValue(faultActor);
        faultObj.setActor(faultActorObj);
    }
        
    Detail detailObj = null;
    if (detailChildren != null && !detailChildren.isEmpty()) {
        detailObj = (Detail) builderFactory.getBuilder(Detail.DEFAULT_ELEMENT_NAME)
            .buildObject(Detail.DEFAULT_ELEMENT_NAME);
        for (XMLObject xo : detailChildren) {
            if (xo != null) {
                detailObj.getUnknownXMLObjects().add(xo);
            }
        }
    }
    if (detailAttributes != null && !detailAttributes.isEmpty()) {
        if (detailObj == null) {
            detailObj = (Detail) builderFactory.getBuilder(Detail.DEFAULT_ELEMENT_NAME)
                .buildObject(Detail.DEFAULT_ELEMENT_NAME);
        }
        for (Entry<QName,String> entry : detailAttributes.entrySet()) {
            if (entry.getKey() != null && entry.getValue() != null) {
                detailObj.getUnknownAttributes().put(entry.getKey(), entry.getValue());
            }
        }
    }
    if (detailObj != null && 
            (!detailObj.getUnknownXMLObjects().isEmpty() || !detailObj.getUnknownAttributes().isEmpty())) {
        faultObj.setDetail(detailObj);
    }
    
    return faultObj;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:70,代码来源:SOAPHelper.java

示例12: AbstractXMLObjectUnmarshaller

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
/**
 * Constructor.
 */
protected AbstractXMLObjectUnmarshaller() {
    xmlObjectBuilderFactory = Configuration.getBuilderFactory();
    unmarshallerFactory = Configuration.getUnmarshallerFactory();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:AbstractXMLObjectUnmarshaller.java

示例13: createStatement

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
@Override
public void createStatement(GenericIdentityProviderData ipData, RahasData rahasData)
        throws IdentityProviderException {
    if (log.isDebugEnabled()) {
        log.debug("Begin SAML statement creation.");
    }
    attributeStmt = (AttributeStatement) buildXMLObject(AttributeStatement.DEFAULT_ELEMENT_NAME);

    Map<String, RequestedClaimData> mapClaims = ipData.getRequestedClaims();

    if (rahasData.getAppliesToAddress() != null) {
        appilesTo = rahasData.getAppliesToAddress();
    }

    Iterator<RequestedClaimData> ite = mapClaims.values().iterator();

    while (ite.hasNext()) {
        RequestedClaimData claim = ite.next();
        String uri = claim.getUri();

        int index = uri.lastIndexOf("/");
        String attrName = uri.substring(index + 1, uri.length());
        String attrNamespace = uri.substring(0, index);

        Attribute attribute = (Attribute) buildXMLObject(Attribute.DEFAULT_ELEMENT_NAME);
        attribute.setName(attrName);
        attribute.setNameFormat(attrNamespace);

        XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();

        // TODO remove this else if condition after WSO2 IS supports claim
        // types properly
        if (claim.getUri().equals(IdentityConstants.CLAIM_PPID)) {
            XSBase64BinaryBuilder ppidValueBuilder = (XSBase64BinaryBuilder) builderFactory
                    .getBuilder(XSBase64Binary.TYPE_NAME);
            XSBase64Binary ppidValue = ppidValueBuilder.buildObject(
                    AttributeValue.DEFAULT_ELEMENT_NAME, XSBase64Binary.TYPE_NAME);
            ppidValue.setValue(claim.getValue());
            attribute.getAttributeValues().add(ppidValue);
        } else {
            XSStringBuilder attributeValueBuilder = (XSStringBuilder) builderFactory
                    .getBuilder(XSString.TYPE_NAME);

            XSString stringValue = attributeValueBuilder.buildObject(
                    AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
            stringValue.setValue(claim.getValue());
            attribute.getAttributeValues().add(stringValue);
        }
        attributeStmt.getAttributes().add(attribute);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:52,代码来源:SAML2TokenBuilder.java

示例14: createStatement

import org.opensaml.xml.Configuration; //导入方法依赖的package包/类
@Override
public void createStatement(GenericIdentityProviderData ipData, RahasData rahasData)
        throws IdentityProviderException {
    if (log.isDebugEnabled()) {
        log.debug("Begin SAML statement creation.");
    }
    attributeStmt = (AttributeStatement) buildXMLObject(AttributeStatement.DEFAULT_ELEMENT_NAME);

    Subject subject = (Subject) buildXMLObject(Subject.DEFAULT_ELEMENT_NAME);
    SubjectConfirmation subjectConf =
            (SubjectConfirmation) buildXMLObject(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
    ConfirmationMethod confMethod = (ConfirmationMethod) buildXMLObject(ConfirmationMethod.DEFAULT_ELEMENT_NAME);
    confMethod.setConfirmationMethod(CONF_KEY);
    subjectConf.getConfirmationMethods().add(confMethod);
    subject.setSubjectConfirmation(subjectConf);

    attributeStmt.setSubject(subject);

    Map<String, RequestedClaimData> mapClaims = ipData.getRequestedClaims();

    if (rahasData.getAppliesToAddress() != null) {
        appilesTo = rahasData.getAppliesToAddress();
    }

    Iterator<RequestedClaimData> ite = mapClaims.values().iterator();

    while (ite.hasNext()) {
        RequestedClaimData claim = ite.next();
        String uri = claim.getUri();

        int index = uri.lastIndexOf("/");
        String attrName = uri.substring(index + 1, uri.length());
        String attrNamespace = uri.substring(0, index);

        Attribute attribute = (Attribute) buildXMLObject(Attribute.DEFAULT_ELEMENT_NAME);
        attribute.setAttributeName(attrName);
        attribute.setAttributeNamespace(attrNamespace);

        XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
        XSStringBuilder attributeValueBuilder = (XSStringBuilder) builderFactory.getBuilder(XSString.TYPE_NAME);

        XSString stringValue =
                attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
        stringValue.setValue(claim.getValue());
        attribute.getAttributeValues().add(stringValue);

        attributeStmt.getAttributes().add(attribute);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:50,代码来源:SAML1TokenBuilder.java


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