Package org.mitre.oauth2.model

Examples of org.mitre.oauth2.model.OAuth2AccessTokenEntity


  public void deleteClient() {

    Long id = 12345L;
    String clientId = "b00g3r";

    ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class);
    Mockito.when(client.getId()).thenReturn(id);
    Mockito.when(client.getClientId()).thenReturn(clientId);

    Mockito.when(clientRepository.getById(id)).thenReturn(client);

    WhitelistedSite site = Mockito.mock(WhitelistedSite.class);
    Mockito.when(whitelistedSiteService.getByClientId(clientId)).thenReturn(site);
View Full Code Here


  }

  @Test
  public void updateClient_nullClients() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    try {
      service.updateClient(oldClient, null);
      fail("New client is null. Expected an IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void updateClient_blacklistedUri() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    String badSite = "badsite.xxx";

    Mockito.when(newClient.getRegisteredRedirectUri()).thenReturn(Sets.newHashSet(badSite));
    Mockito.when(blacklistedSiteService.isBlacklisted(badSite)).thenReturn(true);

    service.updateClient(oldClient, newClient);
  }
View Full Code Here

  }

  @Test
  public void updateClient_yesOfflineAccess() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    Mockito.when(newClient.isAllowRefresh()).thenReturn(true);

    // scopes returned by client entities are Strings
    @SuppressWarnings("unchecked")
    Set<String> scopes = Mockito.mock(Set.class);

    Mockito.when(newClient.getScope()).thenReturn(scopes);

    service.updateClient(oldClient, newClient);

    Mockito.verify(scopes).add(SystemScopeService.OFFLINE_ACCESS);
  }
View Full Code Here

  }

  @Test
  public void updateClient_noOfflineAccess() {

    ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class);
    ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class);

    Mockito.when(newClient.isAllowRefresh()).thenReturn(false);

    // scopes returned by client entities are Strings
    @SuppressWarnings("unchecked")
    Set<String> scopes = Mockito.mock(Set.class);

    Mockito.when(newClient.getScope()).thenReturn(scopes);

    service.updateClient(oldClient, newClient);

    Mockito.verify(scopes).remove(SystemScopeService.OFFLINE_ACCESS);
  }
View Full Code Here

  }

  @Override
  public UserInfo getByUsernameAndClientId(String username, String clientId) {

    ClientDetailsEntity client = clientService.loadClientByClientId(clientId);

    UserInfo userInfo = getByUsername(username);

    if (client == null || userInfo == null) {
      return null;
    }

    if (SubjectType.PAIRWISE.equals(client.getSubjectType())) {
      String pairwiseSub = pairwiseIdentifierService.getIdentifier(userInfo, client);
      userInfo.setSub(pairwiseSub);
    }

    return userInfo;
View Full Code Here

  }

  @Override
  @Transactional
  public void removeAccessToken(OAuth2AccessTokenEntity accessToken) {
    OAuth2AccessTokenEntity found = getAccessTokenByValue(accessToken.getValue());
    if (found != null) {
      manager.remove(found);
    } else {
      throw new IllegalArgumentException("Access token not found: " + accessToken);
    }
View Full Code Here

      // now save it
      try {
        ClientDetailsEntity savedClient = clientService.saveNewClient(newClient);

        // generate the registration access token
        OAuth2AccessTokenEntity token = connectTokenService.createResourceAccessToken(savedClient);
        tokenService.saveAccessToken(token);

        // send it all out to the view

        RegisteredClient registered = new RegisteredClient(savedClient, token.getValue(), config.getIssuer() + "resource/" + UriUtils.encodePathSegment(savedClient.getClientId(), "UTF-8"));
        m.addAttribute("client", registered);
        m.addAttribute("code", HttpStatus.CREATED); // http 201

        return ClientInformationResponseView.VIEWNAME;
      } catch (UnsupportedEncodingException e) {
View Full Code Here



      try {
        // possibly update the token
        OAuth2AccessTokenEntity token = fetchValidRegistrationToken(auth, client);

        RegisteredClient registered = new RegisteredClient(client, token.getValue(), config.getIssuer() + "resource/" +  UriUtils.encodePathSegment(client.getClientId(), "UTF-8"));

        // send it all out to the view
        m.addAttribute("client", registered);
        m.addAttribute("code", HttpStatus.OK); // http 200
View Full Code Here

      try {
        // save the client
        ClientDetailsEntity savedClient = clientService.updateClient(oldClient, newClient);

        // possibly update the token
        OAuth2AccessTokenEntity token = fetchValidRegistrationToken(auth, savedClient);

        RegisteredClient registered = new RegisteredClient(savedClient, token.getValue(), config.getIssuer() + "resource/" + UriUtils.encodePathSegment(savedClient.getClientId(), "UTF-8"));

        // send it all out to the view
        m.addAttribute("client", registered);
        m.addAttribute("code", HttpStatus.OK); // http 200
View Full Code Here

TOP

Related Classes of org.mitre.oauth2.model.OAuth2AccessTokenEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.