Search in sources :

Example 46 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project product-is by wso2.

the class OIDCIdentityFederationTestCase method updateServiceProviderWithSAMLConfigs.

private void updateServiceProviderWithSAMLConfigs(int portOffset, String issuerName, String acsUrl, ServiceProvider serviceProvider) throws Exception {
    String attributeConsumingServiceIndex = super.createSAML2WebSSOConfiguration(portOffset, getSAMLSSOServiceProviderDTO(issuerName, acsUrl));
    Assert.assertNotNull(attributeConsumingServiceIndex, "Failed to create SAML2 Web SSO configuration for" + " issuer '" + issuerName + "'");
    InboundAuthenticationRequestConfig samlAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
    samlAuthenticationRequestConfig.setInboundAuthKey(issuerName);
    samlAuthenticationRequestConfig.setInboundAuthType(PRIMARY_IS_SP_INBOUND_AUTH_TYPE_SAMLSSO);
    org.wso2.carbon.identity.application.common.model.xsd.Property property = new org.wso2.carbon.identity.application.common.model.xsd.Property();
    property.setName("attrConsumServiceIndex");
    property.setValue(attributeConsumingServiceIndex);
    samlAuthenticationRequestConfig.setProperties(new org.wso2.carbon.identity.application.common.model.xsd.Property[] { property });
    serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { samlAuthenticationRequestConfig });
}
Also used : InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property)

Example 47 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project product-is by wso2.

the class OAuth2ServiceSAML2BearerGrantTestCase method testSAML2BearerValidSAMLAssertion.

@Test
public void testSAML2BearerValidSAMLAssertion() {
    try {
        // Get a SAML response.
        String samlResponse = getSAMLResponse();
        // Extract the assertion from SAML response.
        String samlAssersion = getSAMLAssersion(samlResponse);
        // Send the extracted SAML assertion to token endpoint in SAML2 bearer grant.
        HttpResponse httpResponse = sendSAMLAssertion(samlAssersion);
        // Extract the response value from http response.
        String responseValue = IOUtils.toString(httpResponse.getEntity().getContent());
        // If we have an access token in the response test is successful.
        Assert.assertTrue(responseValue.contains("access_token"));
    } catch (Exception e) {
        Assert.fail("SAML Bearer Grant test failed with an exception.", e);
    }
}
Also used : HttpResponse(org.apache.http.HttpResponse) TransformerException(javax.xml.transform.TransformerException) IdentitySAMLSSOConfigServiceIdentityException(org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) Test(org.testng.annotations.Test)

Example 48 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project identity-api-server by wso2.

the class ServerApplicationMetadataService method getInboundProtocols.

/**
 * Return a list of all available inbound protocols. If the customOnly parameter set to True, will return only the
 * custom protocols.
 *
 * @param customOnly Set to True to get only custom protocols. Default value: False.
 * @return The list of inbound protocols.
 */
public List<AuthProtocolMetadata> getInboundProtocols(Boolean customOnly) {
    List<AuthProtocolMetadata> authProtocolMetadataList = new ArrayList<>();
    // Add custom inbound protocols
    Map<String, AbstractInboundAuthenticatorConfig> allCustomAuthenticators = ApplicationManagementServiceHolder.getApplicationManagementService().getAllInboundAuthenticatorConfig();
    for (Map.Entry<String, AbstractInboundAuthenticatorConfig> entry : allCustomAuthenticators.entrySet()) {
        AuthProtocolMetadata protocol = new AuthProtocolMetadata().name(entry.getValue().getName()).displayName(entry.getValue().getFriendlyName());
        authProtocolMetadataList.add(protocol);
    }
    if (customOnly == null || !customOnly) {
        // Add default inbound protocols. WS-Federation (Passive) is not added because it doesn't have metadata,
        authProtocolMetadataList.add(new AuthProtocolMetadata().name("saml").displayName("SAML2 Web SSO Configuration"));
        authProtocolMetadataList.add(new AuthProtocolMetadata().name("oidc").displayName("OAuth/OpenID Connect Configuration"));
        authProtocolMetadataList.add(new AuthProtocolMetadata().name("ws-trust").displayName("WS-Trust Security Token Service Configuration"));
    }
    return authProtocolMetadataList;
}
Also used : AuthProtocolMetadata(org.wso2.carbon.identity.api.server.application.management.v1.AuthProtocolMetadata) ArrayList(java.util.ArrayList) AbstractInboundAuthenticatorConfig(org.wso2.carbon.identity.application.mgt.AbstractInboundAuthenticatorConfig) Map(java.util.Map)

Aggregations

Test (org.testng.annotations.Test)16 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)14 HttpResponse (org.apache.http.HttpResponse)11 IOException (java.io.IOException)10 RemoteException (java.rmi.RemoteException)9 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)9 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)9 IdentitySAMLSSOConfigServiceIdentityException (org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException)9 SAXException (org.xml.sax.SAXException)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 ArrayList (java.util.ArrayList)7 XPathExpressionException (javax.xml.xpath.XPathExpressionException)7 ConfigurationException (org.opensaml.xml.ConfigurationException)7 ValidationException (org.opensaml.xml.validation.ValidationException)7 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)7 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)7 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)5 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)4