Skip to content

Commit

Permalink
Merge branch 'jetty-10.0.x' into jetty-11.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
olamy committed Dec 13, 2020
2 parents d5b08ea + 0c1f963 commit aa150d3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 89 deletions.
Expand Up @@ -159,7 +159,7 @@ public static List<ConstraintMapping> getConstraintMappingsForPath(String pathSp
if (pathSpec == null || "".equals(pathSpec.trim()) || constraintMappings == null || constraintMappings.size() == 0)
return Collections.emptyList();

List<ConstraintMapping> mappings = new ArrayList<ConstraintMapping>();
List<ConstraintMapping> mappings = new ArrayList<>();
for (ConstraintMapping mapping : constraintMappings)
{
if (pathSpec.equals(mapping.getPathSpec()))
Expand All @@ -183,7 +183,7 @@ public static List<ConstraintMapping> removeConstraintMappingsForPath(String pat
if (pathSpec == null || "".equals(pathSpec.trim()) || constraintMappings == null || constraintMappings.size() == 0)
return Collections.emptyList();

List<ConstraintMapping> mappings = new ArrayList<ConstraintMapping>();
List<ConstraintMapping> mappings = new ArrayList<>();
for (ConstraintMapping mapping : constraintMappings)
{
//Remove the matching mappings by only copying in non-matching mappings
Expand All @@ -205,10 +205,10 @@ public static List<ConstraintMapping> removeConstraintMappingsForPath(String pat
*/
public static List<ConstraintMapping> createConstraintsWithMappingsForPath(String name, String pathSpec, ServletSecurityElement securityElement)
{
List<ConstraintMapping> mappings = new ArrayList<ConstraintMapping>();
List<ConstraintMapping> mappings = new ArrayList<>();

//Create a constraint that will describe the default case (ie if not overridden by specific HttpMethodConstraints)
Constraint httpConstraint = null;
Constraint httpConstraint;
ConstraintMapping httpConstraintMapping = null;

if (securityElement.getEmptyRoleSemantic() != EmptyRoleSemantic.PERMIT ||
Expand All @@ -225,7 +225,7 @@ public static List<ConstraintMapping> createConstraintsWithMappingsForPath(Strin
}

//See Spec 13.4.1.2 p127
List<String> methodOmissions = new ArrayList<String>();
List<String> methodOmissions = new ArrayList<>();

//make constraint mappings for this url for each of the HttpMethodConstraintElements
Collection<HttpMethodConstraintElement> methodConstraintElements = securityElement.getHttpMethodConstraints();
Expand All @@ -250,7 +250,7 @@ public static List<ConstraintMapping> createConstraintsWithMappingsForPath(Strin
//See spec 13.4.1.2 p127 - add an omission for every method name to the default constraint
//UNLESS the default constraint contains all default values. In that case, we won't add it. See Servlet Spec 3.1 pg 129
if (methodOmissions.size() > 0 && httpConstraintMapping != null)
httpConstraintMapping.setMethodOmissions(methodOmissions.toArray(new String[methodOmissions.size()]));
httpConstraintMapping.setMethodOmissions(methodOmissions.toArray(new String[0]));

return mappings;
}
Expand Down Expand Up @@ -394,10 +394,7 @@ protected void doStart() throws Exception
_constraintRoles.reset();
if (_constraintMappings != null)
{
for (ConstraintMapping mapping : _constraintMappings)
{
processConstraintMapping(mapping);
}
_constraintMappings.stream().forEach(this::processConstraintMapping);
}

//Servlet Spec 3.1 pg 147 sec 13.8.4.2 log paths for which there are uncovered http methods
Expand All @@ -424,7 +421,7 @@ protected void processConstraintMapping(ConstraintMapping mapping)
Map<String, RoleInfo> mappings = _constraintRoles.get(PathMappings.asPathSpec(mapping.getPathSpec()));
if (mappings == null)
{
mappings = new HashMap<String, RoleInfo>();
mappings = new HashMap<>();
_constraintRoles.put(mapping.getPathSpec(), mappings);
}
RoleInfo allMethodsRoleInfo = mappings.get(ALL_METHODS);
Expand Down Expand Up @@ -579,7 +576,7 @@ protected RoleInfo prepareConstraintInfo(String pathInContext, Request request)
if (roleInfo == null)
{
//No specific http-method names matched
List<RoleInfo> applicableConstraints = new ArrayList<RoleInfo>();
List<RoleInfo> applicableConstraints = new ArrayList<>();

//Get info for constraint that matches all methods if it exists
RoleInfo all = mappings.get(ALL_METHODS);
Expand Down Expand Up @@ -715,8 +712,8 @@ protected boolean checkWebResourcePermissions(String pathInContext, Request requ
public void dump(Appendable out, String indent) throws IOException
{
dumpObjects(out, indent,
DumpableCollection.from("roles", _roles),
DumpableCollection.from("constraints", _constraintMappings));
DumpableCollection.from("roles", _roles),
DumpableCollection.from("constraints", _constraintMappings));
}

@Override
Expand Down Expand Up @@ -767,7 +764,7 @@ public Set<String> getPathsWithUncoveredHttpMethods()
if (_denyUncoveredMethods)
return Collections.emptySet();

Set<String> uncoveredPaths = new HashSet<String>();
Set<String> uncoveredPaths = new HashSet<>();

for (MappedResource<Map<String, RoleInfo>> resource : _constraintRoles)
{
Expand Down Expand Up @@ -839,7 +836,7 @@ protected Set<String> getOmittedMethods(String omission)
return Collections.emptySet();

String[] strings = omission.split("\\.");
Set<String> methods = new HashSet<String>();
Set<String> methods = new HashSet<>();
for (int i = 0; i < strings.length - 1; i++)
{
methods.add(strings[i]);
Expand Down
Expand Up @@ -66,13 +66,10 @@ public boolean acknowledgeLicenses() throws IOException
System.err.printf(" + contains software not covered by the Eclipse Public License!%n");
System.err.printf(" + has not been audited for compliance with its license%n");

for (String key : licenseMap.keySet())
for (Map.Entry<String, List<String>> entry : licenseMap.entrySet())
{
System.err.printf("%n Module: %s%n", key);
for (String line : licenseMap.get(key))
{
System.err.printf(" + %s%n", line);
}
System.err.printf("%n Module: %s%n", entry.getKey());
entry.getValue().forEach(line -> System.err.printf(" + %s%n", line));
}

boolean licenseAck = false;
Expand Down

0 comments on commit aa150d3

Please sign in to comment.