protected Map<String, Object> getSessionParams(String ipAddress, String clientInfo) { GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class); String serverInfo = "Portal (" + globalConfig.getWebHostName() + ":" + globalConfig.getWebPort() + "/" + globalConfig.getWebContextName() + ") "; return ParamsMap.of( ClientType.class.getName(), AppContext.getProperty("cuba.clientType"), SessionParams.IP_ADDRESS.getId(), ipAddress, SessionParams.CLIENT_INFO.getId(), serverInfo + clientInfo ); }
@Deprecated protected void copyParamsToCredentials(Map<String, Object> params, AbstractClientCredentials credentials) { // for compatibility only Object clientType = params.get(ClientType.class.getName()); if (clientType != null && credentials.getClientType() == null) { credentials.setClientType(ClientType.valueOf((String) clientType)); } Object clientInfo = params.get(SessionParams.CLIENT_INFO.getId()); if (clientInfo != null && credentials.getClientInfo() == null) { credentials.setClientInfo((String) clientInfo); } Object ipAddress = params.get(SessionParams.IP_ADDRESS.getId()); if (ipAddress != null && credentials.getIpAddress() == null) { credentials.setIpAddress((String) ipAddress); } Object hostName = params.get(SessionParams.HOST_NAME.getId()); if (hostName != null) { credentials.setHostName((String) hostName); } if (!globalConfig.getLocaleSelectVisible()) { credentials.setOverrideLocale(false); } } }
@Deprecated protected void copyParamsToCredentials(Map<String, Object> params, AbstractClientCredentials credentials) { // for compatibility only Object clientType = params.get(ClientType.class.getName()); if (clientType != null) { credentials.setClientType(ClientType.valueOf((String) clientType)); } Object clientInfo = params.get(SessionParams.CLIENT_INFO.getId()); if (clientInfo != null) { credentials.setClientInfo((String) clientInfo); } Object ipAddress = params.get(SessionParams.IP_ADDRESS.getId()); if (ipAddress != null) { credentials.setIpAddress((String) ipAddress); } Object hostName = params.get(SessionParams.HOST_NAME.getId()); if (hostName != null) { credentials.setHostName((String) hostName); } if (!globalConfig.getLocaleSelectVisible()) { credentials.setOverrideLocale(false); } RemoteClientInfo remoteClientInfo = RemoteClientInfo.get(); if (remoteClientInfo != null) { String address = remoteClientInfo.getAddress(); if (!trustedLoginHandler.checkAddress(address)) { credentials.setIpAddress(address); } } }
protected UserSession loginAsAnonymous() { String login = portalConfig.getAnonymousUserLogin(); String password = portalConfig.getTrustedClientPassword(); UserSession userSession; try { String portalLocationString = getPortalNetworkLocation(); String portalClientInfo = "Portal Anonymous Session"; if (StringUtils.isNotBlank(portalLocationString)) { portalClientInfo += " (" + portalLocationString + ")"; } TrustedClientCredentials credentials = new TrustedClientCredentials(login, password, messagesTools.getDefaultLocale()); credentials.setClientType(ClientType.PORTAL); credentials.setClientInfo(portalClientInfo); credentials.setParams(ParamsMap.of( ClientType.class.getName(), AppContext.getProperty("cuba.clientType"), SessionParams.CLIENT_INFO.getId(), portalClientInfo )); userSession = authenticationService.login(credentials).getSession(); } catch (LoginException e) { throw new NoMiddlewareConnectionException("Unable to login as anonymous portal user", e); } catch (Exception e) { throw new NoMiddlewareConnectionException("Unable to connect to middleware services", e); } return userSession; }