Brent,

I suppose that depends on what findServiceBy returns.
I suspect that most services are defined by a regex, so the comparison will 
depend on the first/best match. Or am I missing something about the job of 
serviceManager?

What is the problem you are trying to solve, or is it just interest?

Ray

On Thu, 2020-04-16 at 06:08 -0700, Brent Smith wrote:
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;




}


}


--

Ray Bon
Programmer Analyst
Development Services, University Systems
2507218831 | CLE 019 | [email protected]<mailto:[email protected]>

I respectfully acknowledge that my place of work is located within the 
ancestral, traditional and unceded territory of the Songhees, Esquimalt and 
WSÁNEĆ Nations.

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/006d9b1762203c0dcb453e6e79c823094a0d0660.camel%40uvic.ca.

Reply via email to