Search in sources :

Example 1 with OIDCMetaData

use of org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData in project product-is by wso2.

the class ApplicationMetadataPositiveTest method init.

@BeforeClass(alwaysRun = true)
public void init() throws IOException {
    super.testInit(API_VERSION, swaggerDefinition, tenant);
    // Init getAllEmailTemplateTypes method response
    ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
    String expectedResponse = readResource("all-inbound-protocols-response.json");
    allInboundProtocolsResponse = Arrays.asList(jsonWriter.readValue(expectedResponse, AuthProtocolMetadata[].class));
    // Init OIDC Metadata
    expectedResponse = readResource("oidc-metadata.json");
    oidcMetaData = jsonWriter.readValue(expectedResponse, OIDCMetaData.class);
    // Init SAML Metadata
    expectedResponse = readResource("saml-metadata-super-tenant.json");
    samlMetaDataSuperTenant = jsonWriter.readValue(expectedResponse, SAMLMetaData.class);
    expectedResponse = readResource("saml-metadata-tenant.json");
    samlMetaDataTenant = jsonWriter.readValue(expectedResponse, SAMLMetaData.class);
    // Init WS Trust Metadata
    expectedResponse = readResource("ws-trust-metadata-super-tenant.json");
    wsTrustMetaDataSuperTenant = jsonWriter.readValue(expectedResponse, WSTrustMetaData.class);
    expectedResponse = readResource("ws-trust-metadata-tenant.json");
    wsTrustMetaDataTenant = jsonWriter.readValue(expectedResponse, WSTrustMetaData.class);
}
Also used : AuthProtocolMetadata(org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AuthProtocolMetadata) OIDCMetaData(org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OIDCMetaData) SAMLMetaData(org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAMLMetaData) JsonFactory(com.fasterxml.jackson.core.JsonFactory) WSTrustMetaData(org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.WSTrustMetaData) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with OIDCMetaData

use of org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData in project product-is by wso2.

the class ApplicationMetadataPositiveTest method testGetOIDCMetadata.

