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

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

#22362

Tony Herstell
Participant

To finish the puzzle…

package com.entermyevents.configurationProvider;

import javax.inject.Inject;
import javax.servlet.ServletContext;

import org.ocpsoft.common.services.NonEnriching;
import org.ocpsoft.rewrite.config.Configuration;
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
import org.ocpsoft.rewrite.servlet.config.rule.Join;

import com.entermyevents.userManagement.Identity;

public class EnterMyEventsConfigurationProvider extends HttpConfigurationProvider implements NonEnriching {

@Inject
private Identity identity;

@Override
public int priority() {
return 10;
}

@Override
public Configuration getConfiguration(final ServletContext context) {

// The standard annotations on my pages will provide
// "pretty re-write rules".
// e.g.

ConfigurationBuilder config = ConfigurationBuilder.begin();
if (identity.isLoggedIn()) {
// For now I am happy to allow access to all pages...

// config.defineRule().when(Direction.isInbound().and(Path.matches("/some/{page}/.*/"))).perform(Redirect.permanent("/new-{page}/"));

}
else {
// Check if they are going to one of these "allowed" pages:
// Allowed pages when not logged in
// /entermyevents/users/register
// /entermyevents/error
// /entermyevents/viewExpired
// and if not then force them to the Home (landing) page (where they
// can login)

config.addRule(Join.path("/").to("/pages/landing.xhtml"));
}
return config;
}
}