Java Code Examples for org.jboss.shrinkwrap.api.Archive#contains()
The following examples show how to use
org.jboss.shrinkwrap.api.Archive#contains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EAP6DeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 6 votes |
private void modifyWebXML(Archive<?> archive, TestClass testClass) { if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; if (testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class) && archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) { log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); } try { Document webXmlDoc = IOUtil.loadXML(archive.get(DeploymentArchiveProcessorUtils.WEBXML_PATH).getAsset().openStream()); IOUtil.modifyDocElementValue(webXmlDoc, "param-value", ".*infinispan\\.InfinispanSessionCacheIdMapperUpdater", "org.keycloak.adapters.saml.jbossweb.infinispan.InfinispanSessionCacheIdMapperUpdater"); archive.add(new StringAsset((IOUtil.documentToString(webXmlDoc))), WEBXML_PATH); } catch (IllegalArgumentException ex) { throw new RuntimeException("Error when processing " + archive.getName(), ex); } }
Example 2
Source File: WildflyDeprecatedDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 5 votes |
private void modifyWebXML(Archive<?> archive, TestClass testClass) { if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return; log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); }
Example 3
Source File: RemoteDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 5 votes |
private void modifyWebXML(Archive<?> archive, TestClass testClass) { if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return; log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); }
Example 4
Source File: EAPDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 5 votes |
private void modifyWebXML(Archive<?> archive, TestClass testClass) { if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return; log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); }
Example 5
Source File: TomcatDeploymentArchiveProcessorUtils.java From keycloak with Apache License 2.0 | 5 votes |
public static void removeServletConfigurationInWebXML(Archive<?> archive) { if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; try { Document webXmlDoc = loadXML(archive.get(DeploymentArchiveProcessorUtils.WEBXML_PATH).getAsset().openStream()); LOG.debug("Removing web.xml servlet configuration for " + archive.getName()); removeElementFromDoc(webXmlDoc, "web-app/servlet"); removeElementFromDoc(webXmlDoc, "web-app/servlet-mapping"); archive.add(new StringAsset((documentToString(webXmlDoc))), DeploymentArchiveProcessorUtils.WEBXML_PATH); } catch (IllegalArgumentException ex) { throw new RuntimeException("Error when processing " + archive.getName(), ex); } }
Example 6
Source File: WildflyDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 5 votes |
private void modifyWebXML(Archive<?> archive, TestClass testClass) { if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return; log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); }
Example 7
Source File: UndertowDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 5 votes |
private void modifyWebXML(Archive<?> archive, TestClass testClass) { if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); }
Example 8
Source File: CommonTomcatDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void modifySAMLAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath); }
Example 9
Source File: WildflyDeprecatedDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void modifySAMLAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath); }
Example 10
Source File: JettyDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void modifySAMLAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath); }
Example 11
Source File: UndertowDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void modifySAMLAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath); }
Example 12
Source File: WildflyDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void modifySAMLAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath); }
Example 13
Source File: RemoteDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void modifySAMLAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath); }
Example 14
Source File: DeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 4 votes |
protected void modifyAdapterConfig(Archive<?> archive, String adapterConfigPath, boolean relative) { if (archive.contains(adapterConfigPath)) { log.info("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); if (adapterConfigPath.endsWith(".xml")) { // SAML adapter config log.info("Modifying saml adapter config in " + archive.getName()); Document doc = loadXML(archive.get(adapterConfigPath).getAsset().openStream()); if (AUTH_SERVER_SSL_REQUIRED) { modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "8080", System.getProperty("auth.server.https.port")); modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "http", "https"); modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "8080", System.getProperty("app.server.https.port")); modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "http", "https"); modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "8080", System.getProperty("auth.server.https.port")); modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "http", "https"); modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "8080", System.getProperty("auth.server.https.port")); modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "http", "https"); modifyDocElementAttribute(doc, "SP", "logoutPage", "8080", System.getProperty("app.server.https.port")); modifyDocElementAttribute(doc, "SP", "logoutPage", "http", "https"); } else { modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "8080", System.getProperty("auth.server.http.port")); modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "8080", System.getProperty("app.server.http.port")); modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "8080", System.getProperty("auth.server.http.port")); modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "8080", System.getProperty("auth.server.http.port")); modifyDocElementAttribute(doc, "SP", "logoutPage", "8080", System.getProperty("app.server.http.port")); } archive.add(new StringAsset(IOUtil.documentToString(doc)), adapterConfigPath); ((WebArchive) archive).addAsResource(new File(DeploymentArchiveProcessor.class.getResource("/keystore/keycloak.truststore").getFile())); // For running SAML tests it is necessary to have few dependencies on app-server side. // Few of them are not in adapter zip so we need to add them manually here } else { // OIDC adapter config try { AdapterConfig adapterConfig = loadJson(archive.get(adapterConfigPath) .getAsset().openStream(), AdapterConfig.class); adapterConfig.setAuthServerUrl(getAuthServerContextRoot() + "/auth"); if (APP_SERVER_SSL_REQUIRED) { adapterConfig.setSslRequired("all"); } archive.add(new StringAsset(JsonSerialization.writeValueAsPrettyString(adapterConfig)), adapterConfigPath); } catch (IOException ex) { log.error("Cannot serialize adapter config to JSON.", ex); } } } }
Example 15
Source File: MarkerContainer.java From thorntail with Apache License 2.0 | 4 votes |
static boolean hasMarker(Archive<?> archive, String markerName) { return archive.contains(ArchivePaths.create("META-INF/markers", markerName)); }
Example 16
Source File: MicroOuterDeployer.java From piranha with BSD 3-Clause "New" or "Revised" License | 4 votes |
@SuppressWarnings("unchecked") public Set<String> deploy(Archive<?> archive) { Set<String> servletNames = new HashSet<>(); if (!archive.contains("WEB-INF/beans.xml")) { archive.add(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); } ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { // Resolve all the dependencies that make up a Piranha runtime configuration ConfigurableMavenResolverSystem mavenResolver = Maven.configureResolver(); configuration.getRepositoriesList().stream().forEach(repoUrl -> mavenResolver.withRemoteRepo(createRepo(repoUrl))); JavaArchive[] piranhaArchives = mavenResolver .workOffline(configuration.isOffline()) .resolve(configuration.getMergedDependencies()) .withTransitivity() .as(JavaArchive.class); // Make all those dependencies available to the Piranha class loader ClassLoader piranhaClassLoader = getPiranhaClassLoader(piranhaArchives); // Make the web application archive (the .war) available to a separate classloader // The webInfClassLoader delegates to the Piranha class loader. // The class loading hierarchy looks as follows: // Web-inf class loader (application classes) // | // |--- System class loader (Pass-through for Shrinkwrap classes only) // |--- java.lang.ClassLoader (super class, Weld, Javasist etc hack-in their classes here) // | // Piranha class loader (Piranha classes) // | // | // Platform class loader (JDK classes) ClassLoader webInfClassLoader = getWebInfClassLoader(archive, piranhaClassLoader); Thread.currentThread().setContextClassLoader(webInfClassLoader); try { URL.setURLStreamHandlerFactory(new StaticURLStreamHandlerFactory()); } catch (Error error) { // Yes, we know... // Ignore } System.setProperty("micro.version", getClass().getPackage().getImplementationVersion()); microInnerDeployer = Class.forName( "cloud.piranha.micro.MicroInnerDeployer", true, webInfClassLoader) .getDeclaredConstructor() .newInstance(); servletNames.addAll((Set<String>) microInnerDeployer .getClass() .getMethod("start", Archive.class, ClassLoader.class, Map.class, Integer.class) .invoke(microInnerDeployer, archive, webInfClassLoader, StaticURLStreamHandlerFactory.getHandlers(), configuration.getPort())); return servletNames; } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalStateException("", e); } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); } }
Example 17
Source File: EAPDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 3 votes |
private void modifyOIDCAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); }
Example 18
Source File: EAP6DeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 3 votes |
private void modifyOIDCAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); }
Example 19
Source File: JettyDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 3 votes |
private void modifyOIDCAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); }
Example 20
Source File: WildflyDeprecatedDeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 3 votes |
private void modifyOIDCAdapterConfig(Archive<?> archive, String adapterConfigPath) { if (!archive.contains(adapterConfigPath)) return; log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); }