@Test public void loadClientByConsumerKeyMultipleCallbacks() { super.setResponseResource(new Resource[] { new ClassPathResource("janus/janus-response-consumerkey3-entityid.json"), new ClassPathResource("janus/janus-response-multiple-callback-metadata.json") }); OpenConextClientDetails result = (OpenConextClientDetails) service.loadClientByClientId("consumerkey3"); Set<String> registeredRedirectUris = result.getRegisteredRedirectUri(); assertEquals(2, registeredRedirectUris.size()); Iterator<String> iterator = registeredRedirectUris.iterator(); assertEquals("http: assertEquals("http: }
@Override @Cacheable(value = { "janus-meta-data" }) public ClientDetails loadClientByClientId(String consumerKey) throws OAuth2Exception { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, OAuth2Exception.create(OAuth2Exception.INVALID_CLIENT, null)); validateMetadata(consumerKey, metadata); final OpenConextClientDetails clientDetails = new OpenConextClientDetails(); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); clientDetails.setClientMetaData(clientMetaData); clientDetails.setClientSecret(metadata.getOauthConsumerSecret()); clientDetails.setClientId(metadata.getOauthConsumerKey()); clientDetails.setRegisteredRedirectUri(getCallbackUrlCollection(metadata)); clientDetails.setScope(Arrays.asList("read")); clientDetails.setAuthorizedGrantTypes(Arrays.asList("implicit", "authorization_code")); if (metadata.isTwoLeggedOauthAllowed()) { clientDetails.getAuthorizedGrantTypes().add("client_credentials"); } ArrayList<GrantedAuthority> authorities = new ArrayList<>(clientDetails.getAuthorities()); authorities.add(new SimpleGrantedAuthority("ROLE_USER")); clientDetails.setAuthorities(authorities); ClientMetaDataHolder.setClientMetaData(clientMetaData); return clientDetails; }
JanusClientDetailsService implements OpenConextClientDetailsService { @Override @Cacheable(value = { "janus-meta-data" }) public ClientDetails loadClientByClientId(String consumerKey) throws OAuth2Exception { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, OAuth2Exception.create(OAuth2Exception.INVALID_CLIENT, null)); validateMetadata(consumerKey, metadata); final OpenConextClientDetails clientDetails = new OpenConextClientDetails(); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); clientDetails.setClientMetaData(clientMetaData); clientDetails.setClientSecret(metadata.getOauthConsumerSecret()); clientDetails.setClientId(metadata.getOauthConsumerKey()); clientDetails.setRegisteredRedirectUri(getCallbackUrlCollection(metadata)); clientDetails.setScope(Arrays.asList("read")); clientDetails.setAuthorizedGrantTypes(Arrays.asList("implicit", "authorization_code")); if (metadata.isTwoLeggedOauthAllowed()) { clientDetails.getAuthorizedGrantTypes().add("client_credentials"); } ArrayList<GrantedAuthority> authorities = new ArrayList<>(clientDetails.getAuthorities()); authorities.add(new SimpleGrantedAuthority("ROLE_USER")); clientDetails.setAuthorities(authorities); ClientMetaDataHolder.setClientMetaData(clientMetaData); return clientDetails; } }
JanusClientDetailsService implements OpenConextClientDetailsService { @Override @Cacheable(value = { "janus-meta-data" }) public ClientDetails loadClientByClientId(String consumerKey) throws OAuth2Exception { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, OAuth2Exception.create(OAuth2Exception.INVALID_CLIENT, null)); validateMetadata(consumerKey, metadata); final OpenConextClientDetails clientDetails = new OpenConextClientDetails(); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); clientDetails.setClientMetaData(clientMetaData); clientDetails.setClientSecret(metadata.getOauthConsumerSecret()); clientDetails.setClientId(metadata.getOauthConsumerKey()); clientDetails.setRegisteredRedirectUri(getCallbackUrlCollection(metadata)); clientDetails.setScope(Arrays.asList("read")); clientDetails.setAuthorizedGrantTypes(Arrays.asList("implicit", "authorization_code")); if (metadata.isTwoLeggedOauthAllowed()) { clientDetails.getAuthorizedGrantTypes().add("client_credentials"); } ArrayList<GrantedAuthority> authorities = new ArrayList<>(clientDetails.getAuthorities()); authorities.add(new SimpleGrantedAuthority("ROLE_USER")); clientDetails.setAuthorities(authorities); ClientMetaDataHolder.setClientMetaData(clientMetaData); return clientDetails; }  }
JanusClientDetailsService implements OpenConextClientDetailsService { @Override @Cacheable(value = { "janus-meta-data" }) public ClientDetails loadClientByClientId(String consumerKey) throws OAuth2Exception { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, OAuth2Exception.create(OAuth2Exception.INVALID_CLIENT, null)); validateMetadata(consumerKey, metadata); final OpenConextClientDetails clientDetails = new OpenConextClientDetails(); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); clientDetails.setClientMetaData(clientMetaData); clientDetails.setClientSecret(metadata.getOauthConsumerSecret()); clientDetails.setClientId(metadata.getOauthConsumerKey()); clientDetails.setRegisteredRedirectUri(getCallbackUrlCollection(metadata)); clientDetails.setScope(Arrays.asList("read")); clientDetails.setAuthorizedGrantTypes(Arrays.asList("implicit", "authorization_code")); if (metadata.isTwoLeggedOauthAllowed()) { clientDetails.getAuthorizedGrantTypes().add("client_credentials"); } ArrayList<GrantedAuthority> authorities = new ArrayList<>(clientDetails.getAuthorities()); authorities.add(new SimpleGrantedAuthority("ROLE_USER")); clientDetails.setAuthorities(authorities); ClientMetaDataHolder.setClientMetaData(clientMetaData); return clientDetails; }  @Override @Cacheable(value = { "janus-meta-data" }) ClientDetails loadClientByClientId(String consumerKey); @Cacheable(value = { "janus-meta-data" }) ARP getArp(String clientId); @Override @Cacheable(value = { "janus-meta-data" }) ConsumerDetails loadConsumerByConsumerKey(String consumerKey); void setJanus(Janus janus); }
JanusClientDetailsService implements OpenConextClientDetailsService { @Override @Cacheable(value = { "janus-meta-data" }) public ClientDetails loadClientByClientId(String consumerKey) throws OAuth2Exception { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, OAuth2Exception.create(OAuth2Exception.INVALID_CLIENT, null)); validateMetadata(consumerKey, metadata); final OpenConextClientDetails clientDetails = new OpenConextClientDetails(); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); clientDetails.setClientMetaData(clientMetaData); clientDetails.setClientSecret(metadata.getOauthConsumerSecret()); clientDetails.setClientId(metadata.getOauthConsumerKey()); clientDetails.setRegisteredRedirectUri(getCallbackUrlCollection(metadata)); clientDetails.setScope(Arrays.asList("read")); clientDetails.setAuthorizedGrantTypes(Arrays.asList("implicit", "authorization_code")); if (metadata.isTwoLeggedOauthAllowed()) { clientDetails.getAuthorizedGrantTypes().add("client_credentials"); } ArrayList<GrantedAuthority> authorities = new ArrayList<>(clientDetails.getAuthorities()); authorities.add(new SimpleGrantedAuthority("ROLE_USER")); clientDetails.setAuthorities(authorities); ClientMetaDataHolder.setClientMetaData(clientMetaData); return clientDetails; }  @Override @Cacheable(value = { "janus-meta-data" }) ClientDetails loadClientByClientId(String consumerKey); @Cacheable(value = { "janus-meta-data" }) ARP getArp(String clientId); @Override @Cacheable(value = { "janus-meta-data" }) ConsumerDetails loadConsumerByConsumerKey(String consumerKey); void setJanus(Janus janus);  }