Package org.mitre.openid.connect.model

Examples of org.mitre.openid.connect.model.WhitelistedSite


     * @throws IOException
     */
    private void readWhitelistedSites(JsonReader reader) throws IOException {
        reader.beginArray();
        while (reader.hasNext()) {
            WhitelistedSite wlSite = new WhitelistedSite();
            Long currentId = null;
            reader.beginObject();
            while (reader.hasNext()) {
                switch (reader.peek()) {
                    case END_OBJECT:
                        continue;
                    case NAME:
                        String name = reader.nextName();
                        if (name.equals("id")) {
                            currentId = reader.nextLong();
                        } else if (name.equals("clientId")) {
                            wlSite.setClientId(reader.nextString());
                        } else if (name.equals("creatorUserId")) {
                            wlSite.setCreatorUserId(reader.nextString());
                        } else if (name.equals("allowedScopes")) {
                            Set<String> allowedScopes = readSet(reader);
                            wlSite.setAllowedScopes(allowedScopes);
                        } else {
                            logger.debug("Found unexpected entry");
                            reader.skipValue();
                        }
                        break;
View Full Code Here


        }
        accessTokenToIdTokenRefs.clear();
        for (Long oldGrantId : grantToWhitelistedSiteRefs.keySet()) {
            Long oldWhitelistedSiteId = grantToWhitelistedSiteRefs.get(oldGrantId);
            Long newWhitelistedSiteId = whitelistedSiteOldToNewIdMap.get(oldWhitelistedSiteId);
            WhitelistedSite wlSite = wlSiteRepository.getById(newWhitelistedSiteId);
            Long newGrantId = grantOldToNewIdMap.get(oldGrantId);
            ApprovedSite approvedSite = approvedSiteRepository.getById(newGrantId);
            approvedSite.setWhitelistedSite(wlSite);
            approvedSiteRepository.save(approvedSite);
        }
View Full Code Here

  }

  @Override
  @Transactional
  public void remove(WhitelistedSite whitelistedSite) {
    WhitelistedSite found = manager.find(WhitelistedSite.class, whitelistedSite.getId());

    if (found != null) {
      manager.remove(found);
    } else {
      throw new IllegalArgumentException();
View Full Code Here

    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);

    service.deleteClient(client);

    Mockito.verify(tokenRepository).clearTokensForClient(client);
View Full Code Here

  @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
  public String addNewWhitelistedSite(@RequestBody String jsonString, ModelMap m, Principal p) {

    JsonObject json;

    WhitelistedSite whitelist = null;
    try {
      json = parser.parse(jsonString).getAsJsonObject();
      whitelist = gson.fromJson(json, WhitelistedSite.class);

    } catch (JsonParseException e) {
      logger.error("addNewWhitelistedSite failed due to JsonParseException", e);
      m.addAttribute("code", HttpStatus.BAD_REQUEST);
      m.addAttribute("errorMessage", "Could not save new whitelisted site. The server encountered a JSON syntax exception. Contact a system administrator for assistance.");
      return JsonErrorView.VIEWNAME;
    } catch (IllegalStateException e) {
      logger.error("addNewWhitelistedSite failed due to IllegalStateException", e);
      m.addAttribute("code", HttpStatus.BAD_REQUEST);
      m.addAttribute("errorMessage", "Could not save new whitelisted site. The server encountered an IllegalStateException. Refresh and try again - if the problem persists, contact a system administrator for assistance.");
      return JsonErrorView.VIEWNAME;
    }

    // save the id of the person who created this
    whitelist.setCreatorUserId(p.getName());

    WhitelistedSite newWhitelist = whitelistService.saveNew(whitelist);

    m.put("entity", newWhitelist);

    return JsonEntityView.VIEWNAME;
View Full Code Here

  @RequestMapping(value="/{id}", method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
  public String updateWhitelistedSite(@PathVariable("id") Long id, @RequestBody String jsonString, ModelMap m, Principal p) {

    JsonObject json;

    WhitelistedSite whitelist = null;
    try {
      json = parser.parse(jsonString).getAsJsonObject();
      whitelist = gson.fromJson(json, WhitelistedSite.class);

    } catch (JsonParseException e) {
      logger.error("updateWhitelistedSite failed due to JsonParseException", e);
      m.put("code", HttpStatus.BAD_REQUEST);
      m.put("errorMessage", "Could not update whitelisted site. The server encountered a JSON syntax exception. Contact a system administrator for assistance.");
      return JsonErrorView.VIEWNAME;
    } catch (IllegalStateException e) {
      logger.error("updateWhitelistedSite failed due to IllegalStateException", e);
      m.put("code", HttpStatus.BAD_REQUEST);
      m.put("errorMessage", "Could not update whitelisted site. The server encountered an IllegalStateException. Refresh and try again - if the problem persists, contact a system administrator for assistance.");
      return JsonErrorView.VIEWNAME;
    }

    WhitelistedSite oldWhitelist = whitelistService.getById(id);

    if (oldWhitelist == null) {
      logger.error("updateWhitelistedSite failed; whitelist with id " + id + " could not be found.");
      m.put("code", HttpStatus.NOT_FOUND);
      m.put("errorMessage", "Could not update whitelisted site. The requested whitelisted site with id " + id + "could not be found.");
      return JsonErrorView.VIEWNAME;
    } else {

      WhitelistedSite newWhitelist = whitelistService.update(oldWhitelist, whitelist);

      m.put("entity", newWhitelist);

      return JsonEntityView.VIEWNAME;
    }
View Full Code Here

   *
   */
  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @RequestMapping(value="/{id}", method = RequestMethod.DELETE)
  public String deleteWhitelistedSite(@PathVariable("id") Long id, ModelMap m) {
    WhitelistedSite whitelist = whitelistService.getById(id);

    if (whitelist == null) {
      logger.error("deleteWhitelistedSite failed; whitelist with id " + id + " could not be found.");
      m.put("code", HttpStatus.NOT_FOUND);
      m.put("errorMessage", "Could not delete whitelisted site. The requested whitelisted site with id " + id + "could not be found.");
View Full Code Here

  /**
   * Get a single whitelisted site
   */
  @RequestMapping(value="/{id}", method = RequestMethod.GET, produces = "application/json")
  public String getWhitelistedSite(@PathVariable("id") Long id, ModelMap m) {
    WhitelistedSite whitelist = whitelistService.getById(id);
    if (whitelist == null) {
      logger.error("getWhitelistedSite failed; whitelist with id " + id + " could not be found.");
      m.put("code", HttpStatus.NOT_FOUND);
      m.put("errorMessage", "The requested whitelisted site with id " + id + "could not be found.");
      return JsonErrorView.VIEWNAME;
View Full Code Here

     * @throws IOException
     */
    private void readWhitelistedSites(JsonReader reader) throws IOException {
        reader.beginArray();
        while (reader.hasNext()) {
            WhitelistedSite wlSite = new WhitelistedSite();
            Long currentId = null;
            reader.beginObject();
            while (reader.hasNext()) {
                switch (reader.peek()) {
                    case END_OBJECT:
                        continue;
                    case NAME:
                        String name = reader.nextName();
                        if (name.equals("id")) {
                            currentId = reader.nextLong();
                        } else if (name.equals("clientId")) {
                            wlSite.setClientId(reader.nextString());
                        } else if (name.equals("creatorUserId")) {
                            wlSite.setCreatorUserId(reader.nextString());
                        } else if (name.equals("allowedScopes")) {
                            Set<String> allowedScopes = readSet(reader);
                            wlSite.setAllowedScopes(allowedScopes);
                        } else {
                            logger.debug("Found unexpected entry");
                            reader.skipValue();
                        }
                        break;
View Full Code Here

        }
        accessTokenToIdTokenRefs.clear();
        for (Long oldGrantId : grantToWhitelistedSiteRefs.keySet()) {
            Long oldWhitelistedSiteId = grantToWhitelistedSiteRefs.get(oldGrantId);
            Long newWhitelistedSiteId = whitelistedSiteOldToNewIdMap.get(oldWhitelistedSiteId);
            WhitelistedSite wlSite = wlSiteRepository.getById(newWhitelistedSiteId);
            Long newGrantId = grantOldToNewIdMap.get(oldGrantId);
            ApprovedSite approvedSite = approvedSiteRepository.getById(newGrantId);
            approvedSite.setWhitelistedSite(wlSite);
            approvedSiteRepository.save(approvedSite);
        }
View Full Code Here

TOP

Related Classes of org.mitre.openid.connect.model.WhitelistedSite

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.