List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getBoolean
public static boolean getBoolean(PortletPreferences preferences, String name, boolean defaultValue)
From source file:com.abubusoft.liferay.linkedin.LinkedinAutoLogin.java
License:Open Source License
@Override protected String[] doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { long companyId = PortalUtil.getCompanyId(request); boolean linkedinAuthEnabled = PrefsPropsUtil.getBoolean(companyId, "linkedin.auth.enabled", true); if (!linkedinAuthEnabled) { return null; }//from w w w . j a va2 s . com User user = getUser(request, companyId); if (user == null) { return null; } String[] credentials = new String[3]; credentials[0] = String.valueOf(user.getUserId()); credentials[1] = user.getPassword(); credentials[2] = Boolean.TRUE.toString(); return credentials; }
From source file:com.liferay.google.GoogleAutoLogin.java
License:Open Source License
@Override protected String[] doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { long companyId = PortalUtil.getCompanyId(request); boolean googleAuthEnabled = PrefsPropsUtil.getBoolean(companyId, "google.auth.enabled", true); if (!googleAuthEnabled) { return null; }/* w w w. ja v a 2 s. c o m*/ User user = getUser(request, companyId); if (user == null) { return null; } String[] credentials = new String[3]; credentials[0] = String.valueOf(user.getUserId()); credentials[1] = user.getPassword(); credentials[2] = Boolean.TRUE.toString(); return credentials; }
From source file:com.liferay.google.login.hook.security.auth.GoogleAutoLogin.java
License:Open Source License
@Override protected String[] doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { long companyId = PortalUtil.getCompanyId(request); boolean googleAuthEnabled = PrefsPropsUtil.getBoolean(companyId, "google-auth-enabled", true); if (!googleAuthEnabled) { return null; }//from w ww . j a v a 2 s . c o m User user = getUser(request, companyId); if (user == null) { return null; } String[] credentials = new String[3]; credentials[0] = String.valueOf(user.getUserId()); credentials[1] = user.getPassword(); credentials[2] = Boolean.TRUE.toString(); return credentials; }
From source file:com.liferay.login.authentication.google.web.internal.portlet.action.AssociateGoogleUserMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); boolean googleAuthEnabled = PrefsPropsUtil.getBoolean(themeDisplay.getCompanyId(), "google-auth-enabled", true);//w w w . j a v a 2s. c o m if (!googleAuthEnabled) { throw new PortletException(new PrincipalException.MustBeEnabled(themeDisplay.getCompanyId(), GoogleLoginAction.class.getName())); } long googleIncompleteUserId = ParamUtil.getLong(renderRequest, "userId"); if (googleIncompleteUserId != 0) { User user = _userLocalService.fetchUser(googleIncompleteUserId); return renderUpdateAccount(renderRequest, user); } // This return statement may be used if the user presses the browser's // back button return "/login.jsp"; }
From source file:com.liferay.shibboleth.hook.security.auth.ShibbolethAutoLogin.java
License:Open Source License
@Override protected String[] doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { Company company = PortalUtil.getCompany(request); long companyId = company.getCompanyId(); if (!ShibbolethUtil.isEnabled(companyId)) { return null; }/*from w w w.ja v a 2s.co m*/ String shibbolethUserHeader = request.getHeader(PrefsPropsUtil.getString(companyId, PropsKeys.SHIBBOLETH_USER_HEADER, PropsValues.SHIBBOLETH_USER_HEADER)); if (Validator.isNull(shibbolethUserHeader)) { return null; } String authType = company.getAuthType(); User user = null; if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.SHIBBOLETH_IMPORT_FROM_LDAP, PropsValues.SHIBBOLETH_IMPORT_FROM_LDAP)) { try { if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { user = PortalLDAPImporterUtil.importLDAPUser(companyId, shibbolethUserHeader, StringPool.BLANK); } else { user = PortalLDAPImporterUtil.importLDAPUser(companyId, StringPool.BLANK, shibbolethUserHeader); } } catch (SystemException se) { } } if (user == null) { if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { user = UserLocalServiceUtil.fetchUserByEmailAddress(companyId, shibbolethUserHeader); } else { user = UserLocalServiceUtil.fetchUserByScreenName(companyId, shibbolethUserHeader); } } String[] credentials = new String[3]; credentials[0] = String.valueOf(user.getUserId()); credentials[1] = user.getPassword(); credentials[2] = Boolean.TRUE.toString(); return credentials; }
From source file:com.liferay.shibboleth.util.ShibbolethUtil.java
License:Open Source License
public static boolean isEnabled(long companyId) { if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.SHIBBOLETH_AUTH_ENABLED, PropsValues.SHIBBOLETH_AUTH_ENABLED)) { return true; } else {/* w w w . j a va 2s. c om*/ return false; } }
From source file:com.liferay.sync.filter.SyncJSONFilter.java
License:Open Source License
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { String uri = (String) servletRequest.getAttribute(WebKeys.INVOKER_FILTER_URI); if (!uri.startsWith("/api/jsonws/sync-web.")) { filterChain.doFilter(servletRequest, servletResponse); return;/*from w ww. j a v a 2 s . c o m*/ } HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; if (PrefsPropsUtil.getBoolean(PortalUtil.getCompanyId(httpServletRequest), PortletPropsKeys.SYNC_SERVICES_ENABLED, PortletPropsValues.SYNC_SERVICES_ENABLED)) { filterChain.doFilter(servletRequest, servletResponse); return; } servletResponse.setCharacterEncoding(StringPool.UTF8); servletResponse.setContentType(ContentTypes.APPLICATION_JSON); OutputStream outputStream = servletResponse.getOutputStream(); String json = SyncUtil.buildExceptionMessage(new SyncServicesUnavailableException()); json = "{\"exception\": \"" + json + "\"}"; outputStream.write(json.getBytes(StringPool.UTF8)); outputStream.close(); }
From source file:com.liferay.sync.internal.configurator.SyncConfigurator.java
License:Open Source License
@Override public void portalInstanceRegistered(Company company) throws Exception { boolean lanEnabled = PrefsPropsUtil.getBoolean(company.getCompanyId(), SyncServiceConfigurationKeys.SYNC_LAN_ENABLED, SyncServiceConfigurationValues.SYNC_LAN_ENABLED); if (lanEnabled) { try {/*www . j a v a 2s. co m*/ _syncUtil.enableLanSync(company.getCompanyId()); } catch (Exception e) { _log.error(e, e); } } }
From source file:com.liferay.sync.internal.servlet.filter.SyncJSONFilter.java
License:Open Source License
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { SyncDevice syncDevice = null;/* ww w . j a v a 2 s.co m*/ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; String uuid = httpServletRequest.getHeader("Sync-UUID"); if (uuid != null) { syncDevice = SyncDeviceLocalServiceUtil.fetchSyncDeviceByUuidAndCompanyId(uuid, _portal.getCompanyId(httpServletRequest)); } if (syncDevice == null) { syncDevice = SyncDeviceLocalServiceUtil.createSyncDevice(0); } syncDevice.setHostname(servletRequest.getRemoteHost()); SyncDeviceThreadLocal.setSyncDevice(syncDevice); if (uuid != null) { filterChain.doFilter(servletRequest, servletResponse); return; } String uri = (String) servletRequest.getAttribute(WebKeys.INVOKER_FILTER_URI); if (uri.equals("/api/jsonws/invoke")) { String contentType = httpServletRequest.getHeader(HttpHeaders.CONTENT_TYPE); if ((contentType == null) || !contentType.startsWith(ContentTypes.MULTIPART_FORM_DATA)) { filterChain.doFilter(servletRequest, servletResponse); return; } if (!(httpServletRequest instanceof UploadServletRequest)) { servletRequest = _portal.getUploadServletRequest(httpServletRequest); } if (!isSyncJSONRequest(servletRequest)) { filterChain.doFilter(servletRequest, servletResponse); return; } } else if (!uri.startsWith("/api/jsonws/sync")) { filterChain.doFilter(servletRequest, servletResponse); return; } if (ParamUtil.get(httpServletRequest, "debug", false)) { filterChain.doFilter(servletRequest, servletResponse); return; } Throwable throwable = null; if (PrefsPropsUtil.getBoolean(_portal.getCompanyId(httpServletRequest), SyncServiceConfigurationKeys.SYNC_SERVICES_ENABLED, SyncServiceConfigurationValues.SYNC_SERVICES_ENABLED)) { int absoluteSyncClientMinBuild = 0; int syncClientMinBuild = 0; String syncDeviceType = httpServletRequest.getHeader("Sync-Device"); if (syncDeviceType == null) { throwable = new SyncDeviceHeaderException(); } else if (syncDeviceType.startsWith("desktop")) { absoluteSyncClientMinBuild = _ABSOLUTE_SYNC_CLIENT_MIN_BUILD_DESKTOP; syncClientMinBuild = PrefsPropsUtil.getInteger(_portal.getCompanyId(httpServletRequest), SyncServiceConfigurationKeys.SYNC_CLIENT_MIN_BUILD_DESKTOP, SyncServiceConfigurationValues.SYNC_CLIENT_MIN_BUILD_DESKTOP); } else if (syncDeviceType.equals("mobile-android")) { absoluteSyncClientMinBuild = _ABSOLUTE_SYNC_CLIENT_MIN_BUILD_ANDROID; syncClientMinBuild = PrefsPropsUtil.getInteger(_portal.getCompanyId(httpServletRequest), SyncServiceConfigurationKeys.SYNC_CLIENT_MIN_BUILD_ANDROID, SyncServiceConfigurationValues.SYNC_CLIENT_MIN_BUILD_ANDROID); } else if (syncDeviceType.equals("mobile-ios")) { absoluteSyncClientMinBuild = _ABSOLUTE_SYNC_CLIENT_MIN_BUILD_IOS; syncClientMinBuild = PrefsPropsUtil.getInteger(_portal.getCompanyId(httpServletRequest), SyncServiceConfigurationKeys.SYNC_CLIENT_MIN_BUILD_IOS, SyncServiceConfigurationValues.SYNC_CLIENT_MIN_BUILD_IOS); } else { throwable = new SyncDeviceHeaderException(); } if (throwable == null) { if (syncClientMinBuild < absoluteSyncClientMinBuild) { syncClientMinBuild = absoluteSyncClientMinBuild; } int syncBuild = httpServletRequest.getIntHeader("Sync-Build"); if (syncBuild >= syncClientMinBuild) { filterChain.doFilter(servletRequest, servletResponse); return; } else { throwable = new SyncClientMinBuildException( "Sync client does not meet minimum build " + syncClientMinBuild); } } } else { throwable = new SyncServicesUnavailableException(); } servletResponse.setCharacterEncoding(StringPool.UTF8); servletResponse.setContentType(ContentTypes.APPLICATION_JSON); OutputStream outputStream = servletResponse.getOutputStream(); String json = _syncUtil.buildExceptionMessage(throwable); json = "{\"exception\": \"" + json + "\"}"; outputStream.write(json.getBytes(StringPool.UTF8)); outputStream.close(); }
From source file:com.liferay.sync.model.impl.SyncDeviceImpl.java
License:Open Source License
@Override public void checkStatus() throws PortalException { if (getStatus() == SyncDeviceConstants.STATUS_INACTIVE) { throw new SyncDeviceActiveException(); } else if (getStatus() == SyncDeviceConstants.STATUS_WIPED) { throw new SyncDeviceWipeException(); }/*from w ww .j ava 2 s . c o m*/ if (!PrefsPropsUtil.getBoolean(getCompanyId(), PortletPropsKeys.SYNC_SERVICES_ENABLED, PortletPropsValues.SYNC_SERVICES_ENABLED)) { throw new SyncServicesUnavailableException(); } if (!isSupported()) { throw new SyncClientMinBuildException(); } }