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


Java MarshallingException类代码示例

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


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

示例1: setSignature

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
/**
 * Applies the XML Digital Signature to the SAML 2.0 based Request.
 *
 * @param request            the SAML 2.0 based Request
 * @param signatureAlgorithm the algorithm used to compute the signature
 * @param credential         the signature signing credential
 * @return the SAML 2.0 based Request with XML Digital Signature set
 * @throws SSOException if an error occurs while signing the SAML 2.0 based Request message
 */
public static RequestAbstractType setSignature(RequestAbstractType request, String signatureAlgorithm,
                                               X509Credential credential) throws SSOException {
    try {
        Signature signature = setSignatureRaw(signatureAlgorithm, credential);
        request.setSignature(signature);

        List<Signature> signatureList = new ArrayList<>();
        signatureList.add(signature);

        //  marshall and sign
        Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(request);
        if (marshaller != null) {
            marshaller.marshall(request);
        }

        //  initializes and configures the library
        Init.init();
        //  signer is responsible for creating the digital signatures for the given XML Objects,
        //  signs the XML Objects based on the given order of the Signature list
        Signer.signObjects(signatureList);
        return request;
    } catch (MarshallingException | SignatureException e) {
        throw new SSOException("Error while signing the SAML 2.0 Request message", e);
    }
}
 
开发者ID:wso2-extensions,项目名称:tomcat-extension-samlsso,代码行数:35,代码来源:SSOUtils.java

