@@ -78,7 +78,7 @@ public void setApplicationContext(ApplicationContext applicationContext)
78
78
79
79
private String getAuthenticationMethod ()
80
80
{
81
- String descriptorMethod = descriptor . getStringProperty (PARAM_AUTH_METHOD );
81
+ String descriptorMethod = getDescriptorProperty (PARAM_AUTH_METHOD , ( EndpointDescriptor ) null );
82
82
return descriptorMethod != null ? descriptorMethod : AUTH_METHOD_OAUTH ;
83
83
}
84
84
@@ -445,21 +445,12 @@ protected void applyRequestAuthentication(RemoteClient remoteClient, ConnectorCo
445
445
protected String doRefresh (String endpointId ) throws TokenRefreshException
446
446
{
447
447
String refreshToken = getRefreshToken ();
448
- ConnectorService connectorService = getConnectorService ();
449
- EndpointDescriptor epd = connectorService .getRemoteConfig ().getEndpointDescriptor (endpointId );
448
+ EndpointDescriptor epd = getEndpointDescriptor (endpointId );
450
449
451
450
// First try to get the client-id and access-token-url from the endpoint, then from the connector
452
451
// TODO Make these strings constants in a Descriptor sub-class or interface
453
- String clientId = epd .getStringProperty ("client-id" );
454
- String tokenUrl = epd .getStringProperty ("access-token-url" );
455
- if (clientId == null )
456
- {
457
- clientId = descriptor .getStringProperty ("client-id" );
458
- }
459
- if (tokenUrl == null )
460
- {
461
- tokenUrl = descriptor .getStringProperty ("access-token-url" );
462
- }
452
+ String clientId = getDescriptorProperty ("client-id" , epd );
453
+ String tokenUrl = getDescriptorProperty ("access-token-url" , epd );
463
454
/*
464
455
RemoteClient remoteClient = buildRemoteClient(tokenUrl);
465
456
@@ -537,6 +528,31 @@ protected String doRefresh(String endpointId) throws TokenRefreshException
537
528
return null ;
538
529
}
539
530
}
531
+
532
+ protected EndpointDescriptor getEndpointDescriptor (String endpointId )
533
+ {
534
+ return getConnectorService ().getRemoteConfig ().getEndpointDescriptor (endpointId );
535
+ }
536
+
537
+ protected String getDescriptorProperty (String propertyName , EndpointDescriptor endpointDescriptor )
538
+ {
539
+ String propertyValue = null ;
540
+ if (endpointDescriptor != null )
541
+ {
542
+ propertyValue = endpointDescriptor .getStringProperty (propertyName );
543
+ }
544
+ // Fall back to connector property if not found on endpoint
545
+ if (propertyValue == null )
546
+ {
547
+ propertyValue = descriptor .getStringProperty (propertyName );
548
+ }
549
+ return propertyValue ;
550
+ }
551
+
552
+ protected String getDescriptorProperty (String propertyName , String endpointId )
553
+ {
554
+ return getDescriptorProperty (propertyName , getEndpointDescriptor (endpointId ));
555
+ }
540
556
541
557
public String getEndpointId ()
542
558
{
0 commit comments