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 protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to