Package net.oauth.v2.OAuth2

Examples of net.oauth.v2.OAuth2.Parameter


           
        } catch (Exception e){
            Boolean sendBodyInJson = false;
            Boolean withAuthHeader = false;
            if (e instanceof OAuth2ProblemException){
              OAuth2ProblemException problem = (OAuth2ProblemException) e;
              problem.setParameter(OAuth2ProblemException.HTTP_STATUS_CODE,new Integer(302));
              //problem.setParameters(OAuth2ProblemException.HTTP_LOCATION,)
            }
          SampleOAuth2Provider.handleException(e, request, response, sendBodyInJson,withAuthHeader);
        }
    }
View Full Code Here


    public static void handleException(HttpServletRequest request, HttpServletResponse response,
        Exception e, String realm, boolean sendBodyInJson, boolean withAuthHeader)
        throws IOException, ServletException {
     
        if (e instanceof OAuth2ProblemException) {
            OAuth2ProblemException problem = (OAuth2ProblemException) e;

            Object httpCode = getHttpCode(problem);

            response.reset();
            response.setStatus(Integer.parseInt(httpCode.toString()));
           
           
            OAuth2Message message = new OAuth2Message(null, null, problem.getParameters().entrySet());  
            if(withAuthHeader){
              response.addHeader("WWW-Authenticate", message.getWWWAuthenticateHeader(realm));
            }

            List<Map.Entry<String, String>> sendBackErrorParameters = new ArrayList<Map.Entry<String, String>>(SEND_BACK_ERROR_PARAMETERS.size());
View Full Code Here

        String client_id = requestMessage.getClientId();
       
        client = SampleOAuth2Provider.ALL_CLIENTS.get(client_id);
       
        if(client == null) {
            OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
            if(requestMessage.getParameter(OAuth2.STATE)!=null){
              problem.setParameter(OAuth2.STATE, requestMessage.getParameter(OAuth2.STATE));
            }
            throw problem;
        }
       
        return client;
View Full Code Here

            if(authz.substring(0,5).equals("Basic")){
                String userPass = new String(Base64.decodeBase64(authz.substring(6).getBytes()), "UTF-8");

                int loc = userPass.indexOf(":");
                if (loc == -1) {
                    OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
                    throw problem;
                }

                String userPassedIn = userPass.substring(0, loc);
                String user = userPassedIn;
                String pass = userPass.substring(loc + 1);
                if(user!=null && pass!=null){
                    client = SampleOAuth2Provider.ALL_CLIENTS.get(user);


                }
            }
        }
        if(client == null) {
            OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
            throw problem;
        }

        return client;
    }
View Full Code Here

            throws IOException, OAuth2ProblemException {
       
        // try to load from local cache if not throw exception
        String code = requestMessage.getCode();
        if(code == null){
          OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_REQUEST);
            throw problem;
        }
        OAuth2Accessor accessor = null;
        for (OAuth2Accessor a : SampleOAuth2Provider.ALL_TOKENS) {
            if(a.code != null) {
                if (a.code.equals(code)) {
                    accessor = a;
                    break;
                }
            }
        }
       
        if(accessor == null){
            OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_REQUEST);

            throw problem;
        }
       
        return accessor;
View Full Code Here

    throws IOException, OAuth2ProblemException {

      // try to load from local cache if not throw exception
      String refreshToken = requestMessage.getParameter(OAuth2.REFRESH_TOKEN);
      if(refreshToken == null){
          OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_REQUEST);
            throw problem;
        }
      OAuth2Accessor accessor = null;
      for (OAuth2Accessor a : SampleOAuth2Provider.ALL_TOKENS) {
        if(a.refreshToken != null) {
          if (a.refreshToken.equals(refreshToken)) {
            accessor = a;
            break;
          }
        }
      }

      if(accessor == null){
        OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_GRANT);

        throw problem;
      }

      return accessor;
View Full Code Here

    }
   
    private void printUserCalendar() {
      WebClient client = createClient("http://localhost:" + port + "/services/social/accounts/calendar",
          "barry@social.com", "1234");
      Calendar calendar = client.get(Calendar.class);
      System.out.println(calendar.toString());
    }
View Full Code Here

      if (!checkPassed) {
          throw new WebApplicationException(403);
      }
      // end of the check
     
      Calendar calendar = getUserCalendar();
      calendar.getEntry(hour).setEventDescription(description);
  }
View Full Code Here

    if (accessToken == null) {
        return redirectToFailureHandler(NO_OAUTH_ACCESS_TOKEN);
    }
   
   
    Calendar c = null;
    try {
      String authHeader = manager.createAuthorizationHeader(accessToken);
          socialService.replaceHeader("Authorization", authHeader);
         
          c = socialService.get(Calendar.class);
    } catch (RuntimeException ex) {
        return redirectToFailureHandler(CALENDAR_ACCESS_PROBLEM);
    }
   
      CalendarEntry entry = c.getEntry(request.getHour());
    if (entry.getEventDescription() == null || entry.getEventDescription().trim().isEmpty()) {
      String address = restaurantService.post(new Form().set("name", request.getReserveName())
                               .set("phone", request.getContactPhone())
                               .set("hour", request.getHour()),
                                String.class);
View Full Code Here

          c = socialService.get(Calendar.class);
    } catch (RuntimeException ex) {
        return redirectToFailureHandler(CALENDAR_ACCESS_PROBLEM);
    }
   
      CalendarEntry entry = c.getEntry(request.getHour());
    if (entry.getEventDescription() == null || entry.getEventDescription().trim().isEmpty()) {
      String address = restaurantService.post(new Form().set("name", request.getReserveName())
                               .set("phone", request.getContactPhone())
                               .set("hour", request.getHour()),
                                String.class);
      if (address == null) {
View Full Code Here

TOP

Related Classes of net.oauth.v2.OAuth2.Parameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.