Package name.pehl.taoki.security

Source Code of name.pehl.taoki.security.TheAnswerCheck

package name.pehl.taoki.security;

import org.restlet.Request;
import org.restlet.Response;
import org.restlet.data.Form;

/**
* @author $Author: harald.pehl $
* @version $Date: 2012-03-02 08:50:20 -0600 (Fri, 02 Mar 2012) $ $Revision: 219 $
*/
public class TheAnswerCheck implements SecurityCheck
{
    @Override
    public void check(Request request, Response response) throws SecurityException
    {
        Form form = request.getResourceRef().getQueryAsForm();
        String answer = form.getFirstValue("answer");
        if (answer == null)
        {
            throw new SecurityException("No answer");
        }
        if (!"42".equals(answer))
        {
            throw new SecurityException("Wrong answer");
        }
    }
}
TOP

Related Classes of name.pehl.taoki.security.TheAnswerCheck

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.