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);
});
}
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);
}
}
}
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);
}
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());
}
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);
}
Aggregations