code: private OAuthServiceEntity filterByEndpoint(OAuthServiceEntity entity, final String redirectUri)
  	{
  		if (entity != null)
  		{
  			if (redirectUri == null)
  				return entity; // If there's no redirectUri supplied then allow it
  
  			// N.B. database can have \r\n so we need to normalise this
  			final List<String> endpoints = Arrays
  					                               .stream(StringUtils
  							                                       .trimToEmpty(entity.getEndpoints())
  							                                       .replace('\r', '\n')
  							                                       .split("\n")).map(StringUtils:: trimToEmpty)
  					                               .filter(s -> s.length() > 0)
  					                               .collect(Collectors.toList());
  
  			if (log.isDebugEnabled())
  				log.debug("Check endpoint " + redirectUri + " against " + Arrays.asList(endpoints));
  
  			// Now check if the redirectUri matches any of the registered endpoints
  			// N.B. don't allow arbitrary startsWith (security issue if the redirectUri can be pointed at a resource in the app that redirects elsewhere)
  			for (String endpoint : endpoints)
  			{
  				if (StringUtils.equals(endpoint, redirectUri))
  				{
  					if (log.isDebugEnabled())
  						log.debug("Exact match to endpoint: " + endpoint);
  
  					return entity; // exact match
  				}
  				else
  				{
  					// Allow database to hold a base service endpoint and for the client to supply the oauth2 callback resource of that service
  					final String withCallbackEndpointAdded = endpoint + (endpoint.endsWith("/") ? "" : "/") + "oauth2/client/cb";
  
  					if (StringUtils.equals(withCallbackEndpointAdded, redirectUri))
  					{
  						if (log.isDebugEnabled())
  							log.debug("Match to endpoint with added /oauth2/client/cb suffix: " + endpoint);
  
  						return entity;
  					}
  				}
  			}
  		}
  
  		// Default: no match found
  		return null;
  	}
docs: Checks that one of the registered endpoints is a prefix match for the supplied <code>redirectUri</code>
  
  @param entity
  the database entity representing the service
  @param redirectUri
  the redirectUri received from the client
  
  @return