Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDIV parameter does not exist #95

Open
saranyaz opened this issue Jul 7, 2017 · 11 comments
Open

HDIV parameter does not exist #95

saranyaz opened this issue Jul 7, 2017 · 11 comments

Comments

@saranyaz
Copy link

saranyaz commented Jul 7, 2017

Hi
I am trying to integrate HDIV with my web application using HDIV struts 1.jar

I encounter the below error when trying to load the login page.

(self-tuning)'][][](org.hdiv.logs.Logger) - HDIV_PARAMETER_DOES_NOT_EXIST;/abc/def/index.do;_HDIV_STATE_;;;127.0.0.1;127.0.0.1;anonymous;

Possible checks I did:
1.tried with addition of struts--el tag lib with HDIV--el tag lib
2.tried with filter mapping pattern to all url

Not sure where I am going wrong. Many searches do not provide me a proper solution. Any guidance is highly appreciated. Thank you

Attached the config files

pom.txt
web.txt
hdiv-config.txt

@gillarramendi
Copy link
Member

Hi,
your hdiv-config.xml file is not correctly formatted. You can't have more tan one <hdiv:config>element in the same file.

Please have a look at this example application and configuration file:

@saranyaz
Copy link
Author

saranyaz commented Jul 7, 2017

Hi

I updated my config file now. I encounter the same error still.. Can kindly help to say where I am going wrong ?

hdiv-config.txt

