Search in sources :

Example 1 with IAuthenticationStrategy

use of org.apache.wicket.authentication.IAuthenticationStrategy in project openmeetings by apache.

the class WebSession method isSignedIn.

@Override
public boolean isSignedIn() {
    if (userId == null) {
        IAuthenticationStrategy strategy = getAuthenticationStrategy();
        // get username and password from persistence store
        String[] data = strategy.load();
        if (data != null && data.length > 3 && data[2] != null) {
            Long domainId = null;
            try {
                domainId = Long.valueOf(data[3]);
            } catch (Exception e) {
            // no-op
            }
            // try to sign in the user
            try {
                if (!signIn(data[0], data[1], Type.valueOf(data[2]), domainId)) {
                    // the loaded credentials are wrong. erase them.
                    strategy.remove();
                }
            } catch (OmException e) {
            // no-op, bad credentials
            }
        }
    }
    return userId != null && userId.longValue() > 0;
}
Also used : IAuthenticationStrategy(org.apache.wicket.authentication.IAuthenticationStrategy) OmException(org.apache.openmeetings.util.OmException) OmException(org.apache.openmeetings.util.OmException)

Example 2 with IAuthenticationStrategy

use of org.apache.wicket.authentication.IAuthenticationStrategy in project wicket by apache.

the class SignInPanel method onConfigure.

/**
 * Try to sign-in with remembered credentials.
 *
 * @see #setRememberMe(boolean)
 */
@Override
protected void onConfigure() {
    // logged in already?
    if (isSignedIn() == false) {
        IAuthenticationStrategy authenticationStrategy = getApplication().getSecuritySettings().getAuthenticationStrategy();
        // get username and password from persistence store
        String[] data = authenticationStrategy.load();
        if ((data != null) && (data.length > 1)) {
            // try to sign in the user
            if (signIn(data[0], data[1])) {
                username = data[0];
                password = data[1];
                onSignInRemembered();
            } else {
                // the loaded credentials are wrong. erase them.
                authenticationStrategy.remove();
            }
        }
    }
    super.onConfigure();
}
Also used : IAuthenticationStrategy(org.apache.wicket.authentication.IAuthenticationStrategy)

Aggregations

IAuthenticationStrategy (org.apache.wicket.authentication.IAuthenticationStrategy)2 OmException (org.apache.openmeetings.util.OmException)1