Tabnine Logo
HttpResult
Code IndexAdd Tabnine to your IDE (free)

How to use
HttpResult
in
cn.dreampie.common.http.result

Best Java code snippets using cn.dreampie.common.http.result.HttpResult (Showing top 6 results out of 315)

origin: Dreampie/Resty

@GET
public HttpResult toSignIn(String key, String response_type, String state) {
 String redirectParam = "?key=" + key + "&response_type=" + response_type + "&state=" + state;
 if (!response_type.equals("code")) {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=response_type_not_match"));
 }
 Client client = Client.DAO.findFirstBy("key=?", key);
 if (client == null) {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=client_not_found"));
 } else {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthSignInUrl + redirectParam));
 }
}
origin: Dreampie/Resty

 response.setStatus(httpResult.getStatus());
 Map<String, String> headers = httpResult.getHeaders();
 if (headers != null && headers.size() > 0) {
  for (Map.Entry<String, String> headersEntry : headers.entrySet()) {
 List<Cookie> cookies = httpResult.getCookies();
 if (cookies != null && cookies.size() > 0) {
  for (Cookie cookie : cookies) {
 result = httpResult.getResult();
} else {
 result = invokeResult;
origin: cn.dreampie/resty-route

 response.setStatus(httpResult.getStatus());
 Map<String, String> headers = httpResult.getHeaders();
 if (headers != null && headers.size() > 0) {
  for (Map.Entry<String, String> headersEntry : headers.entrySet()) {
 List<Cookie> cookies = httpResult.getCookies();
 if (cookies != null && cookies.size() > 0) {
  for (Cookie cookie : cookies) {
 result = httpResult.getResult();
} else {
 result = invokeResult;
origin: Dreampie/Resty

 @PUT
 public HttpResult refreshToken(String refresh_token, String grant_type) {
  String redirectParam = "?refresh_token=" + refresh_token + "&grant_type=" + grant_type;
  if (!grant_type.equals("refresh_token")) {
   return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=grant_type_not_match"));
  }

  Token token = Authorizes.getTokenByRefreshToken(refresh_token);

  if (token == null) {
   return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=token_not_found"));
  } else {
   Client oldClient = Client.DAO.findById(token.getClientId());
   //判断账号是否支持该授权方式
   if (!Arrays.asList(oldClient.getGrant().split(",")).contains(grant_type)) {
    return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=grant_type_not_support"));
   }
   OpenID openID = OpenID.DAO.findFirstBy("user_id=? AND client_id=?", token.getUserId(), token.getClientId());

   AccessToken accessToken = new AccessToken(token.getToken(), token.getExpires(), null, openID.<String>get("open_id"), token.getScope());
   return new HttpResult(HttpStatus.OK, accessToken);
  }
 }
}
origin: Dreampie/Resty

/**
 * @param client={"key":"xx","scopeIds":[xx,xx]}
 * @param response_type
 * @param state
 * @return
 */
@POST
public HttpResult getCode(Client client, String response_type, String state) {
 String redirectParam = "?key=" + client.get("key") + "&response_type=" + response_type + "&state=" + state;
 if (!response_type.equals("code")) {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=response_type_not_match"));
 }
 Client oldClient = Client.DAO.findFirstBy("key=?", client.get("key"));
 if (oldClient == null) {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=client_not_found"));
 } else {
  Set<Scope> scopes = new HashSet<Scope>();
  for (Scope scope : oldClient.getScopes()) {
   if (scope.<Integer>get("selected") == 1 || Arrays.asList(client.getScopeIds()).contains(scope.<Integer>get("id"))) {
    scopes.add(scope);
   }
  }
  Entity<?> user = Subject.getPrincipal().getModel();
  int userId = user.<Integer>get("id");
  Code code = new Code(UUID.randomUUID().toString().replaceAll("-", ""), oldClient.<Integer>get("id"), userId, Constant.oauthExpires, scopes);
  Authorizes.addCode(code);//cache code
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", oldClient.get("redirect_uri") + "?code=" + code.getCode() + "&state=" + state));
 }
}
origin: Dreampie/Resty

String redirectParam = "?key=" + client.get("key") + "&code=" + code + "&grant_type=" + grant_type;
if (!grant_type.equals("authorization_code")) {
 return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=grant_type_not_match"));
 return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=client_or_code_not_found"));
} else {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=grant_type_not_support"));
 Authorizes.addRefreshToken(refreshToken, token);
 AccessToken accessToken = new AccessToken(token.getToken(), token.getExpires(), refreshToken, openID.<String>get("open_id"), token.getScope());
 return new HttpResult(HttpStatus.OK, accessToken);
cn.dreampie.common.http.resultHttpResult

Javadoc

Created by ice on 14-12-19. A HttpResult can be raised to make resty return immediately an HTTP response with a specific HTTP status.

Most used methods

  • <init>
  • getCookies
  • getHeaders
  • getResult
    Returns the content to use in the HTTP response .
  • getStatus

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now