ServiceMatchingStrategy by serviceManager.findServiceBy(serviceId) ?

9 views
Skip to first unread message

Brent Smith

unread,
Apr 16, 2020, 9:11:00 AM4/16/20
to CAS Developer
Hi, 

I see the DefaultServiceMatchingStrategy class does a case-insensitive exact match on the service URL passed in.  But couldn't it just call serviceManager.findServiceBy() for both URLs and then compare the resulting RegisteredService objects?

Or is there a problem with this that I'm not seeing?  Thanks!


/**
* This version of the service matching strategy matches on the serviceId regex, instead of exact matching
*/
@Slf4j
@RequiredArgsConstructor
@Getter
public class ServiceManagerServiceMatchingStrategy implements ServiceMatchingStrategy {
private final ServicesManager servicesManager;

@Override
public boolean matches(final Service service, final Service serviceToMatch) {
try {
val thisUrl = URLDecoder.decode(service.getId(), StandardCharsets.UTF_8.name());
val serviceUrl = URLDecoder.decode(serviceToMatch.getId(), StandardCharsets.UTF_8.name());

val thisUrlService = servicesManager.findServiceBy(thisUrl);
val serviceUrlService = servicesManager.findServiceBy(serviceUrl);

LOGGER.trace("Decoded urls and comparing [{}] with [{}]", thisUrl, serviceUrl);
return thisUrlService!=null && serviceUrlService!=null && thisUrlService.compareTo(serviceUrlService)==0;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
}
Reply all
Reply to author
Forward
0 new messages