use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-microgateway by wso2.
the class CommonUtils method extractResources.
/**
* Extract resource artifacts from the jar file.
* @param projectName project name.
* @throws IOException
*/
public static void extractResources(String projectName) throws IOException {
String path = Constants.RESOURCE_LOCATION + projectName + Constants.FORWARD_SLASH;
CodeSource src = Validate.class.getProtectionDomain().getCodeSource();
StringBuffer stringBuffer;
if (src != null) {
URL jar = src.getLocation();
ZipInputStream zip = new ZipInputStream(jar.openStream());
while (true) {
ZipEntry e = zip.getNextEntry();
if (e == null) {
break;
}
String name = e.getName();
if (name.startsWith(path) && name.endsWith(Constants.JSON_EXTENSION)) {
String fileName = Paths.get(name).getFileName().toString();
String apiName = fileName.substring(0, fileName.lastIndexOf(Constants.UNDER_SCORE));
String apiVersion = fileName.substring(fileName.lastIndexOf(Constants.UNDER_SCORE) + 1, fileName.lastIndexOf(Constants.DOT));
String serviceName = CommonUtils.getQualifiedServiceName(apiName, apiVersion);
InputStream in = Validate.class.getResourceAsStream(Constants.FORWARD_SLASH + name);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
stringBuffer = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
stringBuffer.append(line).append("\n");
}
openAPIMap.put(serviceName, stringBuffer.toString());
}
}
}
}
use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-is by wso2.
the class SPMetaDataTenantTestCase method addSPMetadataForTenant.
@Test(testName = "metaDataTestcase")
public void addSPMetadataForTenant() throws Exception {
String filePath = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "saml" + File.separator + "sp-metadata.xml";
byte[] encoded = Files.readAllBytes(Paths.get(filePath));
String metadataXml = new String(encoded, StandardCharsets.UTF_8);
// Load the metadata file to the client.
SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = ssoConfigServiceClient.uploadServiceProvider(metadataXml);
Assert.assertEquals(samlssoServiceProviderDTO.getIssuer(), ISSUER);
SAMLSSOServiceProviderDTO[] samlssoServiceProviderDTOs = ssoConfigServiceClient.getServiceProviders().getServiceProviders();
SAMLSSOServiceProviderDTO samlssoServiceProviderDTOGet = null;
for (SAMLSSOServiceProviderDTO serviceProviderDTO : samlssoServiceProviderDTOs) {
if (ISSUER.equals(serviceProviderDTO.getIssuer())) {
samlssoServiceProviderDTOGet = serviceProviderDTO;
}
}
Assert.assertNotNull(samlssoServiceProviderDTOGet);
Assert.assertEquals(samlssoServiceProviderDTOGet.getCertAlias(), CERT_ALIAS);
KeyStoreAdminClient keyStoreAdminClient = new KeyStoreAdminClient(backendURL, ADMIN_USERNAME, ADMIN_PASSWORD);
KeyStoreData[] keyStoreDataArray = keyStoreAdminClient.getKeyStores();
Assert.assertTrue(keyStoreDataArray != null && keyStoreDataArray.length > 0);
String[] storeEntries = keyStoreAdminClient.getStoreEntries("wso2-com.jks");
Assert.assertTrue(storeEntries != null && storeEntries.length > 0);
Assert.assertTrue(Arrays.asList(storeEntries).contains(CERT_ALIAS));
}
use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project product-is by wso2.
the class SPMetadataTestCase method addSPMetadata.
@Test
public void addSPMetadata() throws Exception {
String filePath = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "saml" + File.separator + "sp-metadata.xml";
byte[] encoded = Files.readAllBytes(Paths.get(filePath));
String metadataXml = new String(encoded, StandardCharsets.UTF_8);
SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = ssoConfigServiceClient.uploadServiceProvider(metadataXml);
Assert.assertEquals(samlssoServiceProviderDTO.getIssuer(), ISSUER);
Assert.assertEquals(samlssoServiceProviderDTO.getDefaultAssertionConsumerUrl(), ACSs[0]);
Assert.assertEquals(samlssoServiceProviderDTO.getAssertionConsumerUrls(), ACSs);
SAMLSSOServiceProviderDTO[] samlssoServiceProviderDTOs = ssoConfigServiceClient.getServiceProviders().getServiceProviders();
SAMLSSOServiceProviderDTO samlssoServiceProviderDTOGet = null;
for (SAMLSSOServiceProviderDTO serviceProviderDTO : samlssoServiceProviderDTOs) {
if (ISSUER.equals(serviceProviderDTO.getIssuer())) {
samlssoServiceProviderDTOGet = serviceProviderDTO;
}
}
Assert.assertNotNull(samlssoServiceProviderDTOGet);
Assert.assertEquals(samlssoServiceProviderDTOGet.getDefaultAssertionConsumerUrl(), ACSs[0]);
Assert.assertEquals(samlssoServiceProviderDTOGet.getAssertionConsumerUrls(), ACSs);
Assert.assertEquals(samlssoServiceProviderDTOGet.getNameIDFormat(), NAMEIDFORMAT);
Assert.assertEquals(samlssoServiceProviderDTOGet.getDoSignAssertions(), WANTASSERTIONSSIGNED);
Assert.assertEquals(samlssoServiceProviderDTOGet.getDoValidateSignatureInRequests(), ISAAUTHNREQUESTSSIGNED);
Assert.assertEquals(samlssoServiceProviderDTOGet.getSloRequestURL(), SLOREQUESTURL);
Assert.assertEquals(samlssoServiceProviderDTOGet.getSloResponseURL(), SLORESPONSEURL);
}
Aggregations