Пример #1
0
  public static Client valueOf(OrcidClient orcidClient) {
    Client client = new Client();
    client.setClientId(Text.valueOf(orcidClient.getClientId()));
    client.setClientSecret(Text.valueOf(orcidClient.getClientSecret()));
    client.setDisplayName(Text.valueOf(orcidClient.getDisplayName()));
    client.setShortDescription(Text.valueOf(orcidClient.getShortDescription()));
    if (orcidClient.getType() != null) client.setType(Text.valueOf(orcidClient.getType().value()));
    client.setWebsite(Text.valueOf(orcidClient.getWebsite()));

    Checkbox persistentTokenEnabled = new Checkbox();
    persistentTokenEnabled.setValue(orcidClient.isPersistentTokenEnabled());
    client.setPersistentTokenEnabled(persistentTokenEnabled);

    List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
    RedirectUris orcidRedirectUris = orcidClient.getRedirectUris();
    if (orcidRedirectUris != null && orcidRedirectUris.getRedirectUri() != null) {
      for (org.orcid.jaxb.model.clientgroup.RedirectUri orcidRedirectUri :
          orcidRedirectUris.getRedirectUri()) {
        redirectUris.add(RedirectUri.toRedirectUri(orcidRedirectUri));
      }
    }

    client.setRedirectUris(redirectUris);

    return client;
  }
Пример #2
0
  public static Client valueOf(ClientDetailsEntity clientDetails) {
    Client client = new Client();
    if (clientDetails != null) {
      client.setClientId(Text.valueOf(clientDetails.getClientId()));
      client.setDisplayName(Text.valueOf(clientDetails.getClientName()));
      client.setShortDescription(Text.valueOf(clientDetails.getClientDescription()));
      client.setWebsite(Text.valueOf(clientDetails.getClientWebsite()));
      client.redirectUris = new ArrayList<RedirectUri>();
      if (clientDetails.getClientRegisteredRedirectUris() != null) {
        for (ClientRedirectUriEntity rUri : clientDetails.getClientRegisteredRedirectUris()) {
          client.redirectUris.add(RedirectUri.valueOf(rUri));
        }
      }

      client.persistentTokenEnabled = new Checkbox();
      client.persistentTokenEnabled.setValue(clientDetails.isPersistentTokensEnabled());
      client.setType(Text.valueOf(clientDetails.getClientType().value()));

      if (clientDetails.isScoped()) client.setScopes(clientDetails.getScope());

      client.setMemberId(Text.valueOf(clientDetails.getGroupProfileId()));
    }
    return client;
  }