Skip to content

Commit

Permalink
Issue #5824 Change after review
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Dec 30, 2020
1 parent 39d7083 commit 60b3508
Showing 1 changed file with 7 additions and 21 deletions.
Expand Up @@ -261,20 +261,10 @@ public static List<ConstraintMapping> createConstraintsWithMappingsForPath(Strin
return mappings;
}

/**
* @return only the durable mappings if we are not yet started, otherwise
* return both the durables and transients.
*/
@Override
public List<ConstraintMapping> getConstraintMappings()
{
//if we've started, then we've processed both the durable and
//transient constraint mappings
if (isRunning())
return _constraintMappings;
else
//otherwise, we only have durables
return _durableConstraintMappings;
return _constraintMappings;
}

@Override
Expand Down Expand Up @@ -319,6 +309,7 @@ public void setConstraintMappings(List<ConstraintMapping> constraintMappings, Se
{
_durableConstraintMappings.clear();
_constraintMappings.clear();
_constraintMappings.addAll(constraintMappings);

if (isInDurableState())
_durableConstraintMappings.addAll(constraintMappings);
Expand All @@ -343,11 +334,7 @@ public void setConstraintMappings(List<ConstraintMapping> constraintMappings, Se

if (isStarted())
{
_constraintMappings.addAll(constraintMappings);
for (ConstraintMapping mapping : _constraintMappings)
{
processConstraintMapping(mapping);
}
_constraintMappings.stream().forEach(m -> processConstraintMapping(m));
}
}

Expand All @@ -373,6 +360,8 @@ public void addConstraintMapping(ConstraintMapping mapping)
if (isInDurableState())
_durableConstraintMappings.add(mapping);

_constraintMappings.add(mapping);

if (mapping.getConstraint() != null && mapping.getConstraint().getRoles() != null)
{
//allow for lazy role naming: if a role is named in a security constraint, try and
Expand All @@ -386,10 +375,7 @@ public void addConstraintMapping(ConstraintMapping mapping)
}

if (isStarted())
{
_constraintMappings.add(mapping);
processConstraintMapping(mapping);
}
}

/**
Expand Down Expand Up @@ -420,7 +406,6 @@ public void addRole(String role)
@Override
protected void doStart() throws Exception
{
_constraintMappings.addAll(_durableConstraintMappings);
_constraintMappings.stream().forEach(m -> processConstraintMapping(m));

//Servlet Spec 3.1 pg 147 sec 13.8.4.2 log paths for which there are uncovered http methods
Expand All @@ -435,7 +420,8 @@ protected void doStop() throws Exception
super.doStop();
_constraintMap.clear();
_constraintMappings.clear();
}
_constraintMappings.addAll(_durableConstraintMappings);
}

/**
* Create and combine the constraint with the existing processed
Expand Down

0 comments on commit 60b3508

Please sign in to comment.