Fórumok
How to login to another website from my portlet?
How to login to another website from my portlet?
Junior Member Bejegyzések: 81 Csatlakozás dátuma: 2008.04.01. Legújabb bejegyzésekI am trying to login to another website from my portlet(in fact, an action class).
Of course, I can provide some login information for that website. I wonder how can I login to another website without inputting everytime my username and password at that website. Because I am trying to integrate that website into my liferay portlet. And I want to login the user to my integrated website at the same time he login to my portal.
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 29 Csatlakozás dátuma: 2008.03.31. Legújabb bejegyzésekhope this helps,
Peter
RE: How to login to another website from my portlet?
Regular Member Bejegyzések: 154 Csatlakozás dátuma: 2008.02.19. Legújabb bejegyzésekYou might want to check out com.liferay.portal.events.LoginPostAction and portal-ext.properties. If you have the credentials for the other system, you can handle the login on behalf of the user and same them a few steps
Eric
## Portal Events
login.events.post=com.millerzell.liferay.portal.events.LoginPostAction
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2008.10.31. Legújabb bejegyzésekHere is the whole source of the 3party website (attached)
Here are the relevant items:
<body onload="preloadImages();">
<FORM NAME="frmLogin" METHOD="POST" ACTION="https://www.fscservicenet.com/customer/Login.asp">
<INPUT TYPE="HIDDEN" NAME="Validate" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="OldQS" VALUE="ReferrerURL=Default.asp&">
<INPUT TYPE="HIDDEN" NAME="ReferrerURL" VALUE="Default.asp">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
and
<TD align=left bgcolor="#EEEEEE"><strong>Username:</strong><BR>
<INPUT TYPE="text" NAME="username" SIZE="10">
<td bgcolor="#EEEEEE">
<B>Password:</B><BR>
<INPUT TYPE="password" NAME="password" SIZE="15">
The website URL is www.fscorp.com but it looks as though the login goes to the URL above. If you try to bypass fscorp.com all together (and just have the iframe load fscservicenet.com instead there is no referrerurl (see top code).
I can load the website (fscorp.com) without auth and then login manually, however can someone help me with the settings on the iframe porlet?
Source URL ... http://www.fscorp.com
Relative to Context Path y/n
Authenticate Y
Authentication Type Basic OR Form (Form I think)
Form Method Get OR Post (Post I think)
User Name
Password
Hidden Variables do I need to define vars for text and password?
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2008.10.31. Legújabb bejegyzésekWhen looking at the source you must analyze the form to find the name of the variables and input these as well.
For example:
<td align="right" valign="middle"><form action="https://www.financeware.com/login/authenticate.asp" method="POST" target="_parent"><br><br><img src="../images/login_username.jpg" WIDTH="90" HEIGHT="8"></td>
<td valign="middle"><br/><br/><input type="text" id="login_name" name="login_name" size="18" value="addvalue"/></td>
</tr>
<tr>
<td align="right" valign="middle"><img src="../images/login_password.jpg" WIDTH="90" HEIGHT="15"></td>
<td valign="middle">
<input type="password" id="password" name="password" value="" size="18"/>
<input type="hidden" id="UserContextGUID" name="UserContextGUID" value="2D604DCF16904D86AB9A8A8756FAF37B"/>
</td>
In the IFRAME configuration you must input:
URL: https://www.financeware.com/login/authenticate.asp ( This is different then the url for the login page btw, but not always)
Username: login_name=XXXXXXX (The "login_name" field can be found by looking at the source form)
Password: password=XXXX (The "password" field can be found by looking at the source form)
Hidden: UserContextGUID=2D604DCF16904D86AB9A8A8756FAF37B (Some forms have hidden fields in multiple places in the source, do a find for "hidden" when looking)
ETC
the Form methods and authentication should be seen from the source (In this case, FORM and POST)
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 28 Csatlakozás dátuma: 2009.06.03. Legújabb bejegyzésekI talked to my team and I think the use of a LDAP server would be a better idea for our organization. However, I noticed something about the "Leave the user name and password fields blank to use your current login information" suggestion in the settings page of iFrame : it will set your userid number instead of your screenname (or anything else wished) and a blank password. The only way to make it fit well is to hardcode something in the fields "Values". I would like to know if its possible to assign a variable content (something like ${cn}) to input directly some informations about current user.
Thank you for your help.
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 28 Csatlakozás dátuma: 2009.06.03. Legújabb bejegyzésekTo answer to my question, I found an alternative not completely dumb but not completely open for extension. I played in a jsp code of the Iframe .jsp to add a function that uses an algorithm to build the login (ex : last name + first letter of the first name) by using the variables of PortalUtil class. For the password, I did,nt have to change anything because the input of this one was already working fine. That approach is working fine for an environment where you look to work with the same login+password for the entire portal (excatly what a LDAP does like I heard, I'm intership so !). If you want more information about this practice, just ask me.
Have a good day all.
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2008.10.31. Legújabb bejegyzésekHi,
To answer to my question, I found an alternative not completely dumb but not completely open for extension. I played in a jsp code of the Iframe .jsp to add a function that uses an algorithm to build the login (ex : last name + first letter of the first name) by using the variables of PortalUtil class. For the password, I did,nt have to change anything because the input of this one was already working fine. That approach is working fine for an environment where you look to work with the same login+password for the entire portal (excatly what a LDAP does like I heard, I'm intership so !). If you want more information about this practice, just ask me.
Have a good day all.
Im interested to hear more... =)
Ryan
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 28 Csatlakozás dátuma: 2009.06.03. Legújabb bejegyzésekFirst of all, you have to go in the file /ROOT/html/portlet/iframe/proxy.jsp at the line 60 to see something looking like that :
if (Validator.isNull(userNameField)) {
int pos = userName.indexOf(StringPool.EQUAL);
if (pos != -1) {
String fieldValuePair = userName;
userNameField = fieldValuePair.substring(0, pos);
userName = fieldValuePair.substring(pos + 1);
preferences.setValue("user-name", userName);
preferences.setValue("user-name-field", userNameField);
preferences.store();
}
}
this defines what it will takes to authenticate when you use the authenticate mode in the configuration of the iFrame portlet. The problem was that it takes the id of the user (a random number not really significative) and we want to use the username (if it's not the case, I don't know what is the utility to read that!).
A way to use the user name is to create a function to make the username by string manipulation. Like that :
if (Validator.isNull(userName) && Validator.isNotNull(userNameField)) {
userName = PortalUtil.getUserName(PortalUtil.getUserId(renderRequest), "test");
userName= (userName.substring(userName.indexOf(' '), userName.length()) + userName.charAt(0)).toLowerCase().trim();
}
Remember :
- This way to do things is REALLY bad for future extension.
- It supposes that you will use the same login informations for all the websites who needs authentication.
You can also use the same model for the password information,
HTH
Joffré
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2008.10.31. Legújabb bejegyzésekMy days of coding are a bit old but I think I see what you are doing.
What I am trying to do is hardcode form data into different versions of the iframe portlet (I believe like you are).
Currently you have to examine the form to find what is being passed and the names of it, usually user/pass/hidden vars and then input that into the form with your credentials such as
username [________________________] where [_________________] the field you modify on the config page to user=joeblogs
so the config part of the portlet looks like:
username [user=joeblogs] (without the [ ] of course)
It is too hard for users to know this, they will just want to enter in their credentials so I need to hard code the specific form data behind the scences to fill in that field so a user just needs to type in joeblogs not user=joeblogs as well as the specific login page for the form.
I will have 20 or so of these iframe portlets hard coded and then easily deployed.
Is that what you are doing here? Do you think it would be the same?
I can put together a list of whats needed to hard code and will DONATE $10 per iframe portlet to LR if anyone is interested.... Its not much but then again I am poor =)
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 28 Csatlakozás dátuma: 2009.06.03. Legújabb bejegyzésekThanks for the credentials. I have'nt checked that before. I'll give you news soon.
Joffré
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2008.10.31. Legújabb bejegyzésekI have jumped on odesk and am trying to sort it out...I got a guy who can at least hard code the url, and I am just trying to get him to understand how the rest is processed.
I can try and release these to the community but they will be site specific, prob not any use to anyone... my coder suggested programming in the ext environment, after saying he should use hooks. I am not familar with either but I need the original iframe portlet too, on top of teh site specific ones.
Maybe I will ask Brian... its his baby
RE: How to login to another website from my portlet?
Junior Member Bejegyzések: 28 Csatlakozás dátuma: 2009.06.03. Legújabb bejegyzésekRE: How to login to another website from my portlet?
Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2008.10.31. Legújabb bejegyzésekI have attached a picture of the portlet. (As you can I see I also like netflix haha)
I want to get the url hard coded (so users dont have to think about this when they deploy the app without me) and form field data hard coded.
As you can see you have to type username=mysusername and password=mypassword to authenticate. The reason why is explained in a wiki, but essentially the form on the 3rd party website has fields (in this case called username and password, which could be differenent for each website, I have seen user, pass, etc)
The iframe takes the data and submits it to the 3rd party form under the correct name, in this case username, and the data it passes is myusername.
I would like to hard code the field data (and the hidden variables) so a user can deploy "Abc iframe portlet" and then go to the config and just type their username without having to know the form variables because I hard coded them in.
This way a user can do it themselves without having to think too much. I am a half idiot, and it took me a long time to figure out you just dont type your username in the field haha Maybe I should read directions more... =)
Mellékletek: