Skip to content

Commit

Permalink
Merge pull request #6516 from luiseufrasio/FISH-5877-login-config-ann…
Browse files Browse the repository at this point in the history
…otation-security-constraints-community

FISH-5877 : Warning for LoginConfig annotation and security-constraint
  • Loading branch information
luiseufrasio authored Jan 8, 2024
2 parents 8a19035 + 855cc49 commit c6d9f3e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2020-2021] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2020-2023] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -40,9 +40,11 @@
package fish.payara.microprofile.jwtauth.activation;

import java.util.Collection;
import java.util.Enumeration;
import java.util.function.Supplier;
import java.util.logging.Logger;

import com.sun.enterprise.deployment.web.SecurityConstraint;
import jakarta.enterprise.inject.spi.Extension;

import org.glassfish.api.deployment.DeploymentContext;
Expand Down Expand Up @@ -71,6 +73,11 @@ public JwtAuthApplicationContainer load(JwtAuthContainer container,
WebBundleDescriptorImpl descriptor = deploymentContext.getModuleMetaData(WebBundleDescriptorImpl.class);
if (descriptor != null) {
descriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(RolesDeclarationInitializer.class.getName()));

Enumeration<SecurityConstraint> securityConstraintEnumeration = descriptor.getSecurityConstraints();
if (securityConstraintEnumeration.hasMoreElements()) {
LOGGER.warning("Invalid web.xml - security-constraints cannot be defined while using the @LoginConfig annotation");
}
} else {
LOGGER.warning("Failed to find WebBundleDescriptorImpl. JWT Auth roles will not be declared");
}
Expand Down

0 comments on commit c6d9f3e

Please sign in to comment.