@BeforeMethod
  @SuppressWarnings("unchecked")
  public void setup() throws Exception {

    dataStore = mock(TokenDataStore.class);
    OAuth2ProviderSettingsFactory providerSettingsFactory =
        mock(OAuth2ProviderSettingsFactory.class);
    OAuth2UrisFactory<RealmInfo> oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
    OAuth2Uris oAuth2Uris = mock(OAuth2Uris.class);
    TokenIdGenerator idGenerator = mock(TokenIdGenerator.class);

    store =
        new OpenAMResourceSetStore(
            "REALM", providerSettingsFactory, oAuth2UrisFactory, idGenerator, dataStore);

    given(oAuth2UrisFactory.get(Matchers.<OAuth2Request>anyObject())).willReturn(oAuth2Uris);
    given(oAuth2Uris.getResourceSetRegistrationPolicyEndpoint(anyString()))
        .willReturn("POLICY_URI");
  }
Esempio n. 2
0
 /**
  * Gets the instance of the UmaUris.
  *
  * <p>Cache each provider settings on the realm it was created for.
  *
  * @param request The request instance from which the base URL can be deduced.
  * @param realmInfo The realm.
  * @return The OAuth2ProviderSettings instance.
  */
 public UmaUris get(HttpServletRequest request, RealmInfo realmInfo) throws NotFoundException {
   synchronized (providerSettingsMap) {
     UmaUris providerSettings = providerSettingsMap.get(realmInfo);
     if (providerSettings == null) {
       UmaProviderSettings umaProviderSettings =
           umaProviderSettingsFactory.get(realmInfo.getAbsoluteRealm());
       OAuth2Uris oAuth2Uris = oAuth2UriFactory.get(request, realmInfo);
       String baseUrlPattern =
           baseURLProviderFactory.get(realmInfo.getAbsoluteRealm()).getURL(request);
       providerSettings =
           getUmaProviderSettings(realmInfo, umaProviderSettings, oAuth2Uris, baseUrlPattern);
     }
     return providerSettings;
   }
 }