Examples of PebbleUserDetails


Examples of net.sourceforge.pebble.security.PebbleUserDetails

*/
public class PebbleUserDetailsComparatorTest extends SingleBlogTestCase {

  public void testCompare() {
    PebbleUserDetailsComparator comp = new PebbleUserDetailsComparator();
    PebbleUserDetails pud1 = new PebbleUserDetails("username1", "", "User1", "", "", "", new String[]{}, new HashMap<String,String>(), true);
    PebbleUserDetails pud2 = new PebbleUserDetails("username2", "", "User2", "", "", "", new String[]{}, new HashMap<String,String>(), true);

    assertTrue(comp.compare(pud1, pud1) == 0);
    assertTrue(comp.compare(pud1, pud2) < 0);
    assertTrue(comp.compare(pud2, pud1) > 0);
  }
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

          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");
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

      // ... but only if the browser doesn't send the character encoding back
      if (request.getCharacterEncoding() == null) {
        request.setCharacterEncoding(blog.getCharacterEncoding());
      }

      PebbleUserDetails user = SecurityUtils.getUserDetails();
      if (user != null) {
        httpRequest.setAttribute(Constants.AUTHENTICATED_USER, user);
      }

      Config.set(request, Config.FMT_LOCALE, blog.getLocale());
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String username = request.getParameter("user");
    SecurityRealm realm = PebbleContext.getInstance().getConfiguration().getSecurityRealm();
    try {
      PebbleUserDetails user = realm.getUser(username);
      if (user != null) {
        getModel().put(Constants.USER_KEY, user);
        getModel().put(Constants.BLOG_ENTRIES, blog.getRecentPublishedBlogEntries(username));
        return new AboutAuthorView();
      }
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

    return new String[]{Constants.ANY_ROLE};
  }

  @Override
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    PebbleUserDetails userDetails = SecurityUtils.getUserDetails();
    AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);

    String openId = request.getParameter("openid");
    try {
      PebbleContext.getInstance().getConfiguration().getSecurityRealm().removeOpenIdFromUser(userDetails, openId);
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

   * @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 {
    PebbleUserDetails currentUserDetails = SecurityUtils.getUserDetails();

    getModel().put("user", currentUserDetails);

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

    return new UserPreferencesView();
  }
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

  private OpenIDConsumer openIDConsumer;
  @Inject
  private SecurityRealm securityRealm;

  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    PebbleUserDetails userDetails = SecurityUtils.getUserDetails();
    ValidationContext validationContext = new ValidationContext();
    AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);

    String identity = request.getParameter("openid.identity");
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {
      SecurityRealm realm = PebbleContext.getInstance().getConfiguration().getSecurityRealm();
      PebbleUserDetails currentUserDetails = SecurityUtils.getUserDetails();
      String password1 = request.getParameter("password1");
      String password2 = request.getParameter("password2");
      String submit = request.getParameter("submit");

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

      if (submit == null || submit.length() == 0) {
        return new ChangePasswordView();
      }

      ValidationContext validationContext = new ValidationContext();

      if (password1 == null || password1.length() == 0) {
        validationContext.addError("Password can not be empty");
      } else if (!password1.equals(password2)) {
        validationContext.addError("Passwords do not match");
      }

      if (!validationContext.hasErrors()) {
          realm.changePassword(currentUserDetails.getUsername(), password1);

          return new PasswordChangedView();
      }

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

Examples of net.sourceforge.pebble.security.PebbleUserDetails

    Comment comment = blogEntry.createComment(title, body, author, email, website, avatar, ipAddress);

    // if the user is authenticated, overwrite the author information
    if (SecurityUtils.isUserAuthenticated()) {
      PebbleUserDetails user = SecurityUtils.getUserDetails();
      if (user != null) {
        comment.setAuthor(user.getName());
        comment.setEmail(user.getEmailAddress());
        if (user.getWebsite() != null && !user.getWebsite().equals("")) {
          comment.setWebsite(user.getWebsite());
        } else {
          comment.setWebsite(blogEntry.getBlog().getUrl() + "authors/" + user.getUsername() + "/");
        }
        comment.setAuthenticated(true);
      }
    }
View Full Code Here

Examples of net.sourceforge.pebble.security.PebbleUserDetails

    // populate the author, email and website from one of :
    // - the logged in user details
    // - the "remember me" cookie
    if (SecurityUtils.isUserAuthenticated()) {
      PebbleUserDetails user = SecurityUtils.getUserDetails();
      if (user != null) {
        comment.setAuthor(user.getName());
        comment.setEmail(user.getEmailAddress());
        if (user.getWebsite() != null && !user.getWebsite().equals("")) {
          comment.setWebsite(user.getWebsite());
        } else {
          comment.setWebsite(blogEntry.getBlog().getUrl() + "authors/" + user.getUsername() + "/");
        }
        comment.setAuthenticated(true);
      }
    } else {
      try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.