Package com.github.zhangkaitao.shiro.chapter18.oauth2

Examples of com.github.zhangkaitao.shiro.chapter18.oauth2.OAuth2Realm


    }
   
    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

   
    newClient.setApplicationDescription(appDesc);
    newClient.setApplicationLogoUri(logoURI.toString());
    newClient.setRedirectUris(Collections.singletonList(appRedirectURI));
    manager.registerClient(newClient);
    return new ConsumerRegistration(clientId, clientSecret);
  }
View Full Code Here

    String clientSecret = generateClientSecret();
 
    Client newClient = new Client(clientId, clientSecret, true, appName, appURI);
    newClient.setRedirectUris(Collections.singletonList(appRedirectURI));
    manager.registerClient(newClient);
    return new ConsumerRegistration(clientId, clientSecret);
  }
View Full Code Here

      }
     
      WebClient finalClient = createClient(locationHeader2.toString(),
          "barry@restaurant.com", "5678");
      finalClient.accept("application/xml");
      ReservationConfirmation confirm = finalClient.get(ReservationConfirmation.class);
     
      if (confirm != null) {
        updateAndGetUserCalendar(7, "Dinner at " + confirm.getAddress());
      } else {
        System.out.println("Reservation failed");
      }
    }
View Full Code Here

           
            Response response = socialService.form(new Form().set("hour", request.getHour())
                                   .set("description", "Table reserved at " + address));
            boolean calendarUpdated = response.getStatus() == 200 || response.getStatus() == 204;
     
      return Response.ok(new ReservationConfirmation(address, request.getHour(), calendarUpdated))
                     .build();
    } else {
        return redirectToFailureHandler(CALENDAR_BUSY);
    }
    }
View Full Code Here

    @Produces({"text/html", "application/xml;q=0.9" })
    public ReservationFailure handleReservationFailure(@QueryParam("code") String errorCode) {
        LOG.info("Handling the reservation failure");
       
        String message = ERROR_DESCRIPTIONS.get(errorCode);
        return new ReservationFailure(message);
    }
View Full Code Here

                               @FormParam("password") String password) {
    if (accounts.getAccount(name) != null) {
      throw new WebApplicationException(400);
    }
    accounts.setAccount(name, new UserAccount(name, password, alias));
    return new UserRegistration(name);
  }
View Full Code Here

TOP

Related Classes of com.github.zhangkaitao.shiro.chapter18.oauth2.OAuth2Realm

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.