Returns information for a specific client

@param model
@param profileIdentifier
@param clientUUID
@return
@throws Exception
197697
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.GET)
    public
    @ResponseBody
    HashMap<String, Object> getClient(Model model,
                                      @PathVariable("profileIdentifier") String profileIdentifier,
                                      @PathVariable("clientUUID") String clientUUID) throws Exception {
        Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier);
        HashMap<String, Object> valueHash = new HashMap<String, Object>();
        valueHash.put("client", clientService.findClient(clientUUID, profileId));
        return valueHash;
    }
128966
def _get_client(profile):
    '''
    
    '''
    token = _get_config_value(profile, 'token')
    key = 'github.{0}:{1}'.format(
        token,
        _get_config_value(profile, 'org_name')
    )

    if key not in __context__:
        __context__[key] = github.Github(
            token,
            per_page=100
        )
    return __context__[key]
1301260
public static Integer convertProfileIdentifier(String profileIdentifier) throws Exception {
        Integer profileId = -1;
        if (profileIdentifier == null) {
            throw new Exception("A profileIdentifier must be specified");
        } else {
            try {
                profileId = Integer.parseInt(profileIdentifier);
            } catch (NumberFormatException ne) {
                // this is OK.. just means it's not a #
                // try to get it by name instead
                profileId = ProfileService.getInstance().getIdFromName(profileIdentifier);

            }
        }
        logger.info("Profile id is {}", profileId);
        return profileId;
    }
