@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(); }
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; }