@Test public void loadConsumerByConsumerKeyNoSecretFound() { setResponseResource(new ClassPathResource("janus/janus-empty-result.json")); try { ConsumerDetails result = service.loadConsumerByConsumerKey("consumerkey"); fail("service should throw exception in case consumer key not found."); } catch (RuntimeException e) { } }
@Override @Cacheable(value = { "janus-meta-data" }) public ConsumerDetails loadConsumerByConsumerKey(String consumerKey) throws OAuthException { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, new OAuthException(OAuth2Exception.INVALID_CLIENT)); validateMetadata(consumerKey, metadata); final OpenConextConsumerDetails consumerDetails = new OpenConextConsumerDetails(); consumerDetails.setConsumerKey(consumerKey); consumerDetails.setAuthorities(Arrays.<GrantedAuthority> asList(new SimpleGrantedAuthority("ROLE_USER"))); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); consumerDetails.setClientMetaData(clientMetaData); ClientMetaDataHolder.setClientMetaData(clientMetaData); consumerDetails.setSignatureSecret(new SharedConsumerSecretImpl(metadata.getOauthConsumerSecret())); consumerDetails.setRequiredToObtainAuthenticatedToken(true); if (metadata.isTwoLeggedOauthAllowed()) { consumerDetails.setRequiredToObtainAuthenticatedToken(false); } return consumerDetails; }
JanusClientDetailsService implements OpenConextClientDetailsService { @Override @Cacheable(value = { "janus-meta-data" }) public ConsumerDetails loadConsumerByConsumerKey(String consumerKey) throws OAuthException { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, new OAuthException(OAuth2Exception.INVALID_CLIENT)); validateMetadata(consumerKey, metadata); final OpenConextConsumerDetails consumerDetails = new OpenConextConsumerDetails(); consumerDetails.setConsumerKey(consumerKey); consumerDetails.setAuthorities(Arrays.<GrantedAuthority> asList(new SimpleGrantedAuthority("ROLE_USER"))); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); consumerDetails.setClientMetaData(clientMetaData); ClientMetaDataHolder.setClientMetaData(clientMetaData); consumerDetails.setSignatureSecret(new SharedConsumerSecretImpl(metadata.getOauthConsumerSecret())); consumerDetails.setRequiredToObtainAuthenticatedToken(true); if (metadata.isTwoLeggedOauthAllowed()) { consumerDetails.setRequiredToObtainAuthenticatedToken(false); } return consumerDetails; } }
JanusClientDetailsService implements OpenConextClientDetailsService { @Override @Cacheable(value = { "janus-meta-data" }) public ConsumerDetails loadConsumerByConsumerKey(String consumerKey) throws OAuthException { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, new OAuthException(OAuth2Exception.INVALID_CLIENT)); validateMetadata(consumerKey, metadata); final OpenConextConsumerDetails consumerDetails = new OpenConextConsumerDetails(); consumerDetails.setConsumerKey(consumerKey); consumerDetails.setAuthorities(Arrays.<GrantedAuthority> asList(new SimpleGrantedAuthority("ROLE_USER"))); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); consumerDetails.setClientMetaData(clientMetaData); ClientMetaDataHolder.setClientMetaData(clientMetaData); consumerDetails.setSignatureSecret(new SharedConsumerSecretImpl(metadata.getOauthConsumerSecret())); consumerDetails.setRequiredToObtainAuthenticatedToken(true); if (metadata.isTwoLeggedOauthAllowed()) { consumerDetails.setRequiredToObtainAuthenticatedToken(false); } return consumerDetails; }  }
JanusClientDetailsService implements OpenConextClientDetailsService { @Override @Cacheable(value = { "janus-meta-data" }) public ConsumerDetails loadConsumerByConsumerKey(String consumerKey) throws OAuthException { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, new OAuthException(OAuth2Exception.INVALID_CLIENT)); validateMetadata(consumerKey, metadata); final OpenConextConsumerDetails consumerDetails = new OpenConextConsumerDetails(); consumerDetails.setConsumerKey(consumerKey); consumerDetails.setAuthorities(Arrays.<GrantedAuthority> asList(new SimpleGrantedAuthority("ROLE_USER"))); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); consumerDetails.setClientMetaData(clientMetaData); ClientMetaDataHolder.setClientMetaData(clientMetaData); consumerDetails.setSignatureSecret(new SharedConsumerSecretImpl(metadata.getOauthConsumerSecret())); consumerDetails.setRequiredToObtainAuthenticatedToken(true); if (metadata.isTwoLeggedOauthAllowed()) { consumerDetails.setRequiredToObtainAuthenticatedToken(false); } return consumerDetails; }  @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 ConsumerDetails loadConsumerByConsumerKey(String consumerKey) throws OAuthException { EntityMetadata metadata = getJanusMetadataByConsumerKey(consumerKey, new OAuthException(OAuth2Exception.INVALID_CLIENT)); validateMetadata(consumerKey, metadata); final OpenConextConsumerDetails consumerDetails = new OpenConextConsumerDetails(); consumerDetails.setConsumerKey(consumerKey); consumerDetails.setAuthorities(Arrays.<GrantedAuthority> asList(new SimpleGrantedAuthority("ROLE_USER"))); ClientMetaData clientMetaData = new JanusClientMetadata(metadata); consumerDetails.setClientMetaData(clientMetaData); ClientMetaDataHolder.setClientMetaData(clientMetaData); consumerDetails.setSignatureSecret(new SharedConsumerSecretImpl(metadata.getOauthConsumerSecret())); consumerDetails.setRequiredToObtainAuthenticatedToken(true); if (metadata.isTwoLeggedOauthAllowed()) { consumerDetails.setRequiredToObtainAuthenticatedToken(false); } return consumerDetails; }  @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);  }