Search in sources :

Example 36 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-mediation by wso2.

the class FileRegistryResourceDeployer method deployRegistryArtifacts.

/**
 * Deploys registry artifacts recursively. A Registry artifact can exist as a sub artifact in
 * any type of artifact. Therefore, have to search recursively
 *
 * @param artifacts - list of artifacts to be deployed
 * @param parentAppName - name of the parent cApp
 */
private void deployRegistryArtifacts(List<Artifact> artifacts, String parentAppName) {
    artifacts.stream().filter(artifact -> REGISTRY_RESOURCE_TYPE.equals(artifact.getType())).forEach(artifact -> {
        if (log.isDebugEnabled()) {
            log.debug("Deploying registry artifact: " + artifact.getName());
        }
        RegistryConfig regConfig = buildRegistryConfig(artifact, parentAppName);
        writeArtifactToRegistry(regConfig);
    });
}
Also used : AppDeployerConstants(org.wso2.carbon.application.deployer.AppDeployerConstants) AppDeployerUtils(org.wso2.carbon.application.deployer.AppDeployerUtils) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Registry(org.apache.synapse.registry.Registry) CarbonApplication(org.wso2.carbon.application.deployer.CarbonApplication) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) InputStreamReader(java.io.InputStreamReader) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) RegistryConfig(org.wso2.carbon.application.deployer.config.RegistryConfig) ArrayList(java.util.ArrayList) AppDeploymentHandler(org.wso2.carbon.application.deployer.handler.AppDeploymentHandler) List(java.util.List) ApplicationConfiguration(org.wso2.carbon.application.deployer.config.ApplicationConfiguration) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) Artifact(org.wso2.carbon.application.deployer.config.Artifact) CappFile(org.wso2.carbon.application.deployer.config.CappFile) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) BufferedReader(java.io.BufferedReader) DeploymentException(org.apache.axis2.deployment.DeploymentException) InputStream(java.io.InputStream) RegistryConfig(org.wso2.carbon.application.deployer.config.RegistryConfig)

Example 37 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-is by wso2.

the class IDPMetadataTestCase method addIDPMetadata.

@Test
public void addIDPMetadata() throws Exception {
    String filePath = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "saml" + File.separator + "idp-metadata.xml";
    byte[] encoded = Files.readAllBytes(Paths.get(filePath));
    String metadataXml = new String(encoded, StandardCharsets.UTF_8);
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setIdentityProviderName(ENTITYID);
    buildSAMLAuthenticationConfiguration(identityProvider, metadataXml);
    identityProviderMgtServiceClient.addIdP(identityProvider);
    identityProvider = identityProviderMgtServiceClient.getIdPByName(ENTITYID);
    FederatedAuthenticatorConfig samlFederatedAuthenticatorConfig = null;
    FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = identityProvider.getFederatedAuthenticatorConfigs();
    for (int i = 0; i < federatedAuthenticatorConfigs.length; i++) {
        if ("SAMLSSOAuthenticator".equals(federatedAuthenticatorConfigs[i].getName())) {
            samlFederatedAuthenticatorConfig = federatedAuthenticatorConfigs[i];
            break;
        }
    }
    Assert.assertNotNull(identityProvider);
    Assert.assertNotNull(samlFederatedAuthenticatorConfig);
    Property[] properties = samlFederatedAuthenticatorConfig.getProperties();
    for (Property property : properties) {
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), ENTITYID);
        }
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), SPENTITYID);
        }
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.SSO_URL.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), SSOURL);
        }
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.IS_AUTHN_REQ_SIGNED.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), IS_AUTHN_REQ_SIGNED);
        }
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.IS_LOGOUT_ENABLED.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), IS_LOGOUT_ENABLED);
        }
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.LOGOUT_REQ_URL.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), LOGOUT_REQ_URL);
        }
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.IS_ENABLE_ASSERTION_ENCRYPTION.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), IS_ENABLE_ASSERTION_ENCRYPTION);
        }
        if (IdentityApplicationConstants.Authenticator.SAML2SSO.IS_ENABLE_ASSERTION_SIGNING.equals(property.getName())) {
            Assert.assertEquals(property.getValue(), IS_ENABLE_ASSERTION_SIGNING);
        }
    }
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 38 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-is by wso2.

the class TenantDropDownTestCase method setUp.

