Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How to pass attributes from java filter to doFilter(PLEASE HELP... I have a filter that gets the LDAP info, I'm just trying to pass the empid from the public boolean isUserAuthorized section to the doFilter section empid = attributes.get("empid&qu)
How to pass attributes from java filter to doFilter [message #1732318] Sun, 15 May 2016 18:29
Deon Gee is currently offline Deon GeeFriend
Messages: 2
Registered: May 2016
Junior Member
I have a filter that gets the LDAP info, I'm just trying to pass the empid from the public boolean isUserAuthorized section to the doFilter section empid = attributes.get("empid").toString(); System.out.print("DoFilter empid: " +empid); but it is not working. What am I doing wrong?

PLEASE HELP I've been working on this for 2 weeks.

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.sql.DataSource;

import org.apache.commons.configuration.Configuration;

public class myFilter extends LdapFilter {
public static FilterConfig filterConfig;
public static Attributes attributes;
public AuditOracleImpl auditor = null;

public void init(FilterConfig filterConfig) throws ServletException {
  List<String>categories = new ArrayList<String>();
  try {
  } catch (Exception ex) { 
    throw new ServletException(ex);
  try {
   // Load configuration properties.
   List<String> configList = new ArrayList<String>();

   Configuration config = SystemUtils.getConfiguration(configList);
   String strDbConnTCA = config.getString("DB_CONN_TCA");
   String strDbUserTCA = config.getString("DB_USER_TCA");
   String strDbPassTCA = config.getString("DB_PASS_TCA");
   String strWallet = config.getString("WALLET_FILE");

   //Obtain connection to the database.
   DataSource dataSourceCa = OracleClient.getDataSource(strDbConnTCA, strDbUserTCA, trDbPassTCA, strWallet);
   auditor = new AuditOracleImpl(dataSourceCa);
   } catch (Exception ex) {
   logger.error("Unable to create auditor {}", ex.getMessage());

 public boolean isUserAuthorized(Attributes attributes) {
  boolean isAuthorized = false;
  if (attributes !=null && attributes.size() > 0 ) {
    isAuthorized = true;"Authorized: " + isAuthorized);
    Properties properties = new Properties();
  try {
   propertiesUser.setProperty("CN", attributes.get("actualdn").get().toString().replaceFirst("CN=", "")); 
   propertiesUser.setProperty("EID", attributes.get("empid").get().toString();
   propertiesUser.setProperty("EMAIL", attributes.get("empemail").get().toString();

  } catch (Exception e) {
   logger.error("Error updating user:{}", e.getMessage());
  String[] items = {"accesstime", "empid", "ipAddress", "actualdn", "empemail"};
  String result = parseData(items, attributes);
  String empid = attributes.get("empid").toString(); 
  //this is what i'm tyring to put in parameter to pass to the next servlet.;
    System.out.print("This is the empID: " + empid); 
    //this prints out okay
   }"isAuthorized: " + isAuthorized);
 return isAuthorized;

public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain, Attributes attributes) throws IOException, ServletException {
     empid = attributes.get("empid").toString();
     chain.doFilter(request, response);
     System.out.print("DoFilter empid: " +empid); 
     //Nothing prints out.
public void destroy() {
Previous Topic:!MESSAGE [SCR] Method was not found:
Next Topic:Creating custom product/site/repository
Goto Forum:

Current Time: Sat Mar 24 23:51:51 GMT 2018

Powered by FUDForum. Page generated in 0.01587 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software