nikhilboorla Posted May 1, 2013 Report Posted May 1, 2013 [color=#000000][font=verdana, arial, helvetica, sans-serif][size=3][background=rgb(240, 230, 213)]I need to read the cookie and getting fields like userid,username,groupid etc from usertable called USER which i have created.So,I have to add some features(VIEWCONFIG,ADDCLIENT,EDITCLIENT,VIEWINVOICE) to my portal (web app) and i need to set it to session by POPULATING THAT OBJECTS and load the authorizations from resources(resources are resourceID,user_ID,Insert,update,delete,browse etc) .[/background][/size][/font][/color] [color=#000000][font=verdana, arial, helvetica, sans-serif][size=3][background=rgb(240, 230, 213)]I am getting errors in this code.Please help!!![/background][/size][/font][/color] package com.comdata.fis.presentation.actions; import java.io.Serializable; import java.util.Iterator; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.comdata.core.fis.constants.AppConfigKeys; import com.comdata.core.fis.constants.AppContextKeys; import com.comdata.core.fis.util.systemhelpers.IBSSecurityHelper; import com.comdata.fis.web.WebUtils; import com.svs.core.constants.OxmoorSystemConstants; import com.svs.security.helper.ApplicationSecurityHelper; import com.svs.security.model.PortalSecurityPrincipal; public class InitAction extends OxmoorBaseAction { private static Logger log = Logger.getLogger(InitAction.class); public ActionForward appExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { log.info("This is the initial action - Portal will send you here with a Portal Cookie..."); final class PortalSecurityPrincipal { private static Logger log = Logger.getLogger(PortalSecurityPrincipal.class); private String userId; private String groupId; private String userName; public PortalSecurityPrincipal(final String user, final String group,final String fullName) { super(); userId = user; groupId = group; userName = fullName; } public PortalSecurityPrincipal () { super(); } public void load(final String user, final String group, final String fullName) { userId = user; groupId = group; userName = fullName; } public void clear() { this.userId = null; this.groupId = null; this.userName = null; } public String getUserName() { return userName; } public String getGroupId() { return groupId; } public String getUserId() { return userId; } public void setGroupId(String group) { this.groupId = group; } public void setUserId(String user) { this.userId = user; } public void setUserName(String fullName) { this.userName = fullName; } public final boolean equals(Object another) { if (another == null || !(another instanceof PortalSecurityPrincipal)) { return false; } else { PortalSecurityPrincipal other = (PortalSecurityPrincipal) another; return (userId.equalsIgnoreCase(other.getUserId()) && groupId.equalsIgnoreCase(other.getGroupId())); } } public String toString() { String strBuf; strBuf.delete(0,strBuf.length()); strBuf.append(" userId[" + this.userId + "]"); strBuf.append(" groupId[" + this.groupId + "]"); strBuf.append(" userName[" + this.userName + "]"); strBuf.append("\n******* Authorization Prod ********"); Iterator<String> itra = tmFatypes.iterator(); while(itra.hasNext()) { strBuf.append(" action id " + itra.next()); } return(strBuf.toString()); } public final int hashCode() { return (userId + groupId).toLowerCase().hashCode(); } public String getTmFatypes() { // TODO Auto-generated method stub return null; } } log.info("User validated successfully!"); PortalSecurityPrincipal principal = WebUtils.getSecurityPrincipal(request); IBSSecurityHelper iSec = new IBSSecurityHelper(); if (principal.getTmFatypes().contains(AppContextKeys.ADDCLIENT_FATYPE)) iSec.setAddClient(true); if (principal.getTmFatypes().contains(AppContextKeys.EDITCLIENT_FATYPE)) { iSec.setEditClient(true); // TODO: (dho) Remove debugging comment when things settle // iSec.setTempCreditEdit(true); } if (principal.getTmFatypes().contains(AppContextKeys.VIEWCONFIG_FATYPE)) iSec.setViewClient(true); if (principal.getTmFatypes().contains(AppContextKeys.VIEWAUDIT_FATYPE)) iSec.setViewAudit(true); if (principal.getTmFatypes().contains(AppContextKeys.VIEWINVOICE_FATYPE)) iSec.setViewInvoice(true); if (principal.getTmFatypes().contains(AppContextKeys.PAYMENTREVERSAL_FATYPE)) iSec.setPaymentReversal(true); if (principal.getTmFatypes().contains(AppContextKeys.TEMPCREDITEDIT_FATYPE)) iSec.setTempCreditEdit(true); WebUtils.setSecurityRights(request, iSec); return mapping.findForward(AppContextKeys.ACTION_CLIENT_LIST); } } catch (Exception e) { log.error(e.getStackTrace()); log.error("Something unexpected happened : " + e.toString()); } log.info("You failed validation...go back to default page...."); // determine app access and put object in session // default should always go back to login page if in doubt return mapping.findForward(AppContextKeys.PAGE_NOTAUTH); }
Recommended Posts