use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class OpenApiDeploymentProcessor method process.
/**
* Process the deployment in order to produce an OpenAPI document.
*
* @see org.wildfly.swarm.spi.api.DeploymentProcessor#process()
*/
@Override
public void process() throws Exception {
try {
// First register OpenApiServletContextListener which triggers the final init
WARArchive warArchive = archive.as(WARArchive.class);
warArchive.findWebXmlAsset().addListener(LISTENER_CLASS);
} catch (Exception e) {
throw new RuntimeException("Failed to register OpenAPI listener", e);
}
// Set models from annotations and static file
OpenApiDocument openApiDocument = OpenApiDocument.INSTANCE;
openApiDocument.config(config);
openApiDocument.modelFromStaticFile(modelFromStaticFile());
openApiDocument.modelFromAnnotations(modelFromAnnotations());
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class Main method main.
public static void main(String[] args) throws Exception {
/*BEGIN:custom main:JAR_WITH_MAIN*/
swarm = new Swarm();
WARArchive war = ShrinkWrap.create(WARArchive.class).addPackage(Main.class.getPackage()).addAsWebInfResource(new ClassLoaderAsset("web.xml", Main.class.getClassLoader()), WebXmlAsset.NAME);
swarm.start().deploy(war);
/*END:custom main:JAR_WITH_MAIN*/
/*BEGIN:custom main:WAR_WITH_MAIN*/
swarm2 = new Swarm().start().deploy();
/*END:custom main:WAR_WITH_MAIN*/
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class JAXRSArchiveTest method testDetectJAXRSness_classAnnotation.
@Test
public void testDetectJAXRSness_classAnnotation() {
WARArchive archive = ShrinkWrap.create(WARArchive.class);
archive.addClass(MyResource.class);
assertThat(JAXRSArchive.isJAXRS(archive)).isTrue();
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class ManagementConsoleDeploymentProducer method managementConsoleWar.
@Produces
public Archive managementConsoleWar() throws Exception {
// Load the management-ui webjars.
WARArchive war = ShrinkWrap.create(WARArchive.class, "management-console-ui.war");
Module module = Module.getBootModuleLoader().loadModule("org.jboss.as.console");
Iterator<Resource> resources = module.globResources("*");
while (resources.hasNext()) {
Resource each = resources.next();
war.add(new UrlAsset(each.getURL()), each.getName());
}
war.setContextRoot(this.fraction.contextRoot());
return war;
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class MPJWTAuthExtensionArchivePreparer method process.
@Override
public void process() throws Exception {
WARArchive war = archive.as(WARArchive.class);
// Check for LoginConfig annotation
Collection<AnnotationInstance> lcAnnotations = index.getAnnotations(LOGIN_CONFIG);
for (AnnotationInstance lc : lcAnnotations) {
AnnotationValue authMethod = lc.value("authMethod");
AnnotationValue realmName = lc.value("realmName");
String realm = realmName != null ? realmName.asString() : "";
// Set the web.xml login-config auth-method and jboss-web.xml security domain
if (authMethod != null) {
WebXmlAsset webXml = war.findWebXmlAsset();
webXml.setLoginConfig(authMethod.asString(), realm);
}
if (realm.length() > 0) {
JBossWebAsset jBossWeb = war.findJbossWebAsset();
jBossWeb.setSecurityDomain(realm);
}
}
// Get the @ApplicationPath setting
WebXmlAsset webXml = war.findWebXmlAsset();
String appPath = "/";
Collection<AnnotationInstance> appPaths = index.getAnnotations(APP_PATH);
if (!appPaths.isEmpty()) {
appPath = appPaths.iterator().next().value().asString();
}
// Process the @RolesAllowed, @PermitAll and @DenyAll annotations
Collection<AnnotationInstance> rolesAnnotations = index.getAnnotations(ROLES_ALLOWED);
for (AnnotationInstance annotation : rolesAnnotations) {
if (annotation.target().kind() == AnnotationTarget.Kind.CLASS) {
// Process the root resource
String[] roles = annotation.value().asStringArray();
ClassInfo classInfo = annotation.target().asClass();
if (!scannedClasses.contains(classInfo.name())) {
generateSecurityConstraints(webXml, classInfo, roles, appPath);
}
} else if (annotation.target().kind() == AnnotationTarget.Kind.METHOD) {
// Process the containing root resource if it has not been already
MethodInfo methodInfo = annotation.target().asMethod();
ClassInfo classInfo = methodInfo.declaringClass();
if (!scannedClasses.contains(classInfo.name())) {
String[] roles = {};
generateSecurityConstraints(webXml, classInfo, roles, appPath);
}
}
}
// Handle the verification configuration on the fraction
if (fraction.getTokenIssuer().isPresent()) {
log.debugf("Issuer: %s", fraction.getTokenIssuer().get());
war.addAsManifestResource(new StringAsset(fraction.getTokenIssuer().get()), "MP-JWT-ISSUER");
}
if (fraction.getPublicKey() != null) {
log.debugf("PublicKey: %s", fraction.getPublicKey());
war.addAsManifestResource(new StringAsset(fraction.getPublicKey()), "MP-JWT-SIGNER");
}
if (log.isTraceEnabled()) {
log.trace("war: " + war.toString(true));
}
}
Aggregations