Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:41:16+00:00 2026-05-30T17:41:16+00:00

i have the following customized security controller using the secure module for play: public

  • 0

i have the following customized security controller using the secure module for play:

public class Security extends Secure.Security {

    static boolean authenticate(String username, String password) {

        validation.required(username);
        validation.required(password);

        if (!validation.hasErrors()) {
            BetaUser user = BetaUser.find("username", username).first();

            if (user != null && user.password.equals(password)) {
                Session.current().put("userid", user.id);
                return true;
            }

            return false;
        }
        else {
            return false;
        }
    }

    static void onAuthenticated() {
        Series.userSeries();
    }

    static void onDisconnected() {
        Application.index();
    }

    static boolean check(String profile) {
        if ("admin".equals(profile)) {
            return Security.connected().equals("admin");
        }
        return false;
    }
}

In this case the validation mechanism in the authenticate methode works. When i use annotations the password parameter doesn`t get validatet anymore:

static boolean authenticate(@Required String username, @Required String password) {

    if (!validation.hasErrors()) {
        BetaUser user = BetaUser.find("username", username).first();

        if (user != null && user.password.equals(password)) {
            Session.current().put("userid", user.id);
            return true;
        }

        return false;
    }
    else {
        return false;
    }
}

The strange thing is, that the username validation actually does work (error when username is empty). When only the password is left empty the validation has no errors…

I hope that you can help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:41:17+00:00Added an answer on May 30, 2026 at 5:41 pm

    After I dig around,

    Validating HTTP data with play

    Validations ensure that the data has certain values or meet specific
    requirements. You can use validation to verify that your models are
    correct before saving them to the database
    , or use them directly on
    HTTP parameters to validate a simple form
    .

    Ref : http://www.playframework.org/documentation/1.2.4/validation

    Before call your implement method, it call authenticate method in Secure class first. So, this it why annotation it not works in your implement method.

    public static void authenticate(@Required String username, String password, boolean remember) throws Throwable {
            // Check tokens
            Boolean allowed = false;
            try {
                // This is the deprecated method name
                allowed = (Boolean)Security.invoke("authentify", username, password);
            } catch (UnsupportedOperationException e ) {
                // This is the official method name
                allowed = (Boolean)Security.invoke("authenticate", username, password);
            }
            if(validation.hasErrors() || !allowed) {
                flash.keep("url");
                flash.error("secure.error");
                params.flash();
                login();
            }
            // Mark user as connected
            session.put("username", username);
            // Remember if needed
            if(remember) {
                response.setCookie("rememberme", Crypto.sign(username) + "-" + username, "30d");
            }
            // Redirect to the original URL (or /)
            redirectToOriginalURL();
        }
    

    Your can see this thread for deep reason why it not works -> parameter validation with net.sf.oval (in play framework)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following classes. class A { public: void fun(); } class B: public
I have following calss to validate my input elements. class Validator_FormValidator { public function
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have the following dilema: My clients (mom-n-pop pawnshops) have been using my mgmt.
I have the following problem. I have to implement a class that has an
Using CakePHP 1.3, I have the following layout: /srv/www/_cakephp13/ /app/ /cake/ /plugins/ /vendors/ etc...
I have customized UIButton with the following properties: 84x44 frame 84x44 background image 32*32
I have customized UITableViewCell (Static Content Loaded from nib). This cell contains one UILable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.