Java 类javax.ws.rs.FormParam 实例源码

项目:wechat-mall    文件:IndexResource.java   
@POST
@Path("register")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String register(@FormParam("userName") String userName,
        @FormParam("password") String password,
        @FormParam("phone") Long phone, @FormParam("email") String email,
        @FormParam("nick") String nick, @FormParam("addr") String addr,
        @FormParam("gender") String gender) {
    // check not null
    User u = new User();// dao 应该查询
    u.setAddr(addr);
    u.setEmail(email);
    u.setGender(gender);
    u.setNick(nick);
    u.setPassword(password);
    u.setPhone(phone);
    u.setUsername(userName);
    return JsonUtil.bean2Json(u);
}
项目:redpipe    文件:WikiResource.java   
@Path("/save")
@POST
public Single<Response> save(@FormParam("id") String id,
        @FormParam("title") String title,
        @FormParam("markdown") String markdown,
        @FormParam("newPage") String newPage){
    return fiber(() -> {
        boolean isNewPage = "yes".equals(newPage);
        String requiredPermission = isNewPage ? "create" : "update";
        if(!await(user.rxIsAuthorised(requiredPermission)))
            throw new AuthorizationException("Not authorized");

        PagesDao dao = (PagesDao) AppGlobals.get().getGlobal("dao");
        Single<Integer> query;
        if(isNewPage)
            query = dao.client().execute(DSL.using(dao.configuration()).insertInto(dao.getTable())
                    .columns(Tables.PAGES.NAME, Tables.PAGES.CONTENT)
                    .values(title, markdown));
        else
            query = dao.updateExecAsync(new Pages().setId(Integer.valueOf(id)).setContent(markdown));
        await(query);
        URI location = Router.getURI(WikiResource::renderPage, title);
        return Response.seeOther(location).build();
    });
}
项目:javase-restful-server    文件:UserService.java   
@PUT
@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String createUser(
        @FormParam("id") int id,
        @FormParam("name") String name,
        @FormParam("profession") String profession)
{
    User user = new User(id, name, profession);
    int result = userDao.addUser(user);
    if (result == 1)
    {
        return SUCCESS_JSON;
    }

    return FAILURE_JSON;
}
项目:redpipe    文件:WikiResource.java   
@Path("/save")
@POST
public Single<Response> save(@FormParam("id") String id,
        @FormParam("title") String title,
        @FormParam("markdown") String markdown,
        @FormParam("newPage") String newPage){
    return fiber((con) -> {
        boolean isNewPage = "yes".equals(newPage);
        String requiredPermission = isNewPage ? "create" : "update";
        if(!await(user.rxIsAuthorised(requiredPermission)))
            throw new AuthorizationException("Not authorized");

        String sql = isNewPage ? SQL.SQL_CREATE_PAGE : SQL.SQL_SAVE_PAGE;
        JsonArray params = new JsonArray();
        if (isNewPage) {
            params.add(title).add(markdown);
        } else {
            params.add(markdown).add(id);
        }
        await(con.rxUpdateWithParams(sql, params));
        URI location = Router.getURI(WikiResource::renderPage, title);
        return Response.seeOther(location).build();
    });
}
项目:lemon    文件:AccountStatusResource.java   
@POST
@Path("accountalias")
public BaseDTO accountStatus(@FormParam("username") String username) {
    BaseDTO baseDto = new BaseDTO();

    try {
        baseDto.setCode(200);
        baseDto.setData(accountAliasConverter.convertAlias(username));
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        baseDto.setCode(500);
        baseDto.setMessage(ex.getMessage());
    }

    return baseDto;
}
项目:opencps-v2    文件:RegistrationTemplatesManagement.java   
@PUT
@Path("/{id}/sampledata")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update sampledata")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateRegistrationTemplateSampleData(@Context HttpServletRequest request,
        @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext,
        @ApiParam(value = "id of DeliverableType", required = true) @PathParam("id") long registrationTemplatesId,
        @ApiParam(value = "sampledata of  registrationTemplate", required = true) @FormParam("sampleData") String sampledata);
项目:minijax    文件:OwnersResource.java   
@POST
@Path("/new")
@Consumes(APPLICATION_FORM_URLENCODED)
public Response handleSubmit(
        @FormParam("name") final String name,
        @FormParam("address") final String address,
        @FormParam("city") final String city,
        @FormParam("telephone") final String telephone) {

    final Owner owner = new Owner();
    owner.setName(name);
    owner.setAddress(address);
    owner.setCity(city);
    owner.setTelephone(telephone);
    dao.create(owner);
    return Response.seeOther(URI.create(owner.getUrl())).build();
}
项目:opencps-v2    文件:RegistrationFormManagement.java   
@PUT
@Path("/registrations/{id}/forms/{referenceUid}/formdata")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update RegistrationForm")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateRegFormFormData(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext,
        @ApiParam(value = "registrationId", required = true) @PathParam("id") long id,
        @ApiParam(value = "referenceUid", required = true) @PathParam("referenceUid") String referenceUid,
        @ApiParam(value = "formdata of registrationForm", required = true) @FormParam("formdata") String formdata)
        throws PortalException;
项目:QDrill    文件:StatusResources.java   
@POST
@Path("/option/{optionName}")
@Consumes("application/x-www-form-urlencoded")
@Produces(MediaType.TEXT_HTML)
public Viewable updateSystemOption(@FormParam("name") String name, @FormParam("value") String value,
                                 @FormParam("kind") String kind) {
  try {
    work.getContext()
      .getOptionManager()
      .setOption(OptionValue.createOption(
        OptionValue.Kind.valueOf(kind),
        OptionValue.OptionType.SYSTEM,
        name,
        value));
  } catch (Exception e) {
    logger.debug("Could not update.", e);
  }
  return getSystemOptions();
}
项目:clemon    文件:UserResource.java   
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("application/json")
@Path("/save")
public Object saveUser(@FormParam("userName") String userName,@FormParam("userPass") String userPass){
    String jsonData = "";
    User u = new User();
    u.setUserName(userName);
    u.setUserPass(userPass);
    try {
        userService.save(u);
    } catch (Exception e) {
        //-- 统一在过滤器中添加跨域访问的header信息,所以这里就不添加了
        jsonData = JsonUtil.toJsonByProperty("addUser","failure");
        return Response.ok(jsonData).status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR ).build();
    }
    jsonData = JsonUtil.toJsonByProperty("id", u.getId());
    return Response.ok(jsonData).status(HttpServletResponse.SC_OK).build();
}
项目:incubator-freemarker-online-tester    文件:WebPageResource.java   
@POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public FreeMarkerOnlineView formResult(
        @FormParam("template") String template,
        @FormParam("dataModel") String dataModel,
        @FormParam("outputFormat") String outputFormat,
        @FormParam("locale") String locale,
        @FormParam("timeZone") String timeZone) {
    FreeMarkerOnlineView view = new FreeMarkerOnlineView();
    view.setTemplate(template);
    view.setDataModel(dataModel);
    view.setOutputFormat(outputFormat);
    view.setLocale(locale);
    view.setTimeZone(timeZone);
    view.setExecute(true);
    return view;
}
项目:minijax    文件:OwnersResource.java   
@POST
@Path("/{id}/edit")
@Consumes(APPLICATION_FORM_URLENCODED)
public Response handleSubmit(
        @PathParam("id") final UUID id,
        @FormParam("name") final String name,
        @FormParam("address") final String address,
        @FormParam("city") final String city,
        @FormParam("telephone") final String telephone) {

    final Owner owner = dao.read(Owner.class, id);
    if (owner == null) {
        throw new NotFoundException();
    }

    owner.setName(name);
    owner.setAddress(address);
    owner.setCity(city);
    owner.setTelephone(telephone);
    dao.update(owner);
    return Response.seeOther(URI.create(owner.getUrl())).build();
}
项目:incubator-servicecomb-java-chassis    文件:JaxrsSwaggerGeneratorContext.java   
@Override
protected void initParameterAnnotationMgr() {
  super.initParameterAnnotationMgr();

  parameterAnnotationMgr.register(PathParam.class, new PathParamAnnotationProcessor());
  parameterAnnotationMgr.register(FormParam.class, new FormParamAnnotationProcessor());
  parameterAnnotationMgr.register(CookieParam.class, new CookieParamAnnotationProcessor());

  parameterAnnotationMgr.register(HeaderParam.class, new HeaderParamAnnotationProcessor());
  parameterAnnotationMgr.register(QueryParam.class, new QueryParamAnnotationProcessor());
}
项目:wechat-mall    文件:IndexResource.java   
@POST
@Path("login")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@AuthAnnotation
public User login(@FormParam("userName") String userName,
        @FormParam("password") String password,
        @FormParam("verificationCode") String verificationCode,
        @FormParam("phone") Long phone) {
    // check not null

    return null;
}
项目:Alpine    文件:LoginResource.java   
/**
 * Processes login requests.
 * @param username the asserted username
 * @param password the asserted password
 * @return a Response
 */
