Example #1
0
  private Credentials extractCredentials(
      HttpServletRequest request, RepositoryConfiguration configuration) {
    final Credentials credentialsFromUrlParameters = extractCredentialsFromRequest(request);

    final Credentials credentials;
    if (configuration.isAccessControlEnabled()) {
      if (httpAuthenticationHandler.isLoginAttempt(request)) {
        logger.debug("Basic HTTP authentication detected. Parsing credentials from request.");
        credentials = httpAuthenticationHandler.parseCredentials(request);
      } else {
        logger.debug("Parsing credentials from url");
        credentials = credentialsFromUrlParameters;
      }
    } else {
      credentials = configuration.getUserCredentials();
    }
    return credentials;
  }
Example #2
0
  /** {@inheritDoc} */
  protected ModelAndView handle(
      final HttpServletRequest request,
      final HttpServletResponse response,
      final Object cmd,
      final BindException errors)
      throws Exception {

    logger.debug("Getting RSS feed");

    final BaseCommand command = (BaseCommand) cmd;
    logger.debug(command);

    if (!application.isConfigured()) {
      handleError(response, "sventon has not been configured yet!");
      return null;
    }

    final RepositoryConfiguration configuration =
        application.getRepositoryConfiguration(command.getName());
    if (configuration == null) {
      handleError(response, "Repository [" + command.getName() + "] does not exist!");
      return null;
    }

    addResponseHeaders(response);

    SVNRepository repository = null;

    try {
      final List<SVNLogEntry> logEntries = new ArrayList<SVNLogEntry>();
      repository = createRepositoryConnection(request, configuration);
      command.translateRevision(getRepositoryService().getLatestRevision(repository), repository);

      logger.debug("Outputting feed for [" + command.getPath() + "]");
      logEntries.addAll(
          getRepositoryService()
              .getRevisions(
                  command.getName(),
                  repository,
                  command.getRevisionNumber(),
                  FIRST_REVISION,
                  command.getPath(),
                  configuration.getRssItemsCount(),
                  false));
      rssFeedGenerator.outputFeed(configuration, logEntries, request, response);
    } catch (SVNAuthenticationException aex) {
      logger.info(aex.getMessage());
      httpAuthenticationHandler.sendChallenge(response);
    } catch (SVNException svnex) {
      handleSVNException(response, svnex);
    } finally {
      close(repository);
    }
    return null;
  }