• nikhilesh@helicaltech.com
  • +91-7893947676

Helical IT Solutions Pvt Ltd

One stop destination for all your BI, DW, Big Data needs

MENUMENU
  • Products
    • Helical Insight
    • Ask On Data
  • Services
    • AWS Quicksight Consulting
    • AWS Glue Consulting
    • Jaspersoft Consulting
    • Talend Consulting
    • Pentaho Consulting
    • Tableau Consulting
    • Pentaho Data Integration
    • Big Data Analytics
    • Data Lake Consulting
  • AI & Analytics
    • Generative AI Services
  • Modern Data Stack
    • DBT Services
    • Airflow Services
    • Airbyte Services
    • Databricks Services
    • Snowflake Services
  • Company
        • About Helical IT Solutions Pvt Ltd

          Helical IT Solutions Pvt Ltd, based out of Hyderabad India, is an IT company specializing in Data Warehousing, Business Intelligence and Big Data Analytics Services. Helical IT Solutions Pvt Ltd can help you in providing consultation regarding selecting of correct hardware and software based on your requirement, data warehouse modeling and implementation, big data implementation, data processing using Apache Spark or ETL tool, building data analysis in the form of reports dashboards with other features like data security, alerting and notification etc. Helical IT Solutions Pvt Ltd can use open source tool leading to low cost of ownership or your favorite proprietary tool to build the solution that you are looking for.

          • About
          • Careers
          • Contact
          • Engagement Models
          • Clients
          • Blog
  • Clients
  • Contact
        • Location

          View larger map
          • Helical IT Solutions Pvt Ltd.
            Somajiguda, Hyderabad

          • nitin@helicaltech.com
            nikhilesh@helicaltech.com

          • +91-7893947676

        • Contact Us

      • Search what you are looking for..

    Passing the extra parameter from login page Spring Security

    Posted on October 1, 2014 by By Nikhilesh, in Business Intelligence, Data Visualization | 3

    We have implemented spring security with database using hibernate in previous post.
    You can have a look at the previous post from the following link http://helicaltech.com/spring-security-with-hibernate/
    We had seen spring security supports username and password from login page by default.
    In this post we will learn how to pass extra parameter from login page to spring security.

    Make data easy with Helical Insight.
    Helical Insight is the world’s best open source business intelligence tool.

    Lets Start 30 Days Free Trail

    We know how to add spring and spring security jar’s in application class path using maven and adding dependencies in pom.xml file. By default spring submit the page to j_spring_security_check which use UsenamePasswordAuthenticationFilter for authenticating user which extends the AbstractAuthenticationProcessingFilter class.

    Below are the steps for implementation

    Step 1. Create the class which extends the UsenamePasswordAuthenticationFilter and override the two methods attemptAuthentication and obtainUsername

    public Authentication attemptAuthentication(HttpServletRequest req,HttpServletResponse res)
    throws AuthenticationException{
    }
    public String obtainUsername(HttpServletRequest req){
    }

    attemptAuthentication method takes the HttpServletRequest and HttpServletResponse arguments and return the Authentication object and obtainUsername takes the HttpServletRequest argument and return the String which contain the username and extra parameter passed by the login page with delimiter separator.
    Below is class with business logic I chose the class name as ExtInpuParam.

    public class ExtInpuParam extends
    UsernamePasswordAuthenticationFilter {
    private static final Logger logger = LoggerFactory
    .getLogger(PreUsernamePasswordAuthenticationFilter.class);
    private String extraParameter = "j_organization";
    private String delimiter = ":";
    @Override
    public Authentication attemptAuthentication(HttpServletRequest request,
    HttpServletResponse response) throws AuthenticationException {
    logger.debug("Attempting for authentication. " + "j_username = "
    + request.getParameter("j_username") + ", j_password = "
    + request.getParameter("j_password"));
    return super.attemptAuthentication(request, response);
    }
    @Override
    protected String obtainUsername(HttpServletRequest request) {
    String username = request.getParameter(getUsernameParameter());
    logger.debug("username = " + username);
    String extraInput = request.getParameter(getExtraParameter()) == null ? ""
    : request.getParameter(getExtraParameter());
    logger.debug("extraInput = " + extraInput);
    String combinedUsername = "";
    String extParam = extraInput.trim();
    logger.debug("extParam = " + extParam);
    if (extParam.length() == 0) {
    combinedUsername = username;
    } else {
    combinedUsername = username + getDelimiter() + extraInput;
    }
    logger.debug("returning combinedUsername = " + combinedUsername);
    return combinedUsername;
    }
    /**
    * @return The parameter name which will be used to obtain the extra input
    * from the login request
    */
    public String getExtraParameter() {
    return this.extraParameter;
    }

    /**
    * @param extraParameter
    * The parameter name which will be used to obtain the extra
    * input from the login request
    */
    public void setExtraParameter(String extraParameter) {
    this.extraParameter = extraParameter;
    }

    /**
    * @return The delimiter string used to separate the username and extra

    Make data easy with Helical Insight.
    Helical Insight is the world’s best open source business intelligence tool.

    Get your 30 Days Trail Version

    * input values in the string returned by
    * obtainUsername()
    */
    public String getDelimiter() {
    return this.delimiter;
    }

    /**
    * @param delimiter
    * The delimiter string used to separate the username and extra
    * input values in the string returned by
    * obtainUsername()
    */
    public void setDelimiter(String delimiter) {
    this.delimiter = delimiter;
    }

    }

    I passed the extra parameter name as j_organization from login page and adding delimiter “:” with username obtainUsername method will return the uername with extra parameter and “:” separator. In userDetails class you will get the username and extra parameter.

    Step 2. Add j_organization instance field with getter and setter in user model class.

    Step 3.
    Please refer to the code in the below snapshots for the steps to be followed for Step No 3.
    spring security

    spring security 2

    Step 4. Login.jsp page

    Make data easy with Helical Insight.
    Helical Insight is the world’s best open source business intelligence tool.

    Grab The 30 Days Free Trail


    <form name='loginForm'
    action="" method='POST'>

    Organization:
    User:
    Password:

     

    Thankyou
    Muqtar Ahmed
    Helical IT Solutions

    logo

    Best Open Source Business Intelligence Software Helical Insight is Here

    logo

    A Business Intelligence Framework


    Business Intelligence Hibernate jaspersoft Pass an additional parameter with spring security login page Passing the extra parameter from login page Spring Security pentaho single sign on Spring Security SSO
    5 1 vote
    Article Rating
    Subscribe
    Connect with
    Login
    I allow to create an account
    When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
    DisagreeAgree
    Notify of


    I allow to create an account
    When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
    DisagreeAgree
    3 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    extra login fields with spring security Account Official Log In Customer Service Contact Online Info - bankech.com
    3 years ago

    […] Passing the Extra Parameter from Login Page Spring Security […]

    -1
    Reply
    spring security form-login parameters - peterinfo
    2 years ago

    […] Passing the Extra Parameter from Login Page Spring Security […]

    0
    Reply
    spring security login page parameters – infopvp
    2 years ago

    […] Passing the Extra Parameter from Login Page Spring Security […]

    0
    Reply

    You might also like..

    Helical Insight

    Helical IT Solutions Launches Helical Insight 5.2.2 : Focus on Advance Embedded Analytics

    By admin

    24 Dec 2024: Helical IT Solutions is excited to unveil Helical Insight 5.2.2, the latest iteration of its cutting-edge Open Source Business Intelligence (BI) platform. This release reinforces Helical Insight's position as a cost-effective, versatile, and powerful alternative to mainstream...
    • December 26, 2024
    • 0
    Helical Insight 5.2.1

    Helical IT Solutions Launches Helical Insight 5.2.1: Elevating Open Source BI to New Heights

    By admin

    02 Sept 2024 – Helical IT Solutions is thrilled to announce the release of Helical Insight version 5.2.1, the latest upgrade to its Open Source Business Intelligence (BI) platform. This new version delivers a powerful, cost-effective BI solution that is...
    • September 2, 2024
    • 0
    Business Intelligence

    Installation of Firebird db

    By admin

    Steps to install firebird db 1. Go to google and type firebird in search box and then click on first link. License aggrement 2. Click on downloads and then install Firebird latest version(5.0.0). 3. It will navigate to the below...
    • April 30, 2024
    • 0

    Contact Form

      Let’s get started to unravel your best-fit solution.

      ABOUT HELICAL IT SOLUTIONS PVT LTD

      Helical IT Solutions Pvt Ltd specializes in Data Warehousing, Business Intelligence and Big Data Analytics. We offer consultation in selection of correct hardware and software as per requirement, implementation of data warehouse modeling, big data, data processing using Apache Spark or ETL tools and building data analysis in the form of reports and dashboards with supporting features such as data security, alerts and notification, etc.

      Learn More

      Blog

      Helical Blog

        

      Recent Posts

      • Helical IT Solutions Launches Helical Insight 5.2.2 : Focus on Advance Embedded Analytics December 26, 2024
      • Helical IT Solutions Launches Helical Insight 5.2.1: Elevating Open Source BI to New Heights September 2, 2024
      • Installation of Firebird db April 30, 2024

      © 2025 Helical IT Solutions Pvt Ltd

      0
      0Shares
      wpDiscuz
      Join Us