public AdminModule(WebApplicationService webApplicationService) : base("/admin") { Get["/"] = parameters => { var model = new Views.Admin.Models.IndexModel { CreationDate = webApplicationService.GetCreationDate(), TotalRequests = webApplicationService.TimesRequested() }; return(View["Index", model]); }; }
public WebApplicationService extractService(HttpRequest request) { WebApplicationService service = this.extractServiceInternal(request); if (service == null) { //log.debug("Extractor did not generate service."); } else { //log.debug("Extractor generated service for: " + service.getId()); } return(service); }
public static WebApplicationService getService( List <ArgumentExtractor> argumentExtractors, HttpRequest request) { foreach (ArgumentExtractor argumentExtractor in argumentExtractors) { WebApplicationService service = argumentExtractor .extractService(request); if (service != null) { return(service); } } return(null); }
protected ModelAndView handleRequestInternal(HttpRequest request, HttpResponse response) { WebApplicationService service = this.argumentExtractor.extractService(request); string serviceTicketId = service != null?service.getArtifactId() : null; if (service == null || serviceTicketId == null) { //if (logger.isDebugEnabled()) { // logger.debug(string.format("Could not process request; Service: %s, Service Ticket Id: %s", service, serviceTicketId)); //} return(this.generateErrorView("INVALID_REQUEST", "INVALID_REQUEST", null)); } try { Credentials serviceCredentials = this.getServiceCredentialsFromRequest(request); string proxyGrantingTicketId = null; // XXX should be able to validate AND THEN use if (serviceCredentials != null) { try { proxyGrantingTicketId = this.centralAuthenticationService .delegateTicketGrantingTicket(serviceTicketId, serviceCredentials); } catch (TicketException e) { //logger.error("TicketException generating ticket for: " // + serviceCredentials, e); } } Assertion assertion = this.centralAuthenticationService.validateServiceTicket(serviceTicketId, service); ValidationSpecification validationSpecification = this.getCommandClass(); ServletRequestDataBinder binder = new ServletRequestDataBinder(validationSpecification, "validationSpecification"); this.initBinder(request, binder); binder.bind(request); if (!validationSpecification.isSatisfiedBy(assertion)) { //if (logger.isDebugEnabled()) { // logger.debug("ServiceTicket [" + serviceTicketId + "] does not satisfy validation specification."); //} return(this.generateErrorView("INVALID_TICKET", "INVALID_TICKET_SPEC", null)); } this.onSuccessfulValidation(serviceTicketId, assertion); ModelAndView success = new ModelAndView(this.successView); success.addObject(MODEL_ASSERTION, assertion); if (serviceCredentials != null && proxyGrantingTicketId != null) { string proxyIou = this.proxyHandler.handle(serviceCredentials, proxyGrantingTicketId); success.addObject(MODEL_PROXY_GRANTING_TICKET_IOU, proxyIou); } //if (logger.isDebugEnabled()) { // logger.debug(string.format("Successfully validated service ticket: %s", serviceTicketId)); //} return(success); } catch (TicketValidationException e) { return(this.generateErrorView(e.getCode(), e.getCode(), new Object[] { serviceTicketId, e.getOriginalService().getId(), service.getId() })); } catch (TicketException te) { return(this.generateErrorView(te.getCode(), te.getCode(), new Object[] { serviceTicketId })); } catch (UnauthorizedServiceException e) { //return generateErrorView(e.getMessage(), e.getMessage(), null); throw new NotImplementedException(); } }