Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
0
  public void update(OAuthClientRepresentation rep, OAuthClientModel model) {
    if (rep.getName() != null) model.setClientId(rep.getName());
    if (rep.isEnabled() != null) model.setEnabled(rep.isEnabled());
    if (rep.isPublicClient() != null) model.setPublicClient(rep.isPublicClient());
    if (rep.getClaims() != null) {
      ClaimManager.setClaims(model, rep.getClaims());
    }
    if (rep.getNotBefore() != null) {
      model.setNotBefore(rep.getNotBefore());
    }
    if (rep.getSecret() != null) model.setSecret(rep.getSecret());
    List<String> redirectUris = rep.getRedirectUris();
    if (redirectUris != null) {
      model.setRedirectUris(new HashSet<String>(redirectUris));
    }

    List<String> webOrigins = rep.getWebOrigins();
    if (webOrigins != null) {
      model.setWebOrigins(new HashSet<String>(webOrigins));
    }

    if (rep.getClaims() != null) {
      ClaimManager.setClaims(model, rep.getClaims());
    }

    if (rep.getNotBefore() != null) {
      model.setNotBefore(rep.getNotBefore());
    }
  }
Exemplo n.º 4
0
 public OAuthClientModel create(OAuthClientRepresentation rep) {
   OAuthClientModel model = create(rep.getName());
   update(rep, model);
   return model;
 }