-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from newrelic/feature/api-endpoint/fallback-m…
…ech-NR-273607 [NR-273607] Fallback mechanism for route calculation
- Loading branch information
Showing
7 changed files
with
261 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...rc/main/java/com/newrelic/api/agent/security/instrumentation/helpers/RouteComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.newrelic.api.agent.security.instrumentation.helpers; | ||
|
||
import com.newrelic.api.agent.security.schema.RouteSegments; | ||
|
||
import java.util.Comparator; | ||
|
||
public class RouteComparator implements Comparator<RouteSegments> { | ||
|
||
|
||
@Override | ||
public int compare(RouteSegments s1, RouteSegments s2) { | ||
int result = Integer.compare(s2.getRoute().length(), s1.getRoute().length()); | ||
if(result == 0){ | ||
result = s2.getRoute().compareTo(s1.getRoute()); | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,6 @@ public enum Framework { | |
SPRAY, | ||
SPRAY_HTTP, | ||
SUN_NET_HTTPSERVER, | ||
VERTX | ||
VERTX, | ||
UNKNOWN | ||
} |
25 changes: 25 additions & 0 deletions
25
newrelic-security-api/src/main/java/com/newrelic/api/agent/security/schema/RouteSegment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.newrelic.api.agent.security.schema; | ||
|
||
public class RouteSegment { | ||
private final String segment; | ||
private final boolean isPathParam; | ||
private final boolean allowMultipleSegments; | ||
|
||
public RouteSegment(String segment, boolean isPathParam, boolean allowMultipleSegments) { | ||
this.segment = segment; | ||
this.isPathParam = isPathParam; | ||
this.allowMultipleSegments = allowMultipleSegments; | ||
} | ||
|
||
public boolean isPathParam() { | ||
return isPathParam; | ||
} | ||
|
||
public String getSegment() { | ||
return segment; | ||
} | ||
|
||
public boolean isAllowMultipleSegments() { | ||
return allowMultipleSegments; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...elic-security-api/src/main/java/com/newrelic/api/agent/security/schema/RouteSegments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.newrelic.api.agent.security.schema; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class RouteSegments { | ||
private final String route; | ||
private final List<RouteSegment> segments; | ||
|
||
public RouteSegments(String route, List<RouteSegment> segments) { | ||
this.route = route; | ||
this.segments = segments; | ||
} | ||
|
||
public String getRoute() { | ||
return route; | ||
} | ||
|
||
public List<RouteSegment> getSegments() { | ||
return segments; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
if (obj instanceof RouteSegments) { | ||
RouteSegments routeSegments = (RouteSegments) obj; | ||
return Objects.equals(this.route, routeSegments.route); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(route); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters