Is it possible to save some info about the user, so I can show/hide some contents in my web pages? How can I do that?Thank you very much.
... the "End users must log in to view this page" checkbox....
com.interwoven.livesite.external.LoginIfc
com.interwoven.livesite.external.impl.LDAPLogin
server="my.ldap.server" root.dn="dc=my-domain,dc=com" user.ou="ou=People";
<form type="login"><br> <input type="text" name="username"/><br> <input type="password" name="password"/><br> <input type="submit" value="Login"/><br> </form>
type=”login”
public int login(Map params, EndUserSite site, EndUserIfc user)
params
String username = (String) params.get("username"); String password = (String) params.get("password");
site
getSiteLogin()
Map config = site.getSiteLogin().getConfig(); String server = (String) config.get(SERVER); String rootDN = (String) config.get(ROOT_DN); ... List attribs = site.getSiteLogin().getAttributes();
user
com.interwoven.livesite.external.ExternalIfc
com.interwoven.livesite.external.BaseExternal
LoginIfc.LOGIN_SUCCESS
// login successful user.setIsLoggedIn(true, site.getName()); return LOGIN_SUCCESS;
LoginIfc.LOGIN_ERROR
// login failed return LOGIN_ERROR;
user.setAttribute(String, Object)
user.getAttribute(String)
public static Profile getProfile(EndUserIfc user) { Profile profile = (Profile) user.getAttribute(USER_ATTRIB_PROFILE); if (null == profile) { profile = new Profile(true); // anonymous profile user.setAttribute(USER_ATTRIB_PROFILE, profile); } return profile; }
com.interwoven.livesite.external.AuthNavigationIfc
public String getNextPage( EndUserSite site, EndUserIfc user, String lastPageVisited)
lastPageVisited
public class CustomerLogin implements LoginIfc, AuthNavigationIfc{ // workarea relative path to login file public static final String PASSWORD_FILE = "templatedata/Retail/Customer/users.xml"; // authentication xpath to user public static final String XPATH_AUTH = "/users/user[username='%1' and password='%2']"; // username parameter public static final String PARAM_USERNAME = "username"; // password parameter public static final String PARAM_PASSWORD = "password"; /** * Control post-login navigation */ public String getNextPage(EndUserSite site, EndUserIfc user, String lastPageVisited) { String target = site.getLoginPage(); if (user.getIsLoggedIn(site.getName())) { target = (target.equals(lastPageVisited)) ? "Account Summary" : lastPageVisited; } return target; } /** * Handle login. */ public int login(Map params, EndUserSite site, EndUserIfc user) { String username = (String) params.get(PARAM_USERNAME); String password = (String) params.get(PARAM_PASSWORD); if (null == username || null == password) { return LOGIN_ERROR; } try { String filePath = user.getFileDAL().getWebRoot(site) + user.getFileDAL().getSeparator() + PASSWORD_FILE; DOMWrapper dom = new DOMWrapper(user.getFileDAL().read(filePath)); String xpath = StringUtil.replaceFirst(StringUtil.replaceFirst( XPATH_AUTH, "%2", password), "%1", username); Node userNode = dom.selectSingleNode(xpath); // test for node, then double check username/password value if (null == userNode || !username.equals(dom.getNodeValue(userNode, PARAM_USERNAME)) || !password.equals(dom.getNodeValue(userNode, PARAM_PASSWORD))) { return LOGIN_ERROR; } // populate a customer profile Profile profile = Profile.getProfile(user); profile.setAnonymous(false); profile.setUserName(username); user.setLocale(new Locale(dom.getNodeValue(userNode, "locale"))); user.setIsLoggedIn(true, site.getName()); return LOGIN_SUCCESS; } catch (SAXParseException e) { throw new ExternalException("Login Failed", e); } }}