<Jul 7, 2017 11:24:18 PM SGT> <Notice> <Stdout> <BEA-000000> <[DEBUG][2017-07-07 23:24:18,437][][[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kern el.Default (self-tuning)'][][](org.hdiv.filter.ValidatorHelperRequest) - Error restoring the state: Valid: false, Errorcode: ValidatorError [type=HDI V_PARAMETER_DOES_NOT_EXIST, target=/abc/index.do, parameterName=_HDIV_STATE_, parameterValue=null, originalParameterValue=null, localIp=null, remoteI p=null, userName=null, validationRuleName=null]> <Jul 7, 2017 11:24:18 PM SGT> <Notice> <Stdout> <BEA-000000> <[INFO ][2017-07-07 23:24:18,437][][[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kern el.Default (self-tuning)'][][](org.hdiv.logs.Logger) - HDIV_PARAMETER_DOES_NOT_EXIST;/abc/def/index.do;_HDIV_STATE_;;;127.0.0.1;127.0.0.1;anonymous;>

update:
after adding the startpages as /abc/index.do, I can load my application page. But for each ".do" page I am getting similar error as mentioned above, which leads to HDIV unauthorized error page.

@anderruiz
Copy link
Member

anderruiz commented Jul 7, 2017

Ok, we need some clarifications on this. You should set as StartPage every single page that can be accessed directly, usually / but there may be others. For the rest of them
you should be navigating using the links provided by the application. In those links if Hdiv integration is correct you should be seeing something like this:

/efm/whatever.do?HDIV_STATE=1-3-AABBCC..

I guess that your current problem is that no link is being generated with that parameter right?. If not please could you explain your situation?

@saranyaz
Copy link
Author

saranyaz commented Jul 7, 2017

Thanks for the response.
/efm/whatever.do?HDIV_STATE=1-3-AABBCC..
=> I don't see anything like this in my console and also in my logs.
all I see is as below with no random ID as you mentioned above.

HDIV_PARAMETER_DOES_NOT_EXIST;/abc/def/.do;HDIV_STATE;;;127.0.0.1;127.0.0.1;anonymous;>

My application's each menu link or buttons is initiated by a .do. so how do I config this ? looks like I need to all do. as start page which is not the correct way to implement. right ?
My application using struts 1.2.9.

The tld files are taken from the hdiv-master\hdiv-struts-1\target\classes\META-INF\ and I replaced it in my application tld file location /WEB-INF/tld/ and mapped it correctly in the web.xml file.

@gillarramendi
Copy link
Member

Hi,
you should see this kind of url in the HTML of your application: /efm/whatever.do?HDIV_STATE=1-3-AABBCC..
If Hdiv is configured correctly all links and forms contain an HDIV_STATE parameter in links and an extra hidden field in forms.
An important aspect to take into consideration is that you have to create the links and form using Struts tags.
Por example, <html:link> for links and <html:form> for forms.
This is the way Hdiv adds the HDIV_STATE parameter automatically.

Are you creating the links and forms using these tags?

@gillarramendi gillarramendi reopened this Jul 10, 2017
@saranyaz
Copy link
Author

Thanks for your reply

Yes, all the forms are using html:form struts tag. But still the HDIV parameter token is not generated. I am not sure where I am going wrong. I am still figuring it out !

@gillarramendi
Copy link
Member

Ok, the forms are created using Struts tags, and what about the links? Are they created using <html:link>tags?

@saranyaz
Copy link
Author

My application do not have html:links tags. All of the actions are triggered by context path .do file.

Struts token are inserted automatically as a hidden field in all JSP if I use saveToken() whereas I face issue with the token to be inserted with HDIV. jar

@gillarramendi
Copy link
Member

Ok, if you are interested in link protection you have to use <html:link> tag. Otherwise you will get HDIV_PARAMETER_DOES_NOT_EXIST error.

If you are not interested in link protection you have to exclude GET request protection.
Add this line inside <hdiv:config> tag in the hdiv-config.xml file:

<hdiv:startPages method="get">/.*</hdiv:startPages>

Including this config you will skip the protection of all requests that use method GET.
POST request protection is still enabled with this configuration.

Another important question, which Hdiv version are you using?
We recommend to use last stable version 3.3.0, which is compatible with Struts 1.3.8

@saranyaz
Copy link
Author

saranyaz commented Jul 19, 2017

ok, after I change the start pages as suggested above. I get the below error

org.hdiv.filter.ResponseWrapper) - New ResponseWrapper instance. [DEBUG][2017-07-19 10:46:00,630][][[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'][][](org.hdiv.session.SessionHDIV) - Getting page with id:00000000-0000-0000-0000-000000000018 [DEBUG][2017-07-19 10:46:00,630][][[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'][][](org.hdiv.filter.ValidatorHelperRequest) - Validation Error Detected: Parameter [org.apache.struts.taglib.html.TOKEN] does not exist in the state for action [/def/home.do] [INFO ][2017-07-19 10:46:00,630][][[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'][][](org.hdiv.logs.Logger) - INVALID_PARAMETER_NAME;/abc/def/home.do;org.apache.struts.taglib.html.TOKEN;;;192.168.91.1;192.168.91.1;anonymous;

I use the version 3.3.2.

ok. to use the 3.3.0 I download the codes for hdiv-config and hdiv-struts-1 from this link and compile it as a jar file https://github.com/hdiv/hdiv. is this the correct link ?

update:

after I include the below in hdiv config file

<hdiv:startParameters>org.apache.struts.action.TOKEN,org.apache.struts.taglib.html.TOKEN</hdiv:startParam

I get the same error as before

org.hdiv.filter.ResponseWrapper) - New ResponseWrapper instance. [DEBUG][2017-07-19 11:03:56,686][][[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'][][](org.hdiv.filter.ValidatorHelperRequest) - Error restoring the state: Valid: false, Errorcode: ValidatorError [type=HDIV_PARAMETER_DOES_NOT_EXIST, target=/def/ghiIndex.do, parameterName=_HDIV_STATE_, parameterValue=null, originalParameterValue=null, localIp=null, remoteIp=null, userName=null, validationRuleName=null] [INFO ][2017-07-19 11:03:56,686][][[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'][][](org.hdiv.logs.Logger) - HDIV_PARAMETER_DOES_NOT_EXIST;/abc/def/ghiIndex.do;_HDIV_STATE_;;;192.168.91.1;192.168.91.1;anonymous;

I can load my login page, I choose the role to login and click submit, I get the error as above.. (post action)

@gillarramendi
Copy link
Member

Hi,
Hdiv 3.3.0 jars are publicly available at the central Maven repository.
You can download them from this web too: http://search.maven.org/#artifactdetails%7Corg.hdiv%7Chdiv-core%7C3.3.0%7Cjar

It seems Hdiv Taglibs are not executing and the application is invoking Struts original tags instead.

You can check it adding a breakpoint at this method:

org.hdiv.taglib.html.FormTagHDIV.addHDIVParameter()

If should stop every time a form is rendered. If it is not invoked, the Tld is not correctly configured.

To check if the Hdiv taglib installation is correct, review this points:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants