@Test public void loadConsumerByConsumerKeyHappy() { super.setResponseResource(new Resource[] { new ClassPathResource("janus/janus-response-consumerkey3-entityid.json"), new ClassPathResource("janus/janus-response-consumerkey3-metadata.json") }); OpenConextConsumerDetails result = (OpenConextConsumerDetails) service.loadConsumerByConsumerKey("consumerkey3"); assertEquals("service should return correct key", "consumerkey3", result.getConsumerKey()); assertEquals("service should return correct secret", "secret", ((SharedConsumerSecret) result.getSignatureSecret()).getConsumerSecret()); assertEquals("service should return whether client is required to authenticate (so two legged NOT allowed)", true, result.isRequiredToObtainAuthenticatedToken()); assertEquals("app-thumbnail", result.getClientMetaData().getAppThumbNail()); }
@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);  }