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


Java SAMLObjectBuilder类代码示例

本文整理汇总了Java中org.opensaml.common.SAMLObjectBuilder的典型用法代码示例。如果您正苦于以下问题:Java SAMLObjectBuilder类的具体用法?Java SAMLObjectBuilder怎么用?Java SAMLObjectBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: generate

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public MetadataProvider generate(final SAMLConfig configuration) throws MetadataProviderException, ResourceException  {
	SAMLObjectBuilder<EntityDescriptor> builder = (SAMLObjectBuilder<EntityDescriptor>) builderFactory.getBuilder(EntityDescriptor.DEFAULT_ELEMENT_NAME);
       EntityDescriptor descriptor = builder.buildObject();
       descriptor.setID(configuration.getIdpEntityId());
       descriptor.setEntityID(configuration.getIdpEntityId());
       descriptor.getRoleDescriptors().add(buildIDPSSODescriptor(configuration));

       MetadataMemoryProvider memoryProvider = new MetadataMemoryProvider(descriptor);
       memoryProvider.initialize();

       ExtendedMetadata extendedMetadata = new ExtendedMetadata();
   	extendedMetadata.setSigningKey(configuration.getIdpEntityId());

   	ExtendedMetadataDelegate idpMetadataProvider = new ExtendedMetadataDelegate(memoryProvider, extendedMetadata);
   	idpMetadataProvider.setMetadataRequireSignature(false);
   	idpMetadataProvider.initialize();

   	return idpMetadataProvider;
}
 
开发者ID:italia,项目名称:spid-spring,代码行数:21,代码来源:IdpMetadataGenerator.java

示例2: createAuthnRequest

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private AuthnRequest createAuthnRequest(String surl, 
                boolean fauth, boolean isp, String proto,
                      NameIDPolicy npolicy, RequestedAuthnContext actx) {

  AuthnRequest ar = ((SAMLObjectBuilder<AuthnRequest>) 
  _bf.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME)).buildObject();
  ar.setAssertionConsumerServiceURL(surl);
  ar.setForceAuthn(fauth);
  String uid = UUID.randomUUID().toString();
  
  ar.setID(uid);
  ar.setIsPassive(isp);
  ar.setIssueInstant(new DateTime());
  ar.setProtocolBinding(proto);
  ar.setVersion(SAMLVersion.VERSION_20);
  ar.setIssuer(getIssuer());
  // ar.setNameIDPolicy(npolicy);
  // ar.setRequestedAuthnContext(actx);
  
  return ar;
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:23,代码来源:SamlSecurityProvider.java

示例3: createLogoutRequest

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public LogoutRequest createLogoutRequest(Response resp) {
  LogoutRequest lr = ((SAMLObjectBuilder<LogoutRequest>) 
        _bf.getBuilder(LogoutRequest.DEFAULT_ELEMENT_NAME)).buildObject();
  String uid = UUID.randomUUID().toString();
  
  lr.setID(uid);
  lr.setIssueInstant(new DateTime());
  lr.setVersion(SAMLVersion.VERSION_20);
  lr.setIssuer(getIssuer());
  
  // Get NameID and SessionIndex from first assertion from
  // Authentication Response object
  Assertion asr = resp.getAssertions().get(0);
  NameID nid = ((SAMLObjectBuilder<NameID>) 
      _bf.getBuilder(NameID.DEFAULT_ELEMENT_NAME)).buildObject();
  nid.setValue(asr.getSubject().getNameID().getValue());
  lr.setNameID(nid);
  
  // Set session index(es)
  List<AuthnStatement> ausl = asr.getAuthnStatements();
  if (ausl != null) {
    for (AuthnStatement aus :ausl) {
      SessionIndex sindex = ((SAMLObjectBuilder<SessionIndex>) 
          _bf.getBuilder(SessionIndex.DEFAULT_ELEMENT_NAME)).buildObject();
      sindex.setSessionIndex(aus.getSessionIndex());
      lr.getSessionIndexes().add(sindex);
    }
  }
  
  return lr;
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:33,代码来源:SamlSecurityProvider.java

示例4: getSAMLBuilder

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
private static XMLObjectBuilderFactory getSAMLBuilder() throws ConfigurationException {

	if (builderFactory == null) {
	    // OpenSAML 2.3
	    DefaultBootstrap.bootstrap();
	    builderFactory = Configuration.getBuilderFactory();
	    nameIdBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(NameID.DEFAULT_ELEMENT_NAME);
	    confirmationMethodBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
	    subjectConfirmationBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
	    subjectBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Subject.DEFAULT_ELEMENT_NAME);
	    attrStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
	    audienceRestrictionnBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AudienceRestriction.DEFAULT_ELEMENT_NAME);
	    audienceBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Audience.DEFAULT_ELEMENT_NAME);
	    authStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnStatement.DEFAULT_ELEMENT_NAME);
	    authContextBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContext.DEFAULT_ELEMENT_NAME);
	    authContextClassRefBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
	    issuerBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
	    assertionBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Assertion.DEFAULT_ELEMENT_NAME);

	}

	return builderFactory;
    }
 