示例2: generateErrorResponseFromHub_shouldAddExternalCommunicationEvent

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
@Test
public void generateErrorResponseFromHub_shouldAddExternalCommunicationEvent() throws MarshallingException, SignatureException {
    SessionId sessionId = SessionId.createNewSessionId();
    String responseId = UUID.randomUUID().toString();

    when(sessionProxy.getErrorResponseFromHub(sessionId)).thenReturn(new AuthnResponseFromHubContainerDto(samlRequest, postEndPoint, relayState, responseId));
    Response samlResponse = setUpErrorResponseFromHub(sessionId, responseId);
    when(responseTransformer.apply(samlRequest)).thenReturn(samlResponse);

    SamlMessage samlMessage = samlMessageSenderHandler.generateErrorResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
    assertThat(samlMessage.getSamlMessage()).isEqualTo(samlRequest);
    assertThat(samlMessage.getPostEndpoint()).isEqualTo(postEndPoint.toString());
    assertThat(samlMessage.getRegistration().isPresent()).isFalse();
    assertThat(samlMessage.getSamlMessageType()).isEqualTo(SamlMessageType.SAML_RESPONSE);
    assertThat(samlMessage.getRelayState().isPresent()).isTrue();
    assertThat(samlMessage.getRelayState()).isEqualTo(relayState);

    verify(externalCommunicationEventLogger).logResponseFromHub(responseId, sessionId, postEndPoint, principalIpAddressAsSeenByHub);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:SamlMessageSenderHandlerTest.java

示例3: shouldFormatAuthnSuccessResponse

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
@Test
public void shouldFormatAuthnSuccessResponse() throws IOException, URISyntaxException, MarshallingException, SignatureException {
    Response response = aResponse().build();

    String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(response, Direction.INBOUND, true);

    String expectedLogMessage = "Protective Monitoring – Authn Response Event – " +
            "{responseId: default-response-id, " +
            "inResponseTo: default-request-id, " +
            "direction: INBOUND, " +
            "destination: http://destination.com, " +
            "issuerId: a-test-entity, " +
            "validSignature: true, " +
            "status: urn:oasis:names:tc:SAML:2.0:status:Success, " +
            "subStatus: , " +
            "statusDetails: []}";
    assertThat(logString).isEqualTo(expectedLogMessage);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:19,代码来源:ProtectiveMonitoringLogFormatterTest.java

示例4: build

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
public AuthnRequest build(LevelOfAssurance levelOfAssurance, String serviceEntityId) {
    AuthnRequest authnRequest = new AuthnRequestBuilder().buildObject();
    authnRequest.setID(String.format("_%s", UUID.randomUUID()));
    authnRequest.setIssueInstant(DateTime.now());
    authnRequest.setForceAuthn(false);
    authnRequest.setDestination(destination.toString());
    authnRequest.setExtensions(createExtensions());

    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue(serviceEntityId);
    authnRequest.setIssuer(issuer);

    authnRequest.setSignature(createSignature());

    try {
        XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(authnRequest).marshall(authnRequest);
        Signer.signObject(authnRequest.getSignature());
    } catch (SignatureException | MarshallingException e) {
        throw new SAMLRuntimeException("Unknown problem while signing SAML object", e);
    }

    return authnRequest;
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:24,代码来源:AuthnRequestFactory.java

示例5: badHubEntityDescriptor

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
private EntityDescriptor badHubEntityDescriptor() {
    X509Certificate x509CertificateOne = X509CertificateBuilder.aX509Certificate().withCert(TestCertificateStrings.UNCHAINED_PUBLIC_CERT).build();
    X509Data x509DataOne = X509DataBuilder.aX509Data().withX509Certificate(x509CertificateOne).build();
    KeyInfo signingOne = KeyInfoBuilder.aKeyInfo().withKeyName("signing_one").withX509Data(x509DataOne).build();
    KeyDescriptor keyDescriptorOne = KeyDescriptorBuilder.aKeyDescriptor().withKeyInfo(signingOne).build();
    SPSSODescriptor spssoDescriptor = SPSSODescriptorBuilder.anSpServiceDescriptor()
            .addKeyDescriptor(keyDescriptorOne)
            .withoutDefaultSigningKey()
            .withoutDefaultEncryptionKey().build();
    try {
        return EntityDescriptorBuilder.anEntityDescriptor()
                .withEntityId(HUB_ENTITY_ID)
                .addSpServiceDescriptor(spssoDescriptor)
                .withIdpSsoDescriptor(null)
                .withValidUntil(DateTime.now().plusHours(1))
                .withSignature(null)
                .withoutSigning()
                .build();
    } catch (MarshallingException | SignatureException e) {
        throw propagate(e);
    }
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:23,代码来源:MatchingServiceAdapterFailingMetadataAppRuleTest.java

示例6: marshall

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
/**
 * Serializes the specified SAML 2.0 based XML content representation to its corresponding actual XML syntax
 * representation.
 *
 * @param xmlObject the SAML 2.0 based XML content object
 * @return a {@link String} representation of the actual XML representation of the SAML 2.0 based XML content
 * representation
 * @throws SSOException if an error occurs during the marshalling process
 */
public static String marshall(XMLObject xmlObject) throws SSOException {
    try {
        Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(xmlObject);
        Element element = null;
        if (marshaller != null) {
            element = marshaller.marshall(xmlObject);
        }
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS implementation = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = implementation.createLSSerializer();
        LSOutput output = implementation.createLSOutput();
        output.setByteStream(byteArrayOutputStream);
        writer.write(element, output);
        return new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);
    } catch (ClassNotFoundException | InstantiationException | MarshallingException | IllegalAccessException e) {
        throw new SSOException("Error in marshalling SAML 2.0 Assertion", e);
    }
}
 
开发者ID:wso2-extensions,项目名称:tomcat-extension-samlsso,代码行数:29,代码来源:SSOUtils.java

示例7: createCountryEntityDescriptor

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
public static EntityDescriptor createCountryEntityDescriptor(String entityID) {
    Signature entityDescriptorSignature = createSignature();
    KeyDescriptor keyDescriptor = KeyDescriptorBuilder.aKeyDescriptor().withX509ForSigning(TEST_PUBLIC_CERT).build();
    IDPSSODescriptor idpssoDescriptor = IdpSsoDescriptorBuilder
            .anIdpSsoDescriptor()
            .addKeyDescriptor(keyDescriptor)
            .build();
    try {
        return getEntityDescriptor(entityID, idpssoDescriptor, entityDescriptorSignature);
    } catch (MarshallingException | SignatureException e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:14,代码来源:NodeMetadataFactory.java

示例8: getEntityDescriptor

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
private static EntityDescriptor getEntityDescriptor(String entityID, IDPSSODescriptor idpssoDescriptor, Signature entityDescriptorSignature) throws MarshallingException, SignatureException {
    return EntityDescriptorBuilder
            .anEntityDescriptor()
            .withEntityId(entityID)
            .withIdpSsoDescriptor(idpssoDescriptor)
            .withSignature(entityDescriptorSignature)
            .build();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:9,代码来源:NodeMetadataFactory.java

示例9: generateAuthRequestFromHub_shouldThrowSamlTransformationException

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
@Test(expected = SamlTransformationErrorException.class)
public void generateAuthRequestFromHub_shouldThrowSamlTransformationException() throws MarshallingException, SignatureException {
    SessionId sessionId = SessionId.createNewSessionId();
    String expectedSamlMessageId = UUID.randomUUID().toString();
    when(sessionProxy.getAuthnRequestFromHub(sessionId)).thenReturn(new AuthnRequestFromHubContainerDto(samlRequest, postEndPoint, true));
    AuthnRequest authnRequest = anAuthnRequest().withId(expectedSamlMessageId).build();
    when(authnRequestTransformer.apply(samlRequest)).thenReturn(authnRequest);
    when(samlMessageSignatureValidator.validate(authnRequest, SPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(SamlValidationResponse.anInvalidResponse(new SamlValidationSpecification("bad", true)));

    samlMessageSenderHandler.generateAuthnRequestFromHub(sessionId, principalIpAddressAsSeenByHub);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:12,代码来源:SamlMessageSenderHandlerTest.java

示例10: generateAuthResponseFromHub_shouldThrowSamlTransformationException

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
@Test(expected = SamlTransformationErrorException.class)
public void generateAuthResponseFromHub_shouldThrowSamlTransformationException() throws MarshallingException, SignatureException {
    SessionId sessionId = SessionId.createNewSessionId();
    String expectedSamlMessageId = UUID.randomUUID().toString();
    Response openSamlResponse = setUpAuthnResponseFromHub(sessionId, expectedSamlMessageId);

    when(samlMessageSignatureValidator.validate(openSamlResponse, SPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(SamlValidationResponse.anInvalidResponse(new SamlValidationSpecification("bad", true)));

    samlMessageSenderHandler.generateAuthnResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:11,代码来源:SamlMessageSenderHandlerTest.java

示例11: generateErrorResponseFromHub_shouldThrowSamlTransformationException

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
@Test(expected = SamlTransformationErrorException.class)
public void generateErrorResponseFromHub_shouldThrowSamlTransformationException() throws MarshallingException, SignatureException {
    SessionId sessionId = SessionId.createNewSessionId();
    String expectedSamlMessageId = UUID.randomUUID().toString();
    Response openSamlResponse = setUpErrorResponseFromHub(sessionId, expectedSamlMessageId);
    when(samlMessageSignatureValidator.validate(openSamlResponse, SPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(SamlValidationResponse.anInvalidResponse(new SamlValidationSpecification("bad", true)));

    samlMessageSenderHandler.generateErrorResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:10,代码来源:SamlMessageSenderHandlerTest.java

示例12: setUpAuthnResponseFromHub

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
private Response setUpAuthnResponseFromHub(SessionId sessionId, String expectedSamlMessageId) throws MarshallingException, SignatureException {
    AuthnResponseFromHubContainerDto hubContainerDto = new AuthnResponseFromHubContainerDto(samlRequest, postEndPoint, relayState, expectedSamlMessageId);
    when(sessionProxy.getAuthnResponseFromHub(sessionId)).thenReturn(hubContainerDto);
    Response openSamlResponse = aResponse().withId(expectedSamlMessageId).build();
    when(responseTransformer.apply(anyString())).thenReturn(openSamlResponse);
    return openSamlResponse;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:8,代码来源:SamlMessageSenderHandlerTest.java

示例13: setUpErrorResponseFromHub

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
private Response setUpErrorResponseFromHub(SessionId sessionId, String expectedSamlMessageId) throws MarshallingException, SignatureException {
    AuthnResponseFromHubContainerDto hubContainerDto = new AuthnResponseFromHubContainerDto(samlRequest, postEndPoint, relayState, expectedSamlMessageId);
    when(sessionProxy.getErrorResponseFromHub(sessionId)).thenReturn(hubContainerDto);
    Response openSamlResponse = aResponse().withId(expectedSamlMessageId).build();
    when(responseTransformer.apply(anyString())).thenReturn(openSamlResponse);
    return openSamlResponse;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:8,代码来源:SamlMessageSenderHandlerTest.java

示例14: setUp

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
@Before
public void setUp() throws MarshallingException, SignatureException {
    samlMessageReceiverApi = new SamlMessageReceiverApi(
            relayStateValidator,
            stringSamlAuthnRequestTransformer,
            stringSamlResponseTransformer,
            samlMessageSignatureValidator,
            samlMessageSignatureValidator,
            Optional.of(samlMessageSignatureValidator),
            protectiveMonitoringLogger,
            sessionProxy);
    validSamlResponse = aValidIdpResponse().build();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:14,代码来源:SamlMessageReceiverApiTest.java

示例15: handleResponsePost_shouldReturnActionDtoOnSuccessfulRegistration

import org.opensaml.core.xml.io.MarshallingException; //导入依赖的package包/类
@Test
public void handleResponsePost_shouldReturnActionDtoOnSuccessfulRegistration() throws MarshallingException, SignatureException {
    ResponseActionDto responseActionDto = ResponseActionDto.success(SESSION_ID, true, LevelOfAssurance.LEVEL_2);
    when(stringSamlResponseTransformer.apply(SAML_REQUEST)).thenReturn(validSamlResponse);
    when(samlMessageSignatureValidator.validate(any(org.opensaml.saml.saml2.core.Response.class), any(QName.class))).thenReturn(SamlValidationResponse.aValidResponse());
    when(sessionProxy.receiveAuthnResponseFromIdp(any(SamlAuthnResponseContainerDto.class), eq(SESSION_ID))).thenReturn(responseActionDto);

    Response response = samlMessageReceiverApi.handleResponsePost(SAML_REQUEST_DTO);

    assertThat(response.getStatus()).isEqualTo(Status.OK.getStatusCode());
    assertThat(response.getEntity()).isEqualTo(responseActionDto);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:13,代码来源:SamlMessageReceiverApiTest.java


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