back button of browser in spring security 3.2 + jsf - jsf

How to prevent user from going back to the login page
after successful login using back button of browser in spring security 3.2 and jsf
need custom filters? how to do ...
help me
​Thanks

for the same problem, I disabled button back in browser:
<SCRIPT type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
</SCRIPT>
Put this function in your welcome page.

Related

Embed Acumatica New Screen page in Website

I am trying to build a Support page for my website which should have Acumatica New Case Screen for customers to create a new Case. I tried using iFrame but when logged in, Selectors and dropdown don't respond. Any Suggestions how do I get New Case screen for my Support page just like in Acumatica Partner's portal.
This is working for me:
1) Create an acumatica portal web site; Make sure sp203000 page is accessible and works fine.
2) Create a simple html page and assign iframe src to be sp203000 screen url:
<!DOCTYPE html>
<html>
<body>
<style>
iframe {height:800px; width:1200px;}
</style>
<iframe src="http://localhost/AcuPortal/pages/sp/sp203000.aspx?CaseCD=null&CaseClassID=BILLING">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
And it works fine:
New Case form embedded into frame
First time you will see the login screen in the frame. If you want users to see the form without logging in you need to think about some SSO solution for your site and acumatica.

How to show a pop up only once in chrome extension?

Hi I need to show a pop up in chrome extension. I have set my website as a chrome extension.
Here is the use case:
When the user installs the extension, and clicks on the extension icon, it should show a pop up asking his username.
When user enters his name and login, the pop up gets closed.
This name is stored in local storage.
When user clicks the extension icon next time, it checks whether his name is stored in localstorage If not then it should again show pop up otherwise it should navigate to my website.
Now what my problem is that
When I click twice on the icon only, only then pop up appears.
After I enter name and click login pop up gets closed which is fine
When I click again on icon, actually it should navigate to the website, but in my code it again shows pop up.
When I reload the extension, it works correctly.
Please help me.
Here is my background.js
chrome.browserAction.onClicked.addListener(function(tab) {
if(!localStorage.username){
chrome.browserAction.setPopup({
popup: "userinfo.html"
}); }
else{
//navigate to website
});
here is my userinfo.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="test.js">
</script>
</head>
<body>
<font face="sans-serif"><b>Enter your Email ID</b></font><br><br>
<form id="userinfo">
<table><tr><td>
<font face="sans-serif"><label for="user">Email</label></font></td><td>: </td>
<td><input type="text" id="user" /></td><span id="semail"></span>
</table><br><br>
<font face="sans-serif"><input type="submit" id="login" value="Log In"/></font>
</form>
</body>
</html>
here is my test.js
window.addEventListener('DOMContentLoaded', function() {
var user = document.querySelector('input#user');
var form = document.querySelector('form#userinfo');
form.addEventListener('submit', function(evt) {
evt.preventDefault();
var userStr = user.value;
chrome.runtime.getBackgroundPage(function(bgPage) {
bgPage.login(userStr/*,pwdStr*/); });
window.close();
});
});
anyone please please help me
Let's go one by one with your problems.
1.When I click twice on the icon only, only then pop up appears.
When you click on extension icon, your browserAction.onClicked handler gets executed and it just sets the popup. It does not open it. You have to click on extension icon again to open the popup. That is why you have to click twice.
2.After I enter name and click login pop up gets closed which is fine.
This is because you are redirecting to a new page which closes the extension popup.
3.When I click again on icon, actually it should navigate to the website, but in my code it again shows pop up.
Since you have setup popup for extension click, it has over-ridden the chrome.browserAction.onClick handler which is why you are not able to navigate to your website.
4.When I reload the extension, it works correctly.
This is because after reload, your chrome.browserAction.onClick is not over-ridden by popup and since login credentials are present in localstorage, your code does not over-ride it.
Solution1
In background script, check if the credentials are stored in localstorage then do not set the popup, else set the popup.
Add the handler chrome.browserAction.onClick to always navigate to your website. You know that if popup opens then your handler will not be executed.
When you store the credentials in localstorage and if they are correct, remove the popup.
To remove popup, you can try chrome.browserAction.setPopup({popup: ""});
From chrome.broswerAction API
onClicked
Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.
Solution2
Popup has the same permissions which background scrips have. So instead of defining chrome.browserAction.onClicked event, just write your code in popup script.
Check the localstorage, if credentials are present, create a new tab and open your page and close the popup with window.close()
Otherwise don't close the popup.
PS: I have not tried it. Just giving you an idea.

From popup.html, how can I run a javascript function by button onclick?

I'm trying to build an extension for Chrome, but I'm a newbie and I'm having trouble understanding the Docs provided by Google. I want the extension to have a popup that shows a few buttons, and when a button is clicked, I want to run a script.
This is my setup:
popup.html
<button id="test1" onclick="getSite();">button 1</button>
<button id="test2" onclick="getSite();">button 2</button>
content_script.js
function getSite(){alert('getSite works!');}
I'm having trouble understanding how to use the chrome javascript api, as I see others saying use chrome.tabs.executeScript, but I can't figure out where that line goes. Can anyone help me? I'll give you a cookie! or just an upvote.. or maybe both?
You haven't mentioned on which page you want your scripts to run onclick, in Popup.html page or the page on which user is currently working on the browser. If it is just the popup.html page in which you want to execute your script, include them in popup.html page itself.
If however you want to execute them on the user's browser page, You will have to pass a message to your background page, which in turn will execute chrome.tabs.executeScript with current tab's id and {file: 'yourjsfile.js'} as arguments.
I think you are having this problem because of restrictions imposed by the Google Content Security Policy. It mentions that iniline javascript like the one that you have mentioned in you code will not be executed. Try removing the onclick="getSite()" from your HTML markup to content_script.js. Use addEventListener function to attach the event to the button.

Chrome extension

I just made a Chrome extension. I followed this tutorial to get a nice button in my toolbar. Now if I load a page, the javascript in my extension gets executed.
Unfortunately, if I click the extension's button in my toolbar, nothing happens.
Question: How do I make the js get executed when I click the extension's button in my toolbar?
Thanks for your help.
Edit
I added background.html and it still doesn't work:
<html>
<head>
<script>
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
var action_url = "javascript:mathjax.js";
chrome.tabs.update(tab.id, {url: action_url});
});
</script>
</head>
</html>
You have two options. Either, you can specify a "popup": "popup.html" in your manifest.json, then put the code in popup.html. In this case, the code will get executed in the popup (though of course you can communicate with your background page or anything else).
Probably better would be to put a callback in background.html by attaching a listener to chrome.browserAction.onClicked.
Chrome extension doesn't support inline javascript code in background.html.You must specify external javascript file.Also instead of specifying background.html you can directly specify external file in manifest file in background property.
I have answered similar question here.

Using Post when doing a sendRedirect

I have a requirement that a jsf page needs to be launched from a custom thin client in user browser (thin client does a http post). Since the jsf page may be invoked multiple times, I use a jsp to redirect to the jsf page with params on url. In jsp I do a session invalidation. The jsp code is below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%#page session="true" %>
<%
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
session.invalidate();
String outcome = request.getParameter("outcome");
String queryString = "outcome=" + outcome ;
response.sendRedirect("./faces/MyPage.jspx?" + queryString);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta>
<title>title here</title>
</head>
<body></body>
</html>
My jsf page uses mutiple drop down items with autoSubmit enabled. I set the params on session when the form first inits and then use it from there when an action button is ultimately clicked by user. Following is the code I use to get the param in jsf backing bean constructor:
FacesContext ctx = getFacesContext();
Map sessionState = ctx.getExternalContext().getSessionMap();
outcome = (String)sessionState.get("outcome");
if(outcome == null) //if not on session, get from url
outcome = (String)JSFUtils.getManagedBeanValue("param.outcome");
This way I can get the param even after multiple autoSubmits of drop downs.
My problem is that I cannot have parameters show up on browser address bar. I need a way so that the parameters can be passed to the jsp page. I cannot post direct to jsp from thin client since I need the jsf page to have a new session each time the client launches user browser. This is imp due to the above code snippet on how I use params in the jsf page.
Is there nay way to use a post when doing a sendRedirect so that I do not have to pass params on url? I cannot use forward since when an autoSubmit fires on jsf page, it causes the browser to refresh the jsp page instead.
Is there any better way to handle the jsf page itself so that I don't have to rely on storing params on session between successive autoSubmit events?
Since you invalidate the session, no, you cannot.
The only way would be putting it in the session scope. Why are you by the way invalidating the session on first request? This makes really no sense.
Unrelated to your actual problem, doing sendRedirect() in a scriptlet instead of a Filter and having a bunch of HTML in the same JSP page is receipt for big trouble. Do not write raw Java code in JSP files, you don't want to have that. Java code belongs in Java classes. Use taglibs/EL in JSP only.
No. Because sendRedirect send the web-browser/client a 302 with the new location and according to the following it will usually be a GET, no matter what the original request was.
According to HTTP/1.1 RFC 2616 http://www.ietf.org/rfc/rfc2616.txt:
If the 302 status code is received in response to a request other
than GET or HEAD, **the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user**, since this might
change the conditions under which the request was issued.
Note: RFC 1945 and RFC 2068 specify that the client is not allowed
to change the method on the redirected request. However, ***most
existing user agent implementations treat 302 as if it were a 303
response, performing a GET on the Location field-value regardless
of the original request method***. The status codes 303 and 307 have
been added for servers that wish to make unambiguously clear which
kind of reaction is expected of the client.
Maybe playing carefully with ajax can get you something.
Update: Then again, as user: BalusC pointed out, you can redirect by manually setting the headers, as in:
response.setStatus(307);
response.setHeader("Location", "http://google.com");

Resources