Exemplo n.º 1
0
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  public Response createOAuthClient(
      final @Context UriInfo uriInfo, final OAuthClientRepresentation rep) {
    auth.requireManage();

    OAuthClientManager resourceManager = new OAuthClientManager(realm);
    OAuthClientModel oauth = resourceManager.create(rep);
    return Response.created(uriInfo.getAbsolutePathBuilder().path(oauth.getId()).build()).build();
  }
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;
  }