Jar for download from the page (same as prettyfaces).

Splash Forums Rewrite Users Jar for download from the page (same as prettyfaces).

This topic contains 35 replies, has 3 voices, and was last updated by  Tony Herstell 5 years, 6 months ago.

Viewing 15 posts - 1 through 15 (of 36 total)
  • Author
    Posts
  • #18268

    Tony Herstell
    Participant

    Can you provide a jar for download for ReWrite for those not interested in using Maven?

    (Please don’t Flame about Maven; I just choose to keep things simple as long as possible).

    #22348

    Tony Herstell
    Participant

    Humm.. that might not be as trivial as it sounds due to the many possible extensions.

    I am sure you can work something out to keep it simple for your users.

    #22349

    Actually it’s pretty simple for the core module :) rewrite-servlet.jar, but yeah, putting up links for all the extensions might be a pain. How about this?

    We can add the link to the main jar, then post the maven repo for people to go grab the extensions?

    Sound good?

    ~Lincoln

    #22350

    Tony Herstell
    Participant

    Yes please.

    Was hoping to move over today…

    #22351

    Tony Herstell
    Participant

    So as not to make it too boring; can you also post an example of how to get a “message” out from the ‘reWrite’ to show on the screen.

    I also have my login on the landing page; so will have to think that one out when I implement your re-write.

    I used the MultiPageMessageSupport that I believe I found on your site to solve the problem of messages not passing over pages, but can’t seem to get a “you are not logged in muppet” message to show on the screen.

    Not working:

    if (!passedLoginTrap && !bypassCheck) {
    this.logger.info("Redirecting...");
    FacesContext fc = this.facesContextBuilder.getFacesContext(httpServletRequest, httpServletResponse);
    FacesMessage accessViolationMessage = new FacesMessage("Access Denied; User is not logged in", "Access Denied; User is not logged in!");
    accessViolationMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
    fc.addMessage(null, accessViolationMessage);
    httpServletResponse.sendRedirect(NOT_LOGGED_IN_URL);
    } else {
    filterChain.doFilter(servletRequest, servletResponse);
    }
    this.logger.info("<< =========== doFilter");

    I am looking forward to re-write as this works but is ugly (I miss Seam 2):

    @WebFilter(urlPatterns = "/*")
    public class LoggedInFilter implements Filter {

    private Logger logger = Logger.getLogger(LoggedInFilter.class.getName());

    @Inject
    Identity identity;

    @Inject
    FacesContextBuilder facesContextBuilder;

    private List<String> allowedPagesWhenNotLoggedIn;
    static final String NOT_LOGGED_IN_URL = "/entermyevents/";

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
    HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;

    boolean bypassCheck = false;
    boolean passedLoginTrap = false;

    this.logger.info(">> =========== doFilter");
    if (this.identity.isLoggedIn()) {
    this.logger.info("User: " + this.identity.getName() + "(ID:" + this.identity.getLoggedInUserId() + ")");
    passedLoginTrap = true;
    } else {
    this.logger.info("User not logged in");
    String pageHeadingFor = httpServletRequest.getRequestURI();
    this.logger.info("heading to page: " + pageHeadingFor);
    if (pageHeadingFor.contains("javax.faces.resource")) {
    this.logger.info("It's a resource so ignore...");
    bypassCheck = true;
    } else if (pageHeadingFor.contains("img")) {
    this.logger.info("It's a resource so ignore...");
    bypassCheck = true;
    } else {
    LOGIN_PAGE_TRAP: for (String eachPage : this.allowedPagesWhenNotLoggedIn) {
    if (pageHeadingFor.equalsIgnoreCase(eachPage)) {
    this.logger.info("Passed Login Trap...");
    passedLoginTrap = true;
    break LOGIN_PAGE_TRAP;
    }
    }
    }
    }

    if (!passedLoginTrap && !bypassCheck) {
    this.logger.info("Redirecting...");
    FacesContext fc = this.facesContextBuilder.getFacesContext(httpServletRequest, httpServletResponse);
    FacesMessage accessViolationMessage = new FacesMessage("Access Denied; User is not logged in", "Access Denied; User is not logged in!");
    accessViolationMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
    fc.addMessage(null, accessViolationMessage);
    httpServletResponse.sendRedirect(NOT_LOGGED_IN_URL);
    } else {
    filterChain.doFilter(servletRequest, servletResponse);
    }
    this.logger.info("<< =========== doFilter");
    }

    @Override
    public void init(FilterConfig arg0) throws ServletException {
    this.logger.info(">> =========== init");
    this.allowedPagesWhenNotLoggedIn = new ArrayList<String>();
    this.allowedPagesWhenNotLoggedIn.add(NOT_LOGGED_IN_URL);
    this.allowedPagesWhenNotLoggedIn.add("/entermyevents/users/register");
    this.allowedPagesWhenNotLoggedIn.add("/entermyevents/error");
    this.allowedPagesWhenNotLoggedIn.add("/entermyevents/viewExpired");
    this.logger.info("<< =========== init");
    }

    @Override
    public void destroy() {
    this.logger.info(">> =========== destroy");
    this.logger.info("<< =========== destroy");
    }
    }

    #22352

    I don’t see that this has something to do with Rewrite. What you are trying to do is queuing a FacesMessage from within a ServletFilter, right?

    I actually don’t know if this is possible because you won’t have access to the FacesContext in this early stage of request processing.

    What kind of class is FacesContextBuilder your are injecting into your filter? Did you implement this class? What does it do?

    #22353
    #22354

    Tony Herstell
    Participant

    >> We can add the link to the main jar, then post the maven repo for people to go grab the extensions?

    I am figuring this is the jar I need for now…

    rewrite-servlet-1.0.3.Final.jar

    (http://repo1.maven.org/maven2/org/ocpsoft/rewrite/rewrite-servlet/1.0.3.Final/)

    and “possibly” the CDI Integration one for later…

    >> http://ocpsoft.org/java/persist-and-pass-facesmessages-over-page-redirects/

    Yes used to great success… but still can’t get a message to pop-out when in a filter (which may not be redundant as I move to re-write as it does, like, “everything”).

    #22355

    Tony Herstell
    Participant

    Seems to be all thats required.

    14:42:29,759 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-2) RewriteFilter initialized.

    Now to find some doco… and find how to thrown messages up to the faces context…

    ;)

    #22356

    Tony Herstell
    Participant

    Into my Configuration provider I added MY Identity (import com.entermyevents.userManagement.Identity):

    @Inject
    private Identity identity;

    I access identity in the getConfiguration and it’s null

    if (identity.isLoggedIn()) {

    Being pure J6EE (the only added libs so far are primefaces and re-write) I though; ok add the CDI lib:

    rewrite-integration-cdi-1.0.3.Final.jar

    but this didn’t help…

    in here:

    https://github.com/ocpsoft/socialpm/blob/master/web/src/main/java/com/ocpsoft/socialpm/rewrite/AuthenticationStatusInterceptor.java

    you Inject your profile…

    Am I missing something (like a Jar).

    Added for re-write:

    rewrite-servlet-1.0.3.Final.jar
    rewrite-integration-cdi-1.0.3.Final.jar

    #22357

    Hmmm. That should do it. Are you sure that you have CDI enabled in your application? Could you also post the log output from the RewriteFilter startup? It will list all the extensions that are enabled.

    #22358

    Tony Herstell
    Participant
    15:09:15,060 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) RewriteFilter starting up...
    15:09:15,074 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [1] org.ocpsoft.rewrite.servlet.spi.RewriteLifecycleListener [org.ocpsoft.rewrite.cdi.bridge.RewriteLifecycleEventBridge<-100>]
    15:09:15,074 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [2] org.ocpsoft.rewrite.servlet.spi.RequestCycleWrapper [org.ocpsoft.rewrite.cdi.bridge.RequestCycleWrapperBridge<0>, org.ocpsoft.rewrite.servlet.impl.HttpRewriteRequestCycleWrapper<0>]
    15:09:15,075 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [2] org.ocpsoft.rewrite.spi.RewriteProvider [org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider<0>, org.ocpsoft.rewrite.cdi.bridge.RewriteProviderBridge<100>]
    15:09:15,076 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [1] org.ocpsoft.rewrite.servlet.spi.InboundRewriteProducer [org.ocpsoft.rewrite.servlet.impl.HttpInboundRewriteProducer<0>]
    15:09:15,077 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [1] org.ocpsoft.rewrite.servlet.spi.OutboundRewriteProducer [org.ocpsoft.rewrite.servlet.impl.HttpOutboundRewriteProducer<0>]
    15:09:15,079 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [0] org.ocpsoft.rewrite.servlet.spi.ContextListener []
    15:09:15,081 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [0] org.ocpsoft.rewrite.servlet.spi.RequestListener []
    15:09:15,082 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [0] org.ocpsoft.rewrite.servlet.spi.RequestParameterProvider []
    15:09:15,095 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [1] org.ocpsoft.rewrite.spi.ExpressionLanguageProvider [org.ocpsoft.rewrite.cdi.CdiExpressionLanguageProvider]
    15:09:15,097 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [0] org.ocpsoft.rewrite.spi.InvocationResultHandler []
    15:09:15,099 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [1] org.ocpsoft.common.spi.ServiceEnricher [org.ocpsoft.rewrite.cdi.CdiServiceEnricher]
    15:09:15,102 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) Loaded [1] org.ocpsoft.rewrite.config.ConfigurationProvider [com.entermyevents.configurationProvider.EnterMyEventsConfigurationProvider<10>]
    15:09:15,102 INFO [org.ocpsoft.rewrite.servlet.RewriteFilter] (MSC service thread 1-1) RewriteFilter initialized.

    #22359

    Tony Herstell
    Participant

    As for having CDI enabled in my application… what am I looking for.

    As I am using J6EE; its supposed to be there!

    I am trying to just use a clean J6EE as I can.

    #22360

    Tony Herstell
    Participant

    Humm… now @URLQueryParameter is not there any more

    @SuppressWarnings("unused")
    @URLQueryParameter("cid")
    private String cid;

    and URLMappings(mappings … are not there any more

    @URLMappings(mappings = { @URLMapping(id = "manageUsers", pattern = "/users/manage", viewId = "/pages/users/manageUsers.xhtml"),
    @URLMapping(id = "registerUser", pattern = "/users/register", viewId = "/pages/users/CRUDUser.xhtml"),
    @URLMapping(id = "createUser", pattern = "/users/create", viewId = "/pages/users/CRUDUser.xhtml"),
    @URLMapping(id = "readUser", pattern = "/users/view", viewId = "/pages/users/CRUDUser.xhtml"),
    @URLMapping(id = "updateUser", pattern = "/users/update", viewId = "/pages/users/CRUDUser.xhtml"),
    @URLMapping(id = "deleteUser", pattern = "/users/delete", viewId = "/pages/users/CRUDUser.xhtml") })

    I assume taking out prettyfaces blew them away as I need to write re-write rules…

    But, is it me, or are the docs quite well hidden?

    #22361

    You need to have a in WEB-INF/beans.xml file, is that there?

Viewing 15 posts - 1 through 15 (of 36 total)

You must be logged in to reply to this topic.

Comments are closed.