开发者ID:mwdb,项目名称:OA2C,代码行数:24,代码来源:LocalSamlTokenFactory.java

示例5: buildIDPSSODescriptor

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private IDPSSODescriptor buildIDPSSODescriptor(final SAMLConfig configuration) {
       SAMLObjectBuilder<IDPSSODescriptor> builder = (SAMLObjectBuilder<IDPSSODescriptor>) builderFactory.getBuilder(IDPSSODescriptor.DEFAULT_ELEMENT_NAME);
       IDPSSODescriptor idpDescriptor = builder.buildObject();
       idpDescriptor.setWantAuthnRequestsSigned(false);
       idpDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);

       idpDescriptor.getSingleSignOnServices().add(getSingleSignOnService(configuration, SAMLConstants.SAML2_REDIRECT_BINDING_URI));
       idpDescriptor.getSingleLogoutServices().add(getSingleLogoutService(configuration, SAMLConstants.SAML2_REDIRECT_BINDING_URI));

       return idpDescriptor;

   }
 
开发者ID:italia,项目名称:spid-spring,代码行数:14,代码来源:IdpMetadataGenerator.java

示例6: getSingleSignOnService

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private SingleSignOnService getSingleSignOnService(final SAMLConfig configuration, final String binding) {
	SAMLObjectBuilder<SingleSignOnService> builder = (SAMLObjectBuilder<SingleSignOnService>) builderFactory.getBuilder(SingleSignOnService.DEFAULT_ELEMENT_NAME);
	SingleSignOnService service = builder.buildObject();
	service.setBinding(binding);
	service.setLocation(configuration.getLoginUrl());

	return service;
}
 
开发者ID:italia,项目名称:spid-spring,代码行数:10,代码来源:IdpMetadataGenerator.java

示例7: getSingleLogoutService

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private SingleLogoutService getSingleLogoutService(final SAMLConfig configuration, final String binding) {
	SAMLObjectBuilder<SingleLogoutService> builder = (SAMLObjectBuilder<SingleLogoutService>) builderFactory.getBuilder(SingleLogoutService.DEFAULT_ELEMENT_NAME);
	SingleLogoutService service = builder.buildObject();
	service.setBinding(binding);
	service.setLocation(configuration.getLogoutUrl());

	return service;
}
 
开发者ID:italia,项目名称:spid-spring,代码行数:10,代码来源:IdpMetadataGenerator.java