@Test
public void testGetOIDCMetadata() throws IOException {
    Response response = getResponseOfGet(METADATA_API_BASE_PATH + PATH_SEPARATOR + INBOUND_PROTOCOLS_PATH + PATH_SEPARATOR + OIDC_PATH);
    response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK);
    ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
    OIDCMetaData responseFound = jsonWriter.readValue(response.asString(), OIDCMetaData.class);
    Assert.assertEquals(sortScopeValidators(responseFound), oidcMetaData, "OIDC Metadata returned from the API doesn't match.");
}
Also used : Response(io.restassured.response.Response) OIDCMetaData(org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OIDCMetaData) JsonFactory(com.fasterxml.jackson.core.JsonFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 3 with OIDCMetaData

use of org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData in project identity-api-server by wso2.

the class ServerApplicationMetadataService method getOIDCMetadata.

/**
 * Pull OAuth/OIDC Metadata from OAuthAdminServiceImpl and return.
 *
 * @return Populated OIDCMetadata object.
 */
public OIDCMetaData getOIDCMetadata() {
    OIDCMetaData oidcMetaData = new OIDCMetaData();
    OAuthAdminServiceImpl oAuthAdminService = ApplicationManagementServiceHolder.getOAuthAdminService();
    List<String> supportedGrantTypes = new LinkedList<>(Arrays.asList(oAuthAdminService.getAllowedGrantTypes()));
    List<GrantType> supportedGrantTypeNames = new ArrayList<>();
    // Iterate through the standard grant type names and add matching elements.
    for (String supportedGrantTypeName : supportedGrantTypes) {
        GrantType grantType = new GrantType();
        if (getOAuthGrantTypeNames().keySet().contains(supportedGrantTypeName)) {
            grantType.setName(supportedGrantTypeName);
            grantType.setDisplayName(getOAuthGrantTypeNames().get(supportedGrantTypeName));
        } else {
            grantType.setName(supportedGrantTypeName);
            grantType.setDisplayName(supportedGrantTypeName);
        }
        supportedGrantTypeNames.add(grantType);
    }
    // Set extracted grant types.
    oidcMetaData.setAllowedGrantTypes(new GrantTypeMetaData().options(supportedGrantTypeNames));
    oidcMetaData.setDefaultUserAccessTokenExpiryTime(String.valueOf(oAuthAdminService.getTokenExpiryTimes().getUserAccessTokenExpiryTime()));
    oidcMetaData.defaultApplicationAccessTokenExpiryTime(String.valueOf(oAuthAdminService.getTokenExpiryTimes().getApplicationAccessTokenExpiryTime()));
    oidcMetaData.defaultRefreshTokenExpiryTime(String.valueOf(oAuthAdminService.getTokenExpiryTimes().getRefreshTokenExpiryTime()));
    oidcMetaData.defaultIdTokenExpiryTime(String.valueOf(oAuthAdminService.getTokenExpiryTimes().getIdTokenExpiryTime()));
    OAuthIDTokenAlgorithmDTO idTokenAlgorithmDTO = oAuthAdminService.getSupportedIDTokenAlgorithms();
    oidcMetaData.setIdTokenEncryptionAlgorithm(new MetadataProperty().defaultValue(idTokenAlgorithmDTO.getDefaultIdTokenEncryptionAlgorithm()).options(idTokenAlgorithmDTO.getSupportedIdTokenEncryptionAlgorithms()));
    oidcMetaData.idTokenEncryptionMethod(new MetadataProperty().defaultValue(idTokenAlgorithmDTO.getDefaultIdTokenEncryptionMethod()).options(idTokenAlgorithmDTO.getSupportedIdTokenEncryptionMethods()));
    oidcMetaData.setScopeValidators(new MetadataProperty().defaultValue(null).options(Arrays.asList(oAuthAdminService.getAllowedScopeValidators())));
    oidcMetaData.accessTokenType(new MetadataProperty().defaultValue(oAuthAdminService.getDefaultTokenType()).options(oAuthAdminService.getSupportedTokenTypes()));
    List<TokenBindingMetaDataDTO> supportedTokenBindings = oAuthAdminService.getSupportedTokenBindingsMetaData();
    List<String> supportedTokenBindingTypes = new ArrayList<>();
    supportedTokenBindingTypes.add("None");
    for (TokenBindingMetaDataDTO tokenBindingDTO : supportedTokenBindings) {
        supportedTokenBindingTypes.add(tokenBindingDTO.getTokenBindingType());
    }
    oidcMetaData.setAccessTokenBindingType(new MetadataProperty().defaultValue("None").options(supportedTokenBindingTypes));
    return oidcMetaData;
}
Also used : OAuthIDTokenAlgorithmDTO(org.wso2.carbon.identity.oauth.dto.OAuthIDTokenAlgorithmDTO) OIDCMetaData(org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData) OAuthAdminServiceImpl(org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl) ArrayList(java.util.ArrayList) GrantType(org.wso2.carbon.identity.api.server.application.management.v1.GrantType) LinkedList(java.util.LinkedList) GrantTypeMetaData(org.wso2.carbon.identity.api.server.application.management.v1.GrantTypeMetaData) TokenBindingMetaDataDTO(org.wso2.carbon.identity.oauth.dto.TokenBindingMetaDataDTO) MetadataProperty(org.wso2.carbon.identity.api.server.application.management.v1.MetadataProperty)

Aggregations

JsonFactory (com.fasterxml.jackson.core.JsonFactory)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 OIDCMetaData (org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OIDCMetaData)2 Response (io.restassured.response.Response)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 BeforeClass (org.testng.annotations.BeforeClass)1 Test (org.testng.annotations.Test)1 GrantType (org.wso2.carbon.identity.api.server.application.management.v1.GrantType)1 GrantTypeMetaData (org.wso2.carbon.identity.api.server.application.management.v1.GrantTypeMetaData)1 MetadataProperty (org.wso2.carbon.identity.api.server.application.management.v1.MetadataProperty)1 OIDCMetaData (org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData)1 OAuthAdminServiceImpl (org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl)1 OAuthIDTokenAlgorithmDTO (org.wso2.carbon.identity.oauth.dto.OAuthIDTokenAlgorithmDTO)1 TokenBindingMetaDataDTO (org.wso2.carbon.identity.oauth.dto.TokenBindingMetaDataDTO)1 AuthProtocolMetadata (org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AuthProtocolMetadata)1 SAMLMetaData (org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAMLMetaData)1 WSTrustMetaData (org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.WSTrustMetaData)1