Ejemplo n.º 1
0
  public static OAuthClientRepresentation toRepresentation(OAuthClientModel model) {
    OAuthClientRepresentation rep = new OAuthClientRepresentation();
    rep.setId(model.getId());
    rep.setName(model.getClientId());
    rep.setEnabled(model.isEnabled());
    rep.setPublicClient(model.isPublicClient());
    Set<String> redirectUris = model.getRedirectUris();
    if (redirectUris != null) {
      rep.setRedirectUris(new LinkedList<String>(redirectUris));
    }

    Set<String> webOrigins = model.getWebOrigins();
    if (webOrigins != null) {
      rep.setWebOrigins(new LinkedList<String>(webOrigins));
    }
    rep.setNotBefore(model.getNotBefore());
    return rep;
  }
Ejemplo n.º 2
0
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @NoCache
  public List<OAuthClientRepresentation> getOAuthClients() {
    List<OAuthClientRepresentation> rep = new ArrayList<OAuthClientRepresentation>();
    List<OAuthClientModel> oauthModels = realm.getOAuthClients();

    boolean view = auth.hasView();
    for (OAuthClientModel oauth : oauthModels) {
      if (view) {
        rep.add(OAuthClientManager.toRepresentation(oauth));
      } else {
        OAuthClientRepresentation client = new OAuthClientRepresentation();
        client.setName(oauth.getClientId());
        rep.add(client);
      }
    }
    return rep;
  }