@POST
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(
        value = "Assert login credentials",
        notes = "Upon a successful login, a JWT will be returned in the response. This functionality requires authentication to be enabled.",
        response = String.class
)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Success"),
        @ApiResponse(code = 401, message = "Unauthorized")
})
@AuthenticationNotRequired
public Response validateCredentials(@FormParam("username") String username, @FormParam("password") String password) {
    final Authenticator auth = new Authenticator(username, password);
    try {
        final Principal principal = auth.authenticate();
        if (principal != null) {
            LOGGER.info(SecurityMarkers.SECURITY_AUDIT, "Login succeeded (username: " + username
                    + " / ip address: " + super.getRemoteAddress()
                    + " / agent: " + super.getUserAgent() + ")");

            final JsonWebToken jwt = new JsonWebToken();
            final String token = jwt.createToken(principal);
            return Response.ok(token).build();
        }
    } catch (AuthenticationException e) {
        LOGGER.warn(SecurityMarkers.SECURITY_AUDIT, "Unauthorized login attempt (username: "
                + username + " / ip address: " + super.getRemoteAddress()
                + " / agent: " + super.getUserAgent() + ")");
    }
    return Response.status(Response.Status.UNAUTHORIZED).build();
}
项目:acmeair-modular    文件:BookingsREST.java   
@POST
@Consumes({"application/x-www-form-urlencoded"})
@Path("/bookflights")
@Produces("text/plain")
public /*BookingInfo*/ Response bookFlights(
        @FormParam("userid") String userid,
        @FormParam("toFlightId") String toFlightId,
        @FormParam("toFlightSegId") String toFlightSegId,
        @FormParam("retFlightId") String retFlightId,
        @FormParam("retFlightSegId") String retFlightSegId,
        @FormParam("oneWayFlight") boolean oneWay) {
    try {

        String bookingIdTo = bs.bookFlight(userid, toFlightSegId, toFlightId);

        String bookingInfo = "";

        String bookingIdReturn = null;
        if (!oneWay) {
            bookingIdReturn = bs.bookFlight(userid, retFlightSegId, retFlightId);
            bookingInfo = "{\"oneWay\":false,\"returnBookingId\":\"" + bookingIdReturn + "\",\"departBookingId\":\"" + bookingIdTo + "\"}";
        } else {
            bookingInfo = "{\"oneWay\":true,\"departBookingId\":\"" + bookingIdTo + "\"}";
        }
        return Response.ok(bookingInfo).build();
    }
    catch (Exception e) {
        e.printStackTrace();
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
项目:minijax    文件:FormParamTest.java   
@POST
@Path("/multipart-part")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public static String getMultipartPart(
        @FormParam("content") final Part content)
                throws IOException {
    return content.getSubmittedFileName();
}
项目:acmeair-modular    文件:BookingsREST.java   
@POST
@Consumes({"application/x-www-form-urlencoded"})
@Path("/bookflights")
@Produces("text/plain")
public /*BookingInfo*/ Response bookFlights(
        @FormParam("userid") String userid,
        @FormParam("toFlightId") String toFlightId,
        @FormParam("toFlightSegId") String toFlightSegId,
        @FormParam("retFlightId") String retFlightId,
        @FormParam("retFlightSegId") String retFlightSegId,
        @FormParam("oneWayFlight") boolean oneWay) {
    try {
        String bookingIdTo = bs.bookFlight(userid, toFlightSegId, toFlightId);

        String bookingInfo = "";

        String bookingIdReturn = null;
        if (!oneWay) {
            bookingIdReturn = bs.bookFlight(userid, retFlightSegId, retFlightId);
            bookingInfo = "{\"oneWay\":false,\"returnBookingId\":\"" + bookingIdReturn + "\",\"departBookingId\":\"" + bookingIdTo + "\"}";
        }else {
            bookingInfo = "{\"oneWay\":true,\"departBookingId\":\"" + bookingIdTo + "\"}";
        }
        return Response.ok(bookingInfo).build();
    }
    catch (Exception e) {
        e.printStackTrace();
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
项目:acmeair-modular    文件:BookingsREST.java   
@POST
@Consumes({"application/x-www-form-urlencoded"})
@Path("/cancelbooking")
@Produces("text/plain")
public Response cancelBookingsByNumber(
        @FormParam("number") String number,
        @FormParam("userid") String userid) {
    try {
        bs.cancelBooking(userid, number);
        return Response.ok("booking " + number + " deleted.").build();

    }
    catch (Exception e) {
        e.printStackTrace();
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
项目:sierra    文件:SequenceAnalysisService.java   
/**
 * Service endpoint that provide multiple types of results.
 *
 * @param sequences The input sequences in FASTA format.
 * @param outputOptions Comma delimited values output options
 * @return All results packed in JSON format.
 */
@POST
@Produces("application/json")
public Response getAll(
        @FormParam("sequences") String sequences,
        @FormParam("outputOptions") String outputOptions) {

    SequenceAnalysisServiceOutput output =
        new SequenceAnalysisServiceOutput(sequences, outputOptions);

    return Response.ok(output.toString()).build();
}
项目:redpipe    文件:WikiResource.java   
@RequiresPermissions("create")
@Path("/create")
@POST
public Response create(@FormParam("name") String name){
    URI location;
    if (name == null || name.isEmpty()) {
        location = Router.getURI(WikiResource::index);
    }else{
        location = Router.getURI(WikiResource::renderPage, name);
    }
    return Response.seeOther(location).build();
}
项目:redpipe    文件:WikiResource.java   
@RequiresPermissions("create")
@Path("/create")
@POST
public Response create(@FormParam("name") String name){
    URI location;
    if (name == null || name.isEmpty()) {
        location = Router.getURI(WikiResource::index);
    }else{
        location = Router.getURI(WikiResource::renderPage, name);
    }
    return Response.seeOther(location).build();
}
项目:redpipe    文件:WikiResource.java   
@RequiresPermissions("delete")
@Path("/delete")
@POST
public Single<Response> delete(@FormParam("id") String id){
    return fiber((con) -> {
        await(con.rxUpdateWithParams(SQL.SQL_DELETE_PAGE, new JsonArray().add(id)));
        URI location = Router.getURI(WikiResource::index);
        return Response.seeOther(location).build();
    });
}
项目:redpipe    文件:BaseSecurityResource.java   
@POST
@Path("/loginAuth")
public Single<Response> loginAuth(@FormParam("username") String username, @FormParam("password") String password,
        @FormParam("return_url") String returnUrl, @Context Session session, @Context RoutingContext ctx,
        @Context AuthProvider auth) throws URISyntaxException {
    if (username == null || username.isEmpty() || password == null || password.isEmpty())
        return Single.just(Response.status(Status.BAD_REQUEST).build());

    JsonObject authInfo = new JsonObject().put("username", username).put("password", password);
    return auth.rxAuthenticate(authInfo).map(user -> {
        ctx.setUser(user);
        if (session != null) {
            // the user has upgraded from unauthenticated to authenticated
            // session should be upgraded as recommended by owasp
            session.regenerateId();
        }
        String redirectUrl = session.remove(REDIRECT_KEY);
        if (redirectUrl == null)
            redirectUrl = returnUrl;
        if (redirectUrl == null)
            redirectUrl = "/";

        try {
            return Response.status(Status.FOUND).location(new URI(redirectUrl)).build();
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }).onErrorReturn(t -> {
        t.printStackTrace();
        return Response.status(Status.FORBIDDEN).build();
    });
}
项目:alvisnlp    文件:PubAnnotation.java   
@POST
@Path("/plans/{plan}/{sync:sync|async}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
public Response annotate_POST_URLENCODED(
        @Context ServletContext servletContext,
        @Context HttpContext httpContext,
        @PathParam("plan") String planName,
        @PathParam("sync") String sync,
        @FormParam("text") @DefaultValue("") String text,
        @FormParam("sourcedb") @DefaultValue("") String sourcedb,
        @FormParam("sourceid") @DefaultValue("") String sourceid,
        MultivaluedMap<String,String> formParams
        ) throws Exception {
    return annotate(servletContext, httpContext, planName, text, sourcedb, sourceid, formParams, null, sync.equals("async"));
}
项目:lemon    文件:PlmKanbanResource.java   
/**
 * 创建任务.
 */
@POST
@Path("kanbanCreateIssue")
@Produces(MediaType.APPLICATION_JSON)
public BaseDTO kanbanCreateIssue(@FormParam("name") String name,
        @FormParam("content") String content,
        @FormParam("sprintId") Long sprintId,
        @FormParam("step") String step,
        @FormParam("assigneeId") String assigneeId) throws Exception {
    String userId = currentUserHolder.getUserId();
    PlmIssue plmIssue = new PlmIssue();
    plmIssue.setName(name);
    plmIssue.setContent(content);

    PlmSprint plmSprint = plmSprintManager.get(sprintId);
    plmIssue.setPlmSprint(plmSprint);
    plmIssue.setPlmProject(plmSprint.getPlmProject());
    plmIssue.setStep(step);
    plmIssue.setType("story");
    plmIssue.setStatus("active");
    plmIssue.setAssigneeId(assigneeId);
    plmIssue.setCreateTime(new Date());
    plmIssue.setReporterId(userId);
    plmIssueManager.save(plmIssue);
    plmLogService.issueCreated(plmIssue);

    BaseDTO baseDto = new BaseDTO();
    baseDto.setCode(200);

    return baseDto;
}
项目:corso-lutech    文件:ClienteAPI.java   
@POST
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes({MediaType.APPLICATION_FORM_URLENCODED})
public Cliente getById(@PathParam("id") int id,
        @QueryParam("citta") String citta,
        @FormParam("parametro") String nome) {
    Cliente c = new Cliente();
    c.setNome(nome + " : " + id);
    c.setPartitaIva("658736457634");
    c.setTelefono(citta);
    return c;
}
项目:acmeair    文件:LoginREST.java   
@POST
@Path("/validate")
@Consumes({"application/x-www-form-urlencoded"})
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid user information")})
public CustomerSessionInfo validateCustomer(@FormParam("sessionId") String sessionId) {
    logger.info("Received customer validation request with session id {}", sessionId);
    CustomerSession customerSession = customerService.validateSession(sessionId);
    if (customerSession != null) {
        logger.info("Found customer session {}", customerSession);
        return new CustomerSessionInfo(customerSession);
    }
    throw new InvocationException(Status.FORBIDDEN, "invalid token");
}
项目:lemon    文件:AccountLogResource.java   
@POST
public BaseDTO log(@FormParam("username") String username,
        @FormParam("result") String result,
        @FormParam("reason") String reason,
        @FormParam("application") String application,
        @FormParam("logTime") String logTime,
        @FormParam("client") String client,
        @FormParam("server") String server,
        @FormParam("description") String description) {
    Date date = this.tryToParseTime(logTime);

    AccountLogDTO accountLogDto = new AccountLogDTO();
    accountLogDto.setUsername(username);
    accountLogDto.setResult(result);
    accountLogDto.setReason(reason);
    accountLogDto.setApplication(application);
    accountLogDto.setLogTime(date);
    accountLogDto.setClient(client);
    accountLogDto.setServer(server);
    accountLogDto.setDescription(description);

    BaseDTO baseDto = new BaseDTO();

    try {
        accountLogQueue.add(accountLogDto);
        baseDto.setCode(200);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        baseDto.setCode(500);
        baseDto.setMessage(ex.getMessage());
    }

    return baseDto;
}
项目:minijax    文件:ChangePasswordTest.java   
@POST
@Path("/changepassword")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@RolesAllowed("user")
public Response handleChangePassword(
        @FormParam("oldPassword") final String oldPassword,
        @FormParam("newPassword") final String newPassword,
        @FormParam("confirmNewPassword") final String confirmNewPassword) {
    security.changePassword(oldPassword, newPassword, confirmNewPassword);
    return Response.ok().build();
}
项目:app-ms    文件:TokenResource.java   
/**
 * Performs client credential validation then dispatches to the appropriate
 * handler for a given grant type.
 */
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public OAuthTokenResponse dispatch(
    @ApiParam(allowableValues = "refresh_token, authorization_code") @FormParam("grant_type") final String grantType,
    @FormParam("code") final String code,
    @FormParam("assertion") final String assertion,
    @FormParam("aud") final String audience,
    @FormParam("refresh_token") final String refreshToken,
    @FormParam("jwks_uri") final URI jwksUri,
    @HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {

    final String[] clientCredentials = HttpAuthorizationHeaders.parseBasicAuthorization(authorization);

    final String clientId = clientCredentials[0];
    if (!clientValidator.isValid(grantType, clientId, clientCredentials[1])) {
        throw ErrorResponses.unauthorized(ErrorCodes.UNAUTHORIZED_CLIENT, "Unauthorized client", String.format("Basic realm=\"%s\", encoding=\"UTF-8\"", realmName));
    }

    if (GrantTypes.REFRESH_TOKEN.equals(grantType)) {
        return handleRefreshGrant(refreshToken, clientId);
    } else if (GrantTypes.AUTHORIZATION_CODE.equals(grantType)) {
        return handleAuthorizationCodeGrant(code);
    } else if (GrantTypes.JWT_ASSERTION.equals(grantType)) {
        return handleJwtAssertionGrant(assertion, clientId, audience);

    } else {
        throw ErrorResponses.badRequest(ErrorCodes.UNSUPPORT_GRANT_TYPE, "Invalid grant type");
    }

}
项目:app-ms    文件:RevocationResource.java   
/**
 * Performs client credential validation then invokes the revocation process
 * from the token cache.
 */
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject revoke(
    @FormParam("token") final String token,
    @FormParam("token_type_hint") final String tokenTypeHint,
    @HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {

    final String[] clientCredentials = HttpAuthorizationHeaders.parseBasicAuthorization(authorization);

    final String clientId = clientCredentials[0];
    if (!clientValidator.isValid("revocation", clientId, clientCredentials[1])) {
        throw ErrorResponses.unauthorized(ErrorCodes.UNAUTHORIZED_CLIENT, "Unauthorized client", String.format("Basic realm=\"%s\", encoding=\"UTF-8\"", realmName));
    }

    if (token == null) {
        throw ErrorResponses.invalidRequest("Missing token");
    }
    if (tokenTypeHint != null && !"refresh_token".equals(tokenTypeHint)) {
        throw ErrorResponses.badRequest(ErrorCodes.UNSUPPORTED_TOKEN_TYPE, "Token type is not supported");
    }

    tokenCache.revokeRefreshToken(token, clientId);
    LOG.debug("revoked token={}", token);

    final JsonObject okReturn = new JsonObject();
    okReturn.addProperty("ok", 1);
    return okReturn;

}
项目:app-ms    文件:SingleHello2.java   
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
public String helloHelloPost(@FormParam("me") final String me) {

    return "HelloHello " + me;
}
项目:app-ms    文件:Hello.java   
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
public String helloHelloPost(@FormParam("me") final String me) {

    return "HelloHello " + me;
}
项目:app-ms    文件:SingleHello2.java   
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
public String helloHelloPost(@FormParam("me") final String me) {

    return "HelloHello " + me;
}
项目:acmeair    文件:FlightsREST.java   
@POST
@Path("/browseflights")
@Consumes({"application/x-www-form-urlencoded"})
@Produces("application/json")
public TripFlightOptions browseFlights(
        @FormParam("fromAirport") String fromAirport,
        @FormParam("toAirport") String toAirport,
        @FormParam("oneWay") boolean oneWay) {
    TripFlightOptions options = new TripFlightOptions();
    ArrayList<TripLegInfo> legs = new ArrayList<TripLegInfo>();

    TripLegInfo toInfo = new TripLegInfo();
    List<Flight> toFlights = flightService.getFlightByAirports(fromAirport, toAirport);
    toInfo.addFlightsOptions(toFlights);
    legs.add(toInfo);
    toInfo.setCurrentPage(0);
    toInfo.setHasMoreOptions(false);
    toInfo.setNumPages(1);
    toInfo.setPageSize(TripLegInfo.DEFAULT_PAGE_SIZE);

    if (!oneWay) {
        TripLegInfo retInfo = new TripLegInfo();
        List<Flight> retFlights = flightService.getFlightByAirports(toAirport, fromAirport);
        retInfo.addFlightsOptions(retFlights);
        legs.add(retInfo);
        retInfo.setCurrentPage(0);
        retInfo.setHasMoreOptions(false);
        retInfo.setNumPages(1);
        retInfo.setPageSize(TripLegInfo.DEFAULT_PAGE_SIZE);
        options.setTripLegs(2);
    } else {
        options.setTripLegs(1);
    }

    options.setTripFlights(legs);

    return options;
}
项目:opencps-v2    文件:EmployeeManagement.java   
@POST
@Path("/{id}/lock")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response lockEmployeeAccount(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext, @PathParam("id") long id,
        @DefaultValue("false") @FormParam("locked") boolean locked);
项目:opencps-v2    文件:RegistrationTemplatesManagement.java   
@PUT
@Path("/{id}/formscript")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update FormScript")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateRegistrationTemplateFormScript(@Context HttpServletRequest request,
        @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext,
        @ApiParam(value = "id of  registrationTemplate", required = true) @PathParam("id") long registrationTemplateId,
        @ApiParam(value = "FormScript of  registrationTemplate", required = true) @FormParam("formScript") String formScript);
项目:opencps-v2    文件:RegistrationTemplatesManagement.java   
@PUT
@Path("/{id}/formreport")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update FormScript")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateRegistrationTemplateFormReport(@Context HttpServletRequest request,
        @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext,
        @ApiParam(value = "id of registrationTemplateId", required = true) @PathParam("id") long registrationTemplateId,
        @ApiParam(value = "formReport of registrationTemplate", required = true) @FormParam("formReport") String formReport);
项目:opencps-v2    文件:RegistrationManagement.java   
@POST
@Path("/registrations/syncs")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
public Response registrationSyncs(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext, @BeanParam RegistrationInputModel input,
        @FormParam("submitting") boolean submitting, @FormParam("uuid_") String uuid);