Search in sources :

Example 1 with UserPasswordCredential

use of org.lastaflute.web.login.credential.UserPasswordCredential in project fess by codelibs.

the class FessLoginAssist method resolveCredential.

// ===================================================================================
//                                                                     Login Extention
//                                                                      ==============
@Override
protected void resolveCredential(final CredentialResolver resolver) {
    resolver.resolve(UserPasswordCredential.class, credential -> {
        final UserPasswordCredential userCredential = credential;
        final String username = userCredential.getUser();
        final String password = userCredential.getPassword();
        if (!fessConfig.isAdminUser(username)) {
            final OptionalEntity<FessUser> ldapUser = ComponentUtil.getLdapManager().login(username, password);
            if (ldapUser.isPresent()) {
                return ldapUser;
            }
        }
        return doFindLoginUser(username, encryptPassword(password));
    });
    resolver.resolve(SpnegoCredential.class, credential -> {
        final String username = credential.getUsername();
        if (!fessConfig.isAdminUser(username)) {
            return ComponentUtil.getLdapManager().login(username);
        }
        return OptionalEntity.empty();
    });
    resolver.resolve(OpenIdConnectCredential.class, credential -> {
        return OptionalEntity.of(credential.getUser());
    });
}
Also used : FessUser(org.codelibs.fess.entity.FessUser) UserPasswordCredential(org.lastaflute.web.login.credential.UserPasswordCredential)

Example 2 with UserPasswordCredential

use of org.lastaflute.web.login.credential.UserPasswordCredential in project fess by codelibs.

the class LoginAction method login.

@Execute
public HtmlResponse login(final LoginForm form) {
    validate(form, messages -> {
    }, () -> asIndexPage(form));
    verifyToken(() -> asIndexPage(form));
    final String username = form.username;
    final String password = form.password;
    form.clearSecurityInfo();
    try {
        return fessLoginAssist.loginRedirect(new UserPasswordCredential(username, password), op -> {
        }, () -> {
            activityHelper.login(getUserBean());
            userInfoHelper.deleteUserCodeFromCookie(request);
            return getHtmlResponse();
        });
    } catch (final LoginFailureException lfe) {
        throwValidationError(messages -> messages.addErrorsLoginError(GLOBAL), () -> asIndexPage(form));
    }
    return redirect(getClass());
}
Also used : FessLoginAction(org.codelibs.fess.app.web.base.FessLoginAction) UserPasswordCredential(org.lastaflute.web.login.credential.UserPasswordCredential) Execute(org.lastaflute.web.Execute) LoginFailureException(org.lastaflute.web.login.exception.LoginFailureException) HtmlResponse(org.lastaflute.web.response.HtmlResponse) RenderDataUtil(org.codelibs.fess.util.RenderDataUtil) LoginFailureException(org.lastaflute.web.login.exception.LoginFailureException) UserPasswordCredential(org.lastaflute.web.login.credential.UserPasswordCredential) Execute(org.lastaflute.web.Execute)

Aggregations

UserPasswordCredential (org.lastaflute.web.login.credential.UserPasswordCredential)2 FessLoginAction (org.codelibs.fess.app.web.base.FessLoginAction)1 FessUser (org.codelibs.fess.entity.FessUser)1 RenderDataUtil (org.codelibs.fess.util.RenderDataUtil)1 Execute (org.lastaflute.web.Execute)1 LoginFailureException (org.lastaflute.web.login.exception.LoginFailureException)1 HtmlResponse (org.lastaflute.web.response.HtmlResponse)1