198304
public static boolean setCustomResponseForDefaultClient(String profileName, String pathName, String customData) {
        try {
            return setCustomForDefaultClient(profileName, pathName, true, customData);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
598857
@RequestMapping(value = "api/edit/disable", method = RequestMethod.POST)
    public
    @ResponseBody
    String disableResponses(Model model, int path_id, @RequestParam(defaultValue = Constants.PROFILE_CLIENT_DEFAULT_ID) String clientUUID) throws Exception {
        OverrideService.getInstance().disableAllOverrides(path_id, clientUUID);
        //TODO also need to disable custom override if there is one of those
        editService.removeCustomOverride(path_id, clientUUID);

        return null;
    }
663179
@RequestMapping(value = "api/edit/server", method = RequestMethod.GET)
    public
    @ResponseBody
    HashMap<String, Object> getjqRedirects(Model model,
                                           @RequestParam(value = "profileId", required = false) Integer profileId,
                                           @RequestParam(value = "clientUUID", required = true) String clientUUID,
                                           @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception {
        if (profileId == null && profileIdentifier == null) {
            throw new Exception("profileId required");
        }
        if (profileId == null) {
            profileId = ProfileService.getInstance().getIdFromName(profileIdentifier);
        }
        int clientId = ClientService.getInstance().findClient(clientUUID, profileId).getId();

        HashMap<String, Object> returnJson = Utils.getJQGridJSON(ServerRedirectService.getInstance().tableServers(clientId), "servers");
        returnJson.put("hostEditor", Client.isAvailable());
        return returnJson;
    }
934204
public int getHistoryCount(int profileId, String clientUUID, HashMap<String, String[]> searchFilter) {
        int count = 0;
        Statement query = null;
        ResultSet results = null;

        try (Connection sqlConnection = sqlService.getConnection()) {

            String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " ";

            // see if profileId is set or not (-1)
            if (profileId != -1) {
                sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " ";
            }

            if (clientUUID != null && clientUUID.compareTo("") != 0) {
                sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' ";
            }

            sqlQuery += ";";

            logger.info("Query: {}", sqlQuery);

            query = sqlConnection.createStatement();
            results = query.executeQuery(sqlQuery);
            if (results.next()) {
                count = results.getInt(1);
            }
            query.close();
        } catch (Exception e) {

        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (query != null) {
                    query.close();
                }
            } catch (Exception e) {
            }
        }

        return count;
    }
1043280
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/delete", method = RequestMethod.POST)
    public
    @ResponseBody
    HashMap<String, Object> deleteClient(Model model,
                                         @RequestParam("profileIdentifier") String profileIdentifier,
                                         @RequestParam("clientUUID") String[] clientUUID) throws Exception {

        logger.info("Attempting to remove clients from the profile: ", profileIdentifier);
        logger.info("Attempting to remove the following clients: {}", Arrays.toString(clientUUID));

        HashMap<String, Object> valueHash = new HashMap<String, Object>();
        Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier);

        for( int i = 0; i < clientUUID.length; i++ )
        {
            if (clientUUID[i].compareTo(Constants.PROFILE_CLIENT_DEFAULT_ID) == 0)
                throw new Exception("Default client cannot be deleted");

            clientService.remove(profileId, clientUUID[i]);
        }

        valueHash.put("clients", clientService.findAllClients(profileId));
        return valueHash;
    }
94372
@RequestMapping(value = "/profile", method = RequestMethod.GET)
    public String get(Authentication authentication, Model model) {
        Map<String, List<DescribedApproval>> approvals = getCurrentApprovalsForUser(getCurrentUserId());
        Map<String, String> clientNames = getClientNames(approvals);
        model.addAttribute("clientnames", clientNames);
        model.addAttribute("approvals", approvals);
        model.addAttribute("isUaaManagedUser", isUaaManagedUser(authentication));
        return "approvals";
    }
458745
public String getProfileIdFromClientId(int id) {
        return (String) sqlService.getFromTable(Constants.CLIENT_PROFILE_ID, Constants.GENERIC_ID, id, Constants.DB_TABLE_CLIENT);
    }
1159348
public void fetchMetadata(final String uuid,
                              final DataSetMetadataCallback listener) throws Exception {
        final DataSetMetadata metadata = clientDataSetManager.getDataSetMetadata(uuid);

        if (metadata != null) {
            listener.callback(metadata);
        } else if (dataSetLookupServices != null) {
            if (remoteMetadataMap.containsKey(uuid)) {
                listener.callback(remoteMetadataMap.get(uuid));
            } else {
                dataSetLookupServices.call((DataSetMetadata result) -> {
                                               if (result == null) {
                                                   listener.notFound();
                                               } else {
                                                   remoteMetadataMap.put(uuid,
                                                                         result);
                                                   listener.callback(result);
                                               }
                                           },
                                           (message, throwable) -> {
                                               return listener.onError(new ClientRuntimeError(throwable));
                                           }).lookupDataSetMetadata(uuid);
            }
        } else {
            listener.notFound();
        }
    }
823820
@SneakyThrows
    public static OidcClientRegistrationResponse getClientRegistrationResponse(final OidcRegisteredService registeredService,
                                                                               final String serverPrefix) {
        val clientResponse = new OidcClientRegistrationResponse();
        clientResponse.setApplicationType(registeredService.getApplicationType());
        clientResponse.setClientId(registeredService.getClientId());
        clientResponse.setClientSecret(registeredService.getClientSecret());
        clientResponse.setSubjectType(registeredService.getSubjectType());
        clientResponse.setTokenEndpointAuthMethod(registeredService.getTokenEndpointAuthenticationMethod());
        clientResponse.setClientName(registeredService.getName());
        clientResponse.setRedirectUris(CollectionUtils.wrap(registeredService.getServiceId()));
        clientResponse.setContacts(
            registeredService.getContacts()
                .stream()
                .map(RegisteredServiceContact::getName)
                .filter(StringUtils::isNotBlank)
                .collect(Collectors.toList())
        );
        clientResponse.setGrantTypes(
            Arrays.stream(OAuth20GrantTypes.values())
                .map(type -> type.getType().toLowerCase())
                .collect(Collectors.toList()));

        clientResponse.setResponseTypes(
            Arrays.stream(OAuth20ResponseTypes.values())
                .map(type -> type.getType().toLowerCase())
                .collect(Collectors.toList()));

        val validator = new SimpleUrlValidatorFactoryBean(false).getObject();
        if (Objects.requireNonNull(validator).isValid(registeredService.getJwks())) {
            clientResponse.setJwksUri(registeredService.getJwks());
        } else {
            val jwks = new JsonWebKeySet(registeredService.getJwks());
            clientResponse.setJwks(jwks.toJson());
        }
        clientResponse.setLogo(registeredService.getLogo());
        clientResponse.setPolicyUri(registeredService.getInformationUrl());
        clientResponse.setTermsOfUseUri(registeredService.getPrivacyUrl());
        clientResponse.setRedirectUris(CollectionUtils.wrapList(registeredService.getServiceId()));
        val clientConfigUri = getClientConfigurationUri(registeredService, serverPrefix);
        clientResponse.setRegistrationClientUri(clientConfigUri);
        return clientResponse;
    }
34457
@RequestMapping(value = "/api/profile", method = RequestMethod.POST)
    public
    @ResponseBody
    HashMap<String, Object> addProfile(Model model, String name) throws Exception {
        logger.info("Should be adding the profile name when I hit the enter button={}", name);
        return Utils.getJQGridJSON(profileService.add(name), "profile");
    }
508407
public static Profile findProfile(Model mavenModel, String profileId) {
        List<Profile> profiles = mavenModel.getProfiles();
        if (profiles != null) {
            for (Profile profile : profiles) {
                if (Objects.equal(profile.getId(), profileId)) {
                    return profile;
                }
            }
        }
        return null;
    }
776497
private UserProfile readProfile(Session session, String userName) throws Exception
   {
      Node profileNode;
      try
      {
         profileNode = utils.getProfileNode(session, userName);
      }
      catch (PathNotFoundException e)
      {
         return null;
      }

      return readProfile(userName, profileNode);
   }
176741
protected ProfileRequestContext<?, ?> getProfileRequestContext(HttpServletRequest httpRequest) throws ExternalAuthenticationException {
    return ExternalAuthentication.getProfileRequestContext(this.getExternalAuthenticationKey(httpRequest), httpRequest);
  }
1246180
public Client findClient(String clientUUID, Integer profileId) throws Exception {
        Client client = null;
        /* ERROR CODE: 500 WHEN TRYING TO DELETE A SERVER GROUP.
            THIS APPEARS TO BE BECAUSE CLIENT UUID IS NULL.
         */
        /* CODE ADDED TO PREVENT NULL POINTERS. */
        if (clientUUID == null) {
            clientUUID = "";
        }

        // first see if the clientUUID is actually a uuid.. it might be a friendlyName and need conversion
        /* A UUID IS A UNIVERSALLY UNIQUE IDENTIFIER. */
        if (clientUUID.compareTo(Constants.PROFILE_CLIENT_DEFAULT_ID) != 0 &&
            !clientUUID.matches("[\\w]{8}-[\\w]{4}-[\\w]{4}-[\\w]{4}-[\\w]{12}")) {
            Client tmpClient = this.findClientFromFriendlyName(profileId, clientUUID);

            // if we can't find a client then fall back to the default ID
            if (tmpClient == null) {
                clientUUID = Constants.PROFILE_CLIENT_DEFAULT_ID;
            } else {
                return tmpClient;
            }
        }

        PreparedStatement statement = null;
        ResultSet results = null;
        try (Connection sqlConnection = sqlService.getConnection()) {
            String queryString = "SELECT * FROM " + Constants.DB_TABLE_CLIENT +
                " WHERE " + Constants.CLIENT_CLIENT_UUID + " = ?";

            if (profileId != null) {
                queryString += " AND " + Constants.GENERIC_PROFILE_ID + "=?";
            }

            statement = sqlConnection.prepareStatement(queryString);
            statement.setString(1, clientUUID);

            if (profileId != null) {
                statement.setInt(2, profileId);
            }

            results = statement.executeQuery();
            if (results.next()) {
                client = this.getClientFromResultSet(results);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        return client;
    }