@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
    super.init();
    applicationAuthenticationXml = new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "identity" + File.separator + "application-authentication.xml");
    File applicationAuthenticationXmlToCopy = new File(FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "tenantDropdown" + File.separator + "application-authentication-tanantDropdown-enabled.xml");
    authenticatorsXml = new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "security" + File.separator + "authenticators.xml");
    File authenticatorsXmlToCopy = new File(FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "tenantDropdown" + File.separator + "authenticators-tenantDropdown-enabled.xml");
    catalinaServerXml = new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "tomcat" + File.separator + "catalina-server.xml");
    File catalinaServerXmlToCopy = new File(FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "tenantDropdown" + File.separator + "catalina-server-tanantDropdown-enabled.xml");
    endpointConfigProperties = new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "identity" + File.separator + "EndpointConfig.properties");
    File endpointConfigPropertiesToCopy = new File(FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "tenantDropdown" + File.separator + "EndpointConfigTenantDropdownEnabled.properties");
    userIdentityMgt = new ServerConfigurationManager(isServer);
    userIdentityMgt.applyConfigurationWithoutRestart(applicationAuthenticationXmlToCopy, applicationAuthenticationXml, true);
    userIdentityMgt.applyConfigurationWithoutRestart(authenticatorsXmlToCopy, authenticatorsXml, true);
    userIdentityMgt.applyConfigurationWithoutRestart(catalinaServerXmlToCopy, catalinaServerXml, true);
    userIdentityMgt.applyConfigurationWithoutRestart(endpointConfigPropertiesToCopy, endpointConfigProperties, true);
    userIdentityMgt.restartGracefully();
    super.init();
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    driver = BrowserManager.getWebDriver();
    tenantServiceClient = new TenantManagementServiceClient(isServer.getContextUrls().getBackEndUrl(), sessionCookie);
    tenantServiceClient.addTenant(TENANT_DOMAIN, "admin", "password", "admin@dropdown.com", "Dropdown", "User");
    ssoConfigServiceClient = new SAMLSSOConfigServiceClient(backendURL, sessionCookie);
    applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext);
    ssoConfigServiceClient.addServiceProvider(createSsoServiceProviderDTO());
    createApplication();
    driver.get(isServer.getContextUrls().getWebAppURLHttps() + "/samlsso?spEntityID=" + SAML_ISSUER);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) SAMLSSOConfigServiceClient(org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) File(java.io.File) TenantManagementServiceClient(org.wso2.identity.integration.common.clients.TenantManagementServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 39 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-apimgt by wso2.

the class GatewayArtifactsMgtDAOTest method testGetAPIContextForMetaData.

@Test
public void testGetAPIContextForMetaData() throws APIManagementException {
    String uuid = UUID.randomUUID().toString();
    String name = "contextapiname";
    String version = "1.0.0";
    String revision = UUID.randomUUID().toString();
    String context = "/context2";
    URL resource = getClass().getClassLoader().getResource("admin-PizzaShackAPI-1.0.0.zip");
    File file = new File(resource.getPath());
    gatewayArtifactsMgtDAO.addGatewayAPIArtifactAndMetaData(uuid, name, version, revision, "carbon.super", APIConstants.HTTP_PROTOCOL, file);
    API api = new API(new APIIdentifier("test-provider", name, version));
    api.setContext(context);
    api.setContextTemplate("/context2/{version}");
    api.setUUID(uuid);
    apiMgtDAO.addAPI(api, -1234, "testOrg");
    Map<String, String> gatewayVhosts = new HashMap<>();
    gatewayVhosts.put("label1", "dev.wso2.com");
    gatewayArtifactsMgtDAO.addAndRemovePublishedGatewayLabels(uuid, revision, Collections.asSet("label1"), gatewayVhosts);
    List<APIRuntimeArtifactDto> artifacts = gatewayArtifactsMgtDAO.retrieveGatewayArtifactsByAPIIDAndLabel(uuid, new String[] { "label1" }, "carbon.super");
    Assert.assertEquals(artifacts.size(), 1);
    RuntimeArtifactDto artifact = artifacts.get(0);
    Assert.assertNotNull(artifact);
    Assert.assertEquals(context, artifacts.get(0).getContext());
}
Also used : APIRuntimeArtifactDto(org.wso2.carbon.apimgt.impl.dto.APIRuntimeArtifactDto) HashMap(java.util.HashMap) RuntimeArtifactDto(org.wso2.carbon.apimgt.impl.dto.RuntimeArtifactDto) APIRuntimeArtifactDto(org.wso2.carbon.apimgt.impl.dto.APIRuntimeArtifactDto) API(org.wso2.carbon.apimgt.api.model.API) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 40 with Artifacts

use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-apimgt by wso2.

the class GatewayArtifactsMgtDAOTest method testAddGatewayAPIArtifactAndMetaData.

@Test
public void testAddGatewayAPIArtifactAndMetaData() throws APIManagementException {
    String uuid = UUID.randomUUID().toString();
    String name = "apiname";
    String version = "1.0.0";
    String revision = UUID.randomUUID().toString();
    URL resource = getClass().getClassLoader().getResource("admin-PizzaShackAPI-1.0.0.zip");
    File file = new File(resource.getPath());
    gatewayArtifactsMgtDAO.addGatewayAPIArtifactAndMetaData(uuid, name, version, revision, "carbon.super", APIConstants.HTTP_PROTOCOL, file);
    API api = new API(new APIIdentifier("test-provider", name, version));
    api.setContext("/context1");
    api.setContextTemplate("/context1/{version}");
    api.setUUID(uuid);
    apiMgtDAO.addAPI(api, -1234, "testOrg");
    String gatewayAPIId = gatewayArtifactsMgtDAO.getGatewayAPIId(name, version, "carbon.super");
    Assert.assertEquals(gatewayAPIId, uuid);
    Map<String, String> gatewayVhosts = new HashMap<>();
    gatewayVhosts.put("label1", "dev.wso2.com");
    gatewayArtifactsMgtDAO.addAndRemovePublishedGatewayLabels(uuid, revision, Collections.asSet("label1"), gatewayVhosts);
    List<APIRuntimeArtifactDto> artifacts = gatewayArtifactsMgtDAO.retrieveGatewayArtifactsByAPIIDAndLabel(uuid, new String[] { "label1" }, "carbon.super");
    Assert.assertEquals(artifacts.size(), 1);
    RuntimeArtifactDto artifact = artifacts.get(0);
    Assert.assertNotNull(artifact);
    APIRevisionDeployment apiRevisionDeployment = new APIRevisionDeployment();
    apiRevisionDeployment.setRevisionUUID(revision);
    apiRevisionDeployment.setDeployment("label1");
    gatewayVhosts = new HashMap<>();
    gatewayVhosts.put("label2", "prod.wso2.com");
    gatewayArtifactsMgtDAO.addAndRemovePublishedGatewayLabels(uuid, revision, Collections.asSet("label2"), gatewayVhosts, Collections.asSet(apiRevisionDeployment));
    artifacts = gatewayArtifactsMgtDAO.retrieveGatewayArtifactsByAPIIDAndLabel(uuid, new String[] { "label1" }, "carbon.super");
    Assert.assertEquals(artifacts.size(), 0);
    artifacts = gatewayArtifactsMgtDAO.retrieveGatewayArtifactsByAPIIDAndLabel(uuid, new String[] { "label2" }, "carbon.super");
    Assert.assertEquals(artifacts.size(), 1);
    artifact = artifacts.get(0);
    Assert.assertNotNull(artifact);
}
Also used : APIRuntimeArtifactDto(org.wso2.carbon.apimgt.impl.dto.APIRuntimeArtifactDto) HashMap(java.util.HashMap) RuntimeArtifactDto(org.wso2.carbon.apimgt.impl.dto.RuntimeArtifactDto) APIRuntimeArtifactDto(org.wso2.carbon.apimgt.impl.dto.APIRuntimeArtifactDto) API(org.wso2.carbon.apimgt.api.model.API) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

File (java.io.File)23 IOException (java.io.IOException)18 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)18 ArrayList (java.util.ArrayList)17 CAppArtifacts (org.wso2.ei.dashboard.core.rest.model.CAppArtifacts)16 Operation (io.swagger.v3.oas.annotations.Operation)15 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)15 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)15 Response (javax.ws.rs.core.Response)15 Artifact (org.wso2.carbon.application.deployer.config.Artifact)15 Artifacts (org.wso2.ei.dashboard.core.rest.model.Artifacts)15 DeploymentException (org.apache.axis2.deployment.DeploymentException)11 CappFile (org.wso2.carbon.application.deployer.config.CappFile)11 Deployer (org.apache.axis2.deployment.Deployer)10 ArtifactSynchronizerException (org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException)10 Organization (org.wso2.carbon.apimgt.persistence.dto.Organization)10 InputStream (java.io.InputStream)9 FileInputStream (java.io.FileInputStream)7 APIRuntimeArtifactDto (org.wso2.carbon.apimgt.impl.dto.APIRuntimeArtifactDto)7 APIPersistenceException (org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException)7