示例8: createLogoutResponse

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private LogoutResponse createLogoutResponse(String id, 
                                    String code, String msg) {
    
  // Consume LogoutResponse
  LogoutResponse lresp = ((SAMLObjectBuilder<LogoutResponse>) 
            _bf.getBuilder(LogoutResponse.DEFAULT_ELEMENT_NAME)).
                                                          buildObject();
  String uid = UUID.randomUUID().toString();
  
  lresp.setID(uid);
  lresp.setInResponseTo(id);
  lresp.setIssueInstant(new DateTime());
  lresp.setVersion(SAMLVersion.VERSION_20);
  lresp.setIssuer(getIssuer());
  
  // Set status code
  Status status = ((SAMLObjectBuilder<Status>) _bf.getBuilder(
              Status.DEFAULT_ELEMENT_NAME)).buildObject();
  
  StatusCode scode = ((SAMLObjectBuilder<StatusCode>) _bf.getBuilder(
              StatusCode.DEFAULT_ELEMENT_NAME)).buildObject();
  scode.setValue(code);
  status.setStatusCode(scode);
  
  if (!msg.equals("")) {
    StatusMessage smsg = ((SAMLObjectBuilder<StatusMessage>) _bf.getBuilder(
                          StatusMessage.DEFAULT_ELEMENT_NAME)).buildObject();
    smsg.setMessage(msg);
    status.setStatusMessage(smsg);
  }
  
  lresp.setStatus(status);
  
  return lresp;
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:37,代码来源:SamlSecurityProvider.java

示例9: getIssuer

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
private Issuer getIssuer() {
  @SuppressWarnings("unchecked")
  Issuer issuer = ((SAMLObjectBuilder<Issuer>) _bf.
        getBuilder(Issuer.DEFAULT_ELEMENT_NAME)).buildObject();
  issuer.setValue(_sname);
  
  return issuer;
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:9,代码来源:SamlSecurityProvider.java

示例10: getMetadata

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的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

示例11: testEncoding

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testEncoding() throws Exception {
    SAMLObjectBuilder<Response> requestBuilder = (SAMLObjectBuilder<Response>) builderFactory
            .getBuilder(Response.DEFAULT_ELEMENT_NAME);
    Response samlMessage = requestBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setIssueInstant(new DateTime(0));
    samlMessage.setVersion(SAMLVersion.VERSION_11);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine,
    "/templates/saml1-post-binding.vm");

    MockHttpServletResponse response = new MockHttpServletResponse();
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, false));
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");
    
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(-608085328, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:33,代码来源:HTTPPostEncoderTest.java

示例12: testEncoding

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
/** Tests encoding a simple SAML message. */
@SuppressWarnings("unchecked")
public void testEncoding() throws Exception {
    SAMLObjectBuilder<Request> requestBuilder = (SAMLObjectBuilder<Request>) builderFactory
            .getBuilder(Request.DEFAULT_ELEMENT_NAME);
    Request request = requestBuilder.buildObject();
    request.setID("foo");
    request.setIssueInstant(new DateTime(0));
    request.setVersion(SAMLVersion.VERSION_11);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, false));
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(request);
    messageContext.setRelayState("relay");
    
    HTTPSOAP11Encoder encoder = new HTTPSOAP11Encoder();
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/xml", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals("http://www.oasis-open.org/committees/security", response.getHeader("SOAPAction"));
    assertEquals(-280457420, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:33,代码来源:HTTPSOAP11EncoderTest.java

示例13: testRequestEncoding

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testRequestEncoding() throws Exception {
    SAMLObjectBuilder<AuthnRequest> responseBuilder = (SAMLObjectBuilder<AuthnRequest>) builderFactory
            .getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
    AuthnRequest samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");

    HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine,
    "/templates/saml2-post-binding.vm");
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(-243324550, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:34,代码来源:HTTPPostEncoderTest.java

示例14: testRequestEncoding

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testRequestEncoding() throws Exception {
    SAMLObjectBuilder<AuthnRequest> responseBuilder = (SAMLObjectBuilder<AuthnRequest>) builderFactory
            .getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
    AuthnRequest samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");

    HTTPPostSimpleSignEncoder encoder = new HTTPPostSimpleSignEncoder(velocityEngine,
    "/templates/saml2-post-simplesign-binding.vm");
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(-1110321790, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:34,代码来源:HTTPPostSimpleSignEncoderTest.java

示例15: buildXMLObject

import org.opensaml.common.SAMLObjectBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
public KeyInfoConfirmationDataType buildXMLObject() {
    SAMLObjectBuilder builder = 
        (SAMLObjectBuilder) Configuration.getBuilderFactory().getBuilder(KeyInfoConfirmationDataType.TYPE_NAME);
    
    if(builder == null){
        fail("Unable to retrieve builder for object QName " + KeyInfoConfirmationDataType.TYPE_NAME);
    }
    return (KeyInfoConfirmationDataType) builder.buildObject();
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:11,代码来源:KeyInfoConfirmationDataTypeTest.java


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