use of com.haulmont.cuba.core.global.ClientType in project cuba by cuba-platform.
the class ClientTypeUserAccessChecker method check.
@Override
public void check(Credentials credentials, AuthenticationDetails authenticationDetails) throws LoginException {
if (credentials instanceof AbstractClientCredentials) {
AbstractClientCredentials clientCredentials = (AbstractClientCredentials) credentials;
if (clientCredentials.isCheckClientPermissions()) {
ClientType clientType = clientCredentials.getClientType();
if (ClientType.DESKTOP == clientType || ClientType.WEB == clientType) {
if (!authenticationDetails.getSession().isSpecificPermitted("cuba.gui.loginToClient")) {
log.warn("Attempt of login to {} for user '{}' without cuba.gui.loginToClient permission", clientType, clientCredentials);
Locale userLocale;
if (clientCredentials.getLocale() != null) {
userLocale = clientCredentials.getLocale();
} else {
userLocale = messages.getTools().getDefaultLocale();
}
throw new LoginException(getInvalidCredentialsMessage(clientCredentials.getUserIdentifier(), userLocale));
}
}
}
}
}
use of com.haulmont.cuba.core.global.ClientType in project cuba by cuba-platform.
the class AuthenticationServiceBean method login.
@Nonnull
@Override
public AuthenticationDetails login(Credentials credentials) throws LoginException {
try {
preprocessCredentials(credentials);
// noinspection UnnecessaryLocalVariable
AuthenticationDetails details = authenticationManager.login(credentials);
Map<String, Object> logParams = emptyMap();
if (credentials instanceof AbstractClientCredentials) {
ClientType clientType = ((AbstractClientCredentials) credentials).getClientType();
if (clientType != null) {
logParams = ParamsMap.of(ClientType.class.getName(), clientType.name());
}
}
userSessionLog.createSessionLogRecord(details.getSession(), SessionAction.LOGIN, logParams);
return details;
} catch (InternalAuthenticationException ie) {
log.error("Login error", ie);
throw ie;
} catch (LoginException e) {
log.info("Login failed: {}", e.toString());
throw e;
} catch (Throwable e) {
log.error("Login error", e);
throw wrapInLoginException(e);
}
}
Aggregations