Refine search
/** * Derives member's name and type from it's annotations */ public static Optional<String> getParameterNameFromAnnotations(Annotation[] memberAnnotations) { for (Annotation a : memberAnnotations) { if (a instanceof QueryParam) { return Optional.of("query param " + ((QueryParam) a).value()); } else if (a instanceof PathParam) { return Optional.of("path param " + ((PathParam) a).value()); } else if (a instanceof HeaderParam) { return Optional.of("header " + ((HeaderParam) a).value()); } else if (a instanceof CookieParam) { return Optional.of("cookie " + ((CookieParam) a).value()); } else if (a instanceof FormParam) { return Optional.of("form field " + ((FormParam) a).value()); } else if (a instanceof Context) { return Optional.of("context"); } else if (a instanceof MatrixParam) { return Optional.of("matrix param " + ((MatrixParam) a).value()); } } return Optional.empty(); }
@Override public List<User> getUsers(@CookieParam("uid") int uid) { return Arrays.asList(new User(uid, "name" + uid)); }
@PUT @Path("/{id}") void dummy( @PathParam("id") int id, @QueryParam("mode") String mode, @CookieParam("registrations") List<Cookie> registrations, @HeaderParam("year") @DateFormat("YYYY") Date expectedYear, int count); }
@GET @Path("/redirect") public Response getBookRedirect(@QueryParam("redirect") Boolean done, @QueryParam("sameuri") Boolean sameuri, @CookieParam("a") String cookie) { if (done == null) { String uri = sameuri.equals(Boolean.TRUE) ? ui.getAbsolutePathBuilder().queryParam("redirect", "true").build().toString() : "http://otherhost/redirect"; return Response.status(303).cookie(NewCookie.valueOf("a=b")).header("Location", uri).build(); } return Response.ok(new Book("CXF", 123L), "application/xml") .header("RequestURI", this.ui.getRequestUri().toString()) .header("TheCookie", cookie) .build(); }
@POST @Path("/sign-in") @Produces(MediaType.TEXT_HTML) public Response signIn(@FormParam("username") String username, @FormParam("password") String password, @CookieParam(SessionStore.SESSION_COOKIE_NAME) String sessionId) throws Exception { Account account = execContext.getAccountStore().getByEmail(username); if (account == null || EqualsUtils.objectsNotEqual(account.getPassword(), password)) { execContext.getSessionStore().remove(sessionId); NewCookie sessionCookie = SessionStore.toCookie(getUriInfo(), null); URI other = getUriInfo().getBaseUriBuilder().queryParam("r", REASON_CODE_INVALID_USERNAME_OR_PASSWORD).build(); return Response.seeOther(other).cookie(sessionCookie).build(); } Session session = execContext.getSessionStore().newSession(username); NewCookie sessionCookie = SessionStore.toCookie(getUriInfo(), session); URI other = getUriInfo().getBaseUriBuilder().path("manage").build(); return Response.seeOther(other).cookie(sessionCookie).build(); }
@Override public String getValueOf(CookieParam a) { return a.value(); }
@POST @Path("/subresource2/{n1:.*}") @Consumes("text/plain") @Produces("application/xml") Book getTheBook2(@PathParam("n1") String name1, @QueryParam("n2") String name2, @MatrixParam("n3") String name3, @MatrixParam("n33") String name33, @HeaderParam("N4") String name4, @CookieParam("n5") String name5, String name6) throws BookNotFoundFault;
@POST @Path("/sign-in") @Produces(MediaType.TEXT_HTML) public Response signIn(@FormParam("username") String username, @FormParam("password") String password, @CookieParam(SessionStore.SESSION_COOKIE_NAME) String sessionId) throws Exception { Account account = execContext.getAccountStore().getByEmail(username); if (account == null || EqualsUtils.objectsNotEqual(account.getPassword(), password)) { execContext.getSessionStore().remove(sessionId); NewCookie sessionCookie = SessionStore.toCookie(getUriInfo(), null); URI other = getUriInfo().getBaseUriBuilder().queryParam("r", REASON_CODE_INVALID_USERNAME_OR_PASSWORD).build(); return Response.seeOther(other).cookie(sessionCookie).build(); } Session session = execContext.getSessionStore().newSession(username); NewCookie sessionCookie = SessionStore.toCookie(getUriInfo(), session); URI other = getUriInfo().getBaseUriBuilder().path("manage").build(); return Response.seeOther(other).cookie(sessionCookie).build(); }
@Override public String getValueOf(CookieParam a) { return a.value(); }
@CookieParam(HttpRequest.SID) String sessionid, //gets HttpCookie.getValue() @CookieParam(HttpRequest.SID) HttpCookie sessionidAsCookie, //gets HttpCookie @valid @FormParam("textline") String text, @valid @FormParam("text2") RequiredParam<String> text2, @HeaderParam("Connection") String keepAlive, @PathParam("string") String random, @PathParam("num") int integer, @PathParam("num-doesn't-exist") int integerPrimitive, @PathParam("some-random-name") Integer randomInt, @QueryParam("a") String a, @valid @SessionParam("user_id") String user_id,
newTarget = newTarget.resolveTemplate(((PathParam) ann).value(), value); } else if ((ann = anns.get((QueryParam.class))) != null) { if (value instanceof Collection) { newTarget = newTarget.queryParam(((QueryParam) ann).value(), convert((Collection) value)); } else { newTarget = newTarget.queryParam(((QueryParam) ann).value(), value); headers.addAll(((HeaderParam) ann).value(), convert((Collection) value)); } else { headers.addAll(((HeaderParam) ann).value(), value); final String name = ((CookieParam) ann).value(); Cookie c; if (value instanceof Collection) { newTarget = newTarget.matrixParam(((MatrixParam) ann).value(), convert((Collection) value)); } else { newTarget = newTarget.matrixParam(((MatrixParam) ann).value(), value); form.param(((FormParam) ann).value(), v.toString()); form.param(((FormParam) ann).value(), value.toString());
@Override public String getValueOf(CookieParam a) { return a.value(); }
@GET public String echoCookie(@CookieParam("my-cookie") String cookie) { return cookie; }
Parameter qp = new Parameter(); qp.setIn(QUERY_PARAM); qp.setName(param.value()); parameter = qp; } else if (annotation instanceof PathParam) { Parameter pp = new Parameter(); pp.setIn(PATH_PARAM); pp.setName(param.value()); parameter = pp; } else if (annotation instanceof MatrixParam) { pp.setIn(PATH_PARAM); pp.setStyle(Parameter.StyleEnum.MATRIX); pp.setName(param.value()); parameter = pp; } else if (annotation instanceof HeaderParam) { Parameter pp = new Parameter(); pp.setIn(COOKIE_PARAM); pp.setName(param.value()); parameter = pp; } else if (annotation instanceof io.swagger.v3.oas.annotations.Parameter) {
@Override public String getAnnotationParameterName(Object annotation) { return ((CookieParam) annotation).value(); }
public abstract class RestService { protected final transient Logger logger = LoggerFactory.getLogger(getClass()); @CookieParam(bg_cookie) protected Cookie bgAuth; @Inject protected RepositoryProvider repos; protected String getClientId() { return bgAuth.getValue(); } protected SchemaRepository getRepository() { if (repos == null) { logger.warn("getRepository; service is not yet initialized: RepositoryProvider is null"); return null; } String clientId = getClientId(); SchemaRepository repo = repos.getRepository(clientId); if (repo == null) { logger.warn("getRepository; Repository is not active for client {}", clientId); } return repo; } }
public static String retrieveVisibleParamName(Annotation annotation) { if (CookieParam.class.isInstance(annotation)) { return ((CookieParam) annotation).value(); return ((FormParam) annotation).value(); return ((HeaderParam) annotation).value(); return ((PathParam) annotation).value(); return ((QueryParam) annotation).value();
@Override public String getValueOf(CookieParam a) { return a.value(); }
@POST @Produces("text/html") public LogoutResponse postLogout(@CookieParam(SSOConstants.SECURITY_CONTEXT_TOKEN) Cookie context, @Context SecurityContext sc) { return logout(context, sc); }
.value()); } else if ((header = FindAnnotation.findAnnotation(annotations, HeaderParam.class)) != null) header.value()); } else if ((cookie = FindAnnotation.findAnnotation(annotations, CookieParam.class)) != null) cookie.value()); } else if ((uriParam = FindAnnotation.findAnnotation(annotations, PathParam.class)) != null) uriParam.value()); } else if ((matrix = FindAnnotation.findAnnotation(annotations, MatrixParam.class)) != null) matrix.value()); } else if ((formParam = FindAnnotation.findAnnotation(annotations, FormParam.class)) != null) formParam.value()); this.wantsForm = true; } else if ((form = FindAnnotation.findAnnotation(annotations, Form.class)) != null)