Re: ERRest - IERXRestAuthenticationDelegate
Re: ERRest - IERXRestAuthenticationDelegate
- Subject: Re: ERRest - IERXRestAuthenticationDelegate
- From: Pascal Robert <email@hidden>
- Date: Mon, 05 Mar 2012 04:45:44 -0500
Le 2012-03-05 à 04:26, Ron X a écrit :
> Hi.
> IERXRestAuthenticationDelegate is considered deprecated.
> What class i should use?
> Thank you.
You can override performActionNamed in your REST controller to check if the request is authenticated. Example:
@Override
public WOActionResults performActionNamed(String actionName, boolean throwExceptions) {
try {
initTokenAuthentication();
} catch (MemberException ex) {
return pageWithName(LoginPage.class);
} catch (NotAuthorizedException ex) {
return pageWithName(LoginPage.class);
}
return super.performActionNamed(actionName, throwExceptions);
}
protected void initTokenAuthentication() throws NotAuthorizedException {
String tokenValue = this.request().cookieValueForKey("someToken");
if (tokenValue != null) {
String username = crypter.decrypt(tokenValue);
SomeEO eo = SomeEO.fetchSomeEO(editingContext(), SomeEO.USERNAME.eq(username));
if (eo == null) {
throw new NotAuthorizedException();
}
} else {
throw new NotAuthorizedException();
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden