001
014
015 package com.liferay.portal.security.auth;
016
017 import com.liferay.portal.kernel.exception.SystemException;
018 import com.liferay.portal.kernel.util.PropsKeys;
019 import com.liferay.portal.util.PortalUtil;
020 import com.liferay.portal.util.PrefsPropsUtil;
021 import com.liferay.portal.util.PropsValues;
022
023 import java.util.Set;
024
025 import javax.servlet.http.HttpServletRequest;
026
027
030 public class AuthSettingsUtil {
031
032 public static boolean isAccessAllowed(
033 HttpServletRequest request, Set<String> hostsAllowed) {
034
035 if (hostsAllowed.isEmpty()) {
036 return true;
037 }
038
039 String remoteAddr = request.getRemoteAddr();
040
041 if (hostsAllowed.contains(remoteAddr)) {
042 return true;
043 }
044
045 Set<String> computerAddresses = PortalUtil.getComputerAddresses();
046
047 if (computerAddresses.contains(remoteAddr) &&
048 hostsAllowed.contains(_SERVER_IP)) {
049
050 return true;
051 }
052
053 return false;
054 }
055
056 public static boolean isLDAPAuthEnabled(long companyId)
057 throws SystemException {
058
059 if (PrefsPropsUtil.getBoolean(
060 companyId, PropsKeys.LDAP_AUTH_ENABLED,
061 PropsValues.LDAP_AUTH_ENABLED)) {
062
063 return true;
064 }
065 else {
066 return false;
067 }
068 }
069
070 public static boolean isNtlmEnabled(long companyId) throws SystemException {
071 if (PrefsPropsUtil.getBoolean(
072 companyId, PropsKeys.NTLM_AUTH_ENABLED,
073 PropsValues.NTLM_AUTH_ENABLED)) {
074
075 return true;
076 }
077 else {
078 return false;
079 }
080 }
081
082 public static boolean isSiteMinderEnabled(long companyId)
083 throws SystemException {
084
085 if (PrefsPropsUtil.getBoolean(
086 companyId, PropsKeys.SITEMINDER_AUTH_ENABLED,
087 PropsValues.SITEMINDER_AUTH_ENABLED)) {
088
089 return true;
090 }
091 else {
092 return false;
093 }
094 }
095
096 private static final String _SERVER_IP = "SERVER_IP";
097
098 }