1 Reply Latest reply on Jul 21, 2015 2:07 AM by o.wagner

    Trying to extend the login action

    o.wagner

      Hi all,

       

      After setting up (successfully ) a local Jive instance, I try to develop a plugin for Jive sbs 8. I'm very new to Jive and some accompanied techniques. After reading tutorial after tutorial I've reached a point from which I do not get ahead. I have to add some logic to the login action / extend the rememberMeEnabled()-Method.

      Here are some documents, I've read for now and tried to use: Override struts login action in Jive 6, Override login action in jive 7, Core Help, Building Plugins, A Straight and To-The-Point 'Hello World' Plugin for Jive 5.0Building Plugins and some other.

      For now, I have a structure like this:

       

      MyCustomLoginPlugin.java:

      package xxx.yyy;
      //imports
      public class MyCustomLoginPlugin implements Plugin {
        private static final Logger log = LogManager.getLogger(LoginAction.class);
        @Override
        public void initPlugin() {
             log.info("Starting the MyCustomLoginPlugin...");
        }
        @Override
        public void destroy() {
             log.info("Stopping the MyCustomLoginPlugin...");
        }
      }
      

      MyCustomLoginAction.java:

      package xxx.yyy;
      //imports
      public class MyCustomLoginAction extends LoginAction  {
        private static final long serialVersionUID = -6477635117310245921L;
        private static final Logger log = LogManager.getLogger(LoginActin.class);
        @Override
        public boolean isRememberMeEnabled() {
           //logging etc.
           //logic with returns...
      }
      

      Plugin.xml:

      <plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="http://www.jivesoftware.com/schemas/clearspace/2_5/plugin.xsd">
          <name>MyCustomLogin</name>
          <description>MyCustomLogin</description>
          <author>My Name</author>
          <version>1.0.0</version>
          <minServerVersion>8.0.0.0</minServerVersion>
          <maxServerVersion>8.0.0.0</maxServerVersion>
          
        <!-- you will want to change your class name here! -->
          <class>xxx.yyy.MyCustomLoginPlugin</class>
       <!-- 
          <authorURL>
          <pluginURL>
          <databaseKey>
          <databaseVersion>
          <components>
          <css>
          <soy>
          <javascript>
          <widget>
          <macro>
          <urlmapping>
          <sitemesh>
        -->
      </plugin>
      

      Struts.xml:

      <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
              "http://struts.apache.org/dtds/struts-2.0.dtd">
      <struts>
        <package name="MyCustomLogin-actions" namespace="/"
        extends="community-actions-include">
        <action name="login" class="xxx.yyy.MyCustomLoginAction">
        <result name="input">/template/global/login.ftl</result>
        <result name="unauthenticated">/template/global/login.ftl</result>
        <result name="unauthorized">/template/global/unauth.ftl</result>
        <result name="create-profile" type="redirect">create-account.jspa?username=${username}
        </result>
        </action>
        </package>
      </struts>
      

       

      Since my knowledge about spring is very limited - what do I have to add to the spring.xml? I've tried some things but nothing happend. In the server log there is a entry for the "Starting the MyCustomLoginPlugin" from the MyCustomLoginPlugin.java, but nothing more. I'm pretty sure that I am missing some relevant points..

      And is the content of my project correct for now or am I on a completely wrong way?

        • Re: Trying to extend the login action
          o.wagner

          Okay, can answer the question by myself. I've had an syntax mistake in the struts.xml: it should be namespace="/" but i had namespace="\". must be a copy&paste mistake. after correcting this, it works. thanks anyway

          if someone want to do something similar, here is the spring.xml I am using:

          <?xml version="1.0" encoding="UTF-8"?>
          <!-- Copyright 2008 Jive Software Licensed under the Apache License, Version 
            2.0 (the "License"); you may not use this file except in compliance with 
            the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
            Unless required by applicable law or agreed to in writing, software distributed 
            under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
            OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
            the specific language governing permissions and limitations under the License. -->
          <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
            xmlns:util="http://www.springframework.org/schema/util" xmlns:tx="http://www.springframework.org/schema/tx"
            xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
            xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxws="http://cxf.apache.org/jaxws"
            xmlns:jaxrs="http://cxf.apache.org/jaxrs"
            xsi:schemaLocation="
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
          http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd
          http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
          http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
          http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"
            default-autowire="no" default-init-method="init"
            default-destroy-method="destroy">
          
           <bean id="CustomLogin" class="xxx.yyy.MyCustomLoginPlugin">
            </bean>
            <bean id="CustomLoginAction" class="xxx.yyy.MyCustomLoginAction">
            <property name="externalLoginConfiguration" ref="externalLoginConfiguration"></property>
            <property name="externalLoginManager" ref="externalLoginManager"></property>
            <property name="facebookConfiguration" ref="facebookConfiguration"></property>
            <property name="formAuthenticationRedirectStrategy" ref="formAuthenticationRedirectStrategy"></property>
            <property name="kerberosConfiguration" ref="kerberosConfiguration"></property>
            <property name="ldapConfiguration" ref="ldapConfiguration"></property>
            <property name="refererHelper" ref="refererHelper"></property>
            <property name="samlConfiguration" ref="samlConfiguration"></property>
            </bean>
          </beans>