Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.AbstractBlog


        uri.startsWith("/FCKeditor/")
        ) {
      return null;
    }
   
    AbstractBlog ab = (AbstractBlog)((FilterInvocation)object).getHttpRequest().getAttribute(Constants.BLOG_KEY);
    if (ab instanceof Blog) {
      Blog blog = (Blog)ab;
      List<String> blogReaders = blog.getBlogReaders();
      if (blogReaders != null && blogReaders.size() > 0) {
        return Arrays.<ConfigAttribute>asList(new PrivateBlogConfigAttributeDefinition(blog));
View Full Code Here


   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {
      AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);
      String usernames[] = request.getParameterValues("user");
      String submit = request.getParameter("submit");

      SecurityRealm realm = PebbleContext.getInstance().getConfiguration().getSecurityRealm();
      if (usernames != null) {
        for (String username : usernames) {
          if (submit.equalsIgnoreCase("Remove")) {
            realm.removeUser(username);
          } else if (submit.equalsIgnoreCase("Reset Password")) {
            realm.changePassword(username, "password");
          }
        }
      }

      return new RedirectView(blog.getUrl() + "viewUsers.secureaction");
    } catch (SecurityRealmException e) {
      throw new ServletException(e);
    }
  }
View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {
      AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);

      Map<String,String> preferences = new HashMap<String,String>();
      Enumeration parameterNames = request.getParameterNames();
      while (parameterNames.hasMoreElements()) {
        String parameterName = (String)parameterNames.nextElement();
        if (parameterName.startsWith(PREFERENCE)) {
          preferences.put(parameterName.substring(PREFERENCE.length()), request.getParameter(parameterName));
        }
      }

      PebbleUserDetails currentUserDetails = SecurityUtils.getUserDetails();

      // can the user change their user details?
      if (!currentUserDetails.isDetailsUpdateable()) {
        return new FourZeroThreeView();
      }

      SecurityRealm realm = PebbleContext.getInstance().getConfiguration().getSecurityRealm();

      ValidationContext validationContext = new ValidationContext();

      if (!validationContext.hasErrors()) {
        currentUserDetails.setPreferences(preferences);
        realm.updateUser(currentUserDetails);

        return new RedirectView(blog.getUrl() + "editUserPreferences.secureaction");
      }

      getModel().put("validationContext", validationContext);
      return new ForwardView("/editUserPreferences.secureaction");
    } catch (SecurityRealmException e) {
View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {
      AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);
      String username = request.getParameter("username");
      String password1 = request.getParameter("password1");
      String password2 = request.getParameter("password2");
      String name = request.getParameter("name");
      String emailAddress = request.getParameter("emailAddress");
      String website = request.getParameter("website");
      String profile = request.getParameter("profile");
      String roles[] = request.getParameterValues("role");
      boolean newUser = request.getParameter("newUser").equalsIgnoreCase("true");
      String detailsUpdateableAsString = request.getParameter("detailsUpdateable");
      boolean detailsUpdateable = detailsUpdateableAsString != null && detailsUpdateableAsString.equalsIgnoreCase("true");
      Map<String,String> preferences = new HashMap<String,String>();
      Enumeration parameterNames = request.getParameterNames();
      while (parameterNames.hasMoreElements()) {
        String parameterName = (String)parameterNames.nextElement();
        if (parameterName.startsWith(PREFERENCE)) {
          preferences.put(parameterName.substring(PREFERENCE.length()), request.getParameter(parameterName));
        }
      }

      SecurityRealm realm = PebbleContext.getInstance().getConfiguration().getSecurityRealm();
      PebbleUserDetails currentUserDetails = realm.getUser(username);
      PebbleUserDetails newUserDetails = new PebbleUserDetails(username, password1, name, emailAddress, website, profile, roles, preferences, detailsUpdateable);

      ValidationContext validationContext = new ValidationContext();

      if (newUser && currentUserDetails != null) {
        validationContext.addError("A user with this username already exists");
      } else if (newUser && (username == null || username.trim().length() == 0)) {
        validationContext.addError("Username can't be empty");
      } else if (password1 != null && password1.length() > 0 && !password1.equals(password2)) {
        validationContext.addError("Passwords must match");
      } else {

        if (newUser) {
          try {
            realm.createUser(newUserDetails);
          } catch (SecurityRealmException sre) {
            validationContext.addError(sre.getMessage());
          }
        } else {
          realm.updateUser(newUserDetails);
          if (password1 != null && password1.length() > 0) {
            realm.changePassword(username, password1);
          }
        }
        return new RedirectView(blog.getUrl() + "viewUsers.secureaction");
      }

      getModel().put("validationContext", validationContext);
      getModel().put("user", newUserDetails);
      getModel().put("newUser", newUser);
View Full Code Here

   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);
    String redirectUrl = request.getParameter("redirectUrl");

    if (redirectUrl == null || redirectUrl.trim().length() == 0) {
      redirectUrl = blog.getUrl();
    }
    return new RedirectView(redirectUrl);
  }
View Full Code Here

   * Gets the content type of this view.
   *
   * @return the content type as a String
   */
  public String getContentType() {
    AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);
    return "application/xml; charset=" + blog.getCharacterEncoding();
  }
View Full Code Here

   */
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws ServletException, IOException {

    HttpServletRequest httpRequest = (HttpServletRequest)request;
    AbstractBlog blog = (AbstractBlog)request.getAttribute(Constants.BLOG_KEY);

    String originalUri = httpRequest.getRequestURI();

    // get URI and strip off the context (e.g. /blog)
    String uri = originalUri.substring(httpRequest.getContextPath().length(), originalUri.length());
View Full Code Here

      in.close();
      out.close();
    } catch (IOException ioe) {
      log.warn(ioe);
    } finally {
      AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);
      blog.log(request, HttpServletResponse.SC_OK);
    }
  }
View Full Code Here

  public void processRequest(HttpServletRequest request,
                                HttpServletResponse response,
                                ServletContext servletContext)
          throws ServletException, IOException {

    AbstractBlog blog = (AbstractBlog) request.getAttribute(Constants.BLOG_KEY);

    // find which action should be used
    String actionName = request.getRequestURI();
    if (actionName.indexOf("?") > -1) {
      // strip of the query string - some servers leave this on
      actionName = actionName.substring(0, actionName.indexOf("?"));
    }
    int index = actionName.lastIndexOf("/");
    actionName = actionName.substring(index + 1, (actionName.length() - actionExtension.length()));
    Action action;

    try {
      log.debug("Action is " + actionName);
      action = actionFactory.getAction(actionName);
    } catch (ActionNotFoundException anfe) {
      log.warn(anfe.getMessage());
      response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    boolean authorised = isAuthorised(request, action);
    if (!authorised) {
      response.sendError(HttpServletResponse.SC_FORBIDDEN);
    } else {
      boolean validated = securityTokenValidator.validateSecurityToken(request, response, action);
      if (!validated) {
        // Forward to no security url
        request.getRequestDispatcher("/noSecurityToken.action").forward(request, response);
      } else {
        try {
          Model model = new Model();
          model.put(Constants.BLOG_KEY, blog);
          model.put(Constants.BLOG_URL, blog.getUrl());
          action.setModel(model);
          View view;
          try {
            view = action.process(request, response);
          } catch (ClassCastException cce) {
View Full Code Here

   * @param request the HttpServletRequest
   * @param action  the SecureAction to check against
   * @return true if the user is in one of the roles, false otherwise
   */
  private boolean isUserInRole(HttpServletRequest request, SecureAction action) {
    AbstractBlog ab = (AbstractBlog) request.getAttribute(Constants.BLOG_KEY);
    String currentUser = SecurityUtils.getUsername();
    String roles[] = action.getRoles(request);
    for (String role : roles) {
      if (role.equals(Constants.ANY_ROLE)) {
        return true;
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.domain.AbstractBlog

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.