You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by Werner Ramaekers <we...@shiftat.com> on 2002/07/29 20:09:59 UTC
Custom Security Authentication
Hey,
i'm trying to create my own custom Authentication class because i need
to Authenticate the user's password against a hardware token Controller.
This means i need to verify the password presented by the users which
was generated by his token against the Controller for whic i know the API.
I'm having trouble to get a simple custom testAuthentication class running :
I've written a
public class CustomAuthentication extends TurbineBaseService implements
PortalAuthentication {
and implemented a simple login method :
public JetspeedUser login(String username, String password) throws
LoginException {
JetspeedUser user = null;
//see if we can make this work using a very basic
username/password test
if ("test".equals(username) && "test".equals(password)) {
System.out.println("username/pw are OK");
user = new BaseJetspeedUser();
System.out.println("user created");
user.setUserName(username);
System.out.println("username set");
// Mark the user as being logged in.
user.setHasLoggedIn(new Boolean(true));
System.out.println("login_date set");
// Set the last_login date in the database.
try {
//user.updateLastLogin();
putUserIntoContext(user);
System.out.println("user in context");
if (cachingEnable) {
System.out.println("trying to load cache");
JetspeedSecurityCache.load(username);
System.out.println("cache loaded");
}
}
catch (Exception e) {
System.out.println("exception occured");
putUserIntoContext(JetspeedSecurity.getAnonymousUser());
throw new LoginException("Failed to update last login
", e);
}
} else {
throw new LoginException("username/password combination not
known to me !");
}
when the user logs in i get a
Horrible Exception: java.lang.NullPointerException at
org.apache.jetspeed.modules.actions.JLoginUser.doPerform(JLoginUser.java:305)
at org.apache.turbine.modules.ActionEvent.perform(ActionEvent.java:148)
at org.apache.turbine.modules.ActionLoader.exec(ActionLoader.java:122)
at org.apache.turbine.Turbine.doGet(Turbine.java:456) at
org.apache.turbine.Turbine.doPost(Turbine.java:616) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
so i'm puzzled to say the least :
can anyone tell me what i'm supposed to do to make my own Authentication
class work ? How to create the JetspeedUser ?
What needs to be implemented ?
thanks for your time ;-)
Werner
--
----------------------------------------------------------------------
ir. Werner Ramaekers
Enterprise Java Solutions Architect - Shift@
Sun Certified Java Programmer
"May the source be with you."
<ma...@shiftat.com> <http://www.shiftat.com>
----------------------------------------------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Custom Security Authentication
Posted by Werner Ramaekers <we...@shiftat.com>.
great David,
that fixed it !
David Sean Taylor wrote:
> Sounds like the confirmed string is null.
>
> String confirmed = data.getUser().getConfirmed();
> if (confirmed == null ||
> !confirmed.equals(JetspeedResources.CONFIRM_VALUE ))
> {
> if (
> confirmed.equals(JetspeedResources.CONFIRM_VALUE_REJECTED))
> <==================
>
> I will add a patch in a minute:
>
> if ( confirmed != null &&
> confirmed.equals(JetspeedResources.CONFIRM_VALUE_REJECTED))
>
>
>
>>-----Original Message-----
>>From: Werner Ramaekers [mailto:werner@shiftat.com]
>>Sent: Monday, July 29, 2002 11:10 AM
>>To: jetspeed-dev@jakarta.apache.org
>>Subject: Custom Security Authentication
>>
>>
>>Hey,
>>
>>i'm trying to create my own custom Authentication class because i need
>>to Authenticate the user's password against a hardware token Controller.
>>This means i need to verify the password presented by the users which
>>was generated by his token against the Controller for whic i know the API.
>>
>>I'm having trouble to get a simple custom testAuthentication
>>class running :
>>I've written a
>>public class CustomAuthentication extends TurbineBaseService implements
>>PortalAuthentication {
>>
>>and implemented a simple login method :
>>
>> public JetspeedUser login(String username, String password) throws
>>LoginException {
>> JetspeedUser user = null;
>> //see if we can make this work using a very basic
>>username/password test
>> if ("test".equals(username) && "test".equals(password)) {
>> System.out.println("username/pw are OK");
>> user = new BaseJetspeedUser();
>> System.out.println("user created");
>> user.setUserName(username);
>> System.out.println("username set");
>> // Mark the user as being logged in.
>> user.setHasLoggedIn(new Boolean(true));
>> System.out.println("login_date set");
>> // Set the last_login date in the database.
>> try {
>> //user.updateLastLogin();
>> putUserIntoContext(user);
>> System.out.println("user in context");
>> if (cachingEnable) {
>> System.out.println("trying to load cache");
>> JetspeedSecurityCache.load(username);
>> System.out.println("cache loaded");
>> }
>> }
>> catch (Exception e) {
>> System.out.println("exception occured");
>> putUserIntoContext(JetspeedSecurity.getAnonymousUser());
>> throw new LoginException("Failed to update last login
>>", e);
>> }
>> } else {
>> throw new LoginException("username/password combination not
>>known to me !");
>> }
>>
>>when the user logs in i get a
>>Horrible Exception: java.lang.NullPointerException at
>>org.apache.jetspeed.modules.actions.JLoginUser.doPerform(JLoginUse
>>r.java:305)
>>at org.apache.turbine.modules.ActionEvent.perform(ActionEvent.java:148)
>>at org.apache.turbine.modules.ActionLoader.exec(ActionLoader.java:122)
>>at org.apache.turbine.Turbine.doGet(Turbine.java:456) at
>>org.apache.turbine.Turbine.doPost(Turbine.java:616) at
>>javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at
>>javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
>>
>>so i'm puzzled to say the least :
>>can anyone tell me what i'm supposed to do to make my own Authentication
>>class work ? How to create the JetspeedUser ?
>>What needs to be implemented ?
>>
>>thanks for your time ;-)
>>
>>Werner
>>
>>
>>--
>>----------------------------------------------------------------------
>>ir. Werner Ramaekers
>>Enterprise Java Solutions Architect - Shift@
>>Sun Certified Java Programmer
>>
>>"May the source be with you."
>><ma...@shiftat.com> <http://www.shiftat.com>
>>----------------------------------------------------------------------
>>
>>
>>--
>>To unsubscribe, e-mail:
>
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
----------------------------------------------------------------------
ir. Werner Ramaekers
Enterprise Java Solutions Architect - Shift@
Sun Certified Java Programmer
"May the source be with you."
<ma...@shiftat.com> <http://www.shiftat.com>
----------------------------------------------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Custom Security Authentication
Posted by David Sean Taylor <da...@bluesunrise.com>.
Sounds like the confirmed string is null.
String confirmed = data.getUser().getConfirmed();
if (confirmed == null ||
!confirmed.equals(JetspeedResources.CONFIRM_VALUE ))
{
if (
confirmed.equals(JetspeedResources.CONFIRM_VALUE_REJECTED))
<==================
I will add a patch in a minute:
if ( confirmed != null &&
confirmed.equals(JetspeedResources.CONFIRM_VALUE_REJECTED))
> -----Original Message-----
> From: Werner Ramaekers [mailto:werner@shiftat.com]
> Sent: Monday, July 29, 2002 11:10 AM
> To: jetspeed-dev@jakarta.apache.org
> Subject: Custom Security Authentication
>
>
> Hey,
>
> i'm trying to create my own custom Authentication class because i need
> to Authenticate the user's password against a hardware token Controller.
> This means i need to verify the password presented by the users which
> was generated by his token against the Controller for whic i know the API.
>
> I'm having trouble to get a simple custom testAuthentication
> class running :
> I've written a
> public class CustomAuthentication extends TurbineBaseService implements
> PortalAuthentication {
>
> and implemented a simple login method :
>
> public JetspeedUser login(String username, String password) throws
> LoginException {
> JetspeedUser user = null;
> //see if we can make this work using a very basic
> username/password test
> if ("test".equals(username) && "test".equals(password)) {
> System.out.println("username/pw are OK");
> user = new BaseJetspeedUser();
> System.out.println("user created");
> user.setUserName(username);
> System.out.println("username set");
> // Mark the user as being logged in.
> user.setHasLoggedIn(new Boolean(true));
> System.out.println("login_date set");
> // Set the last_login date in the database.
> try {
> //user.updateLastLogin();
> putUserIntoContext(user);
> System.out.println("user in context");
> if (cachingEnable) {
> System.out.println("trying to load cache");
> JetspeedSecurityCache.load(username);
> System.out.println("cache loaded");
> }
> }
> catch (Exception e) {
> System.out.println("exception occured");
> putUserIntoContext(JetspeedSecurity.getAnonymousUser());
> throw new LoginException("Failed to update last login
> ", e);
> }
> } else {
> throw new LoginException("username/password combination not
> known to me !");
> }
>
> when the user logs in i get a
> Horrible Exception: java.lang.NullPointerException at
> org.apache.jetspeed.modules.actions.JLoginUser.doPerform(JLoginUse
> r.java:305)
> at org.apache.turbine.modules.ActionEvent.perform(ActionEvent.java:148)
> at org.apache.turbine.modules.ActionLoader.exec(ActionLoader.java:122)
> at org.apache.turbine.Turbine.doGet(Turbine.java:456) at
> org.apache.turbine.Turbine.doPost(Turbine.java:616) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
>
> so i'm puzzled to say the least :
> can anyone tell me what i'm supposed to do to make my own Authentication
> class work ? How to create the JetspeedUser ?
> What needs to be implemented ?
>
> thanks for your time ;-)
>
> Werner
>
>
> --
> ----------------------------------------------------------------------
> ir. Werner Ramaekers
> Enterprise Java Solutions Architect - Shift@
> Sun Certified Java Programmer
>
> "May the source be with you."
> <ma...@shiftat.com> <http://www.shiftat.com>
> ----------------------------------------------------------------------
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>