File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
share-oauth/src/main/java/org/sharextras/webscripts/connector Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -581,13 +581,26 @@ public String getEndpointId()
581
581
return descriptor .getStringProperty (PARAM_TOKEN_ENDPOINT );
582
582
}
583
583
584
+ /**
585
+ * Get the endpoint ID identified in the given request object. This is necessary because the connector is
586
+ * not aware of the ID of the endpoint which is utilising it, only the URI.
587
+ *
588
+ * @param uri URI path relative to the base endpoint URI, passed to the connector, e.g. /path/to/blah
589
+ * @param request HTTP request object representing the proxied request object
590
+ * @return The endpoint ID as specified in the web-tier config
591
+ */
584
592
private String getEndpointId (String uri , HttpServletRequest request )
585
593
{
586
594
// Work out URI path (i.e. uri without the querystring portion)
587
595
String uriPath = uri .indexOf ('?' ) > -1 ? uri .substring (0 , uri .indexOf ('?' )) : uri ;
588
- return getEndpointId () != null ? getEndpointId () :
589
- request .getPathInfo ().replaceAll (uriPath , "" ).replaceAll ("/proxy/" , "" );
590
-
596
+ String endpointId = getEndpointId ();
597
+ if (endpointId == null )
598
+ {
599
+ String basePath = request .getPathInfo () // will be something like /proxy/endpoint-id/path/to/blah
600
+ .substring (0 , request .getPathInfo ().length () - uriPath .length ());
601
+ endpointId = basePath .substring (basePath .lastIndexOf ('/' ) + 1 ); // take the last path segment only
602
+ }
603
+ return endpointId ;
591
604
}
592
605
593
606
private ConnectorService getConnectorService ()
You can’t perform that action at this time.
0 commit comments