protected void validateCAS(ActionRequest actionRequest) throws Exception { boolean casEnabled = ParamUtil.getBoolean(actionRequest, "settings--" + PropsKeys.CAS_AUTH_ENABLED + "--"); if (!casEnabled) { return; } String casLoginURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_LOGIN_URL + "--"); String casLogoutURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_LOGOUT_URL + "--"); String casServerName = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVER_NAME + "--"); String casServerURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVER_URL + "--"); String casServiceURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVICE_URL + "--"); String casNoSuchUserRedirectURL = ParamUtil.getString( actionRequest, "settings--" + PropsKeys.CAS_NO_SUCH_USER_REDIRECT_URL + "--"); if (!Validator.isUrl(casLoginURL)) { SessionErrors.add(actionRequest, "casLoginURLInvalid"); } if (!Validator.isUrl(casLogoutURL)) { SessionErrors.add(actionRequest, "casLogoutURLInvalid"); } if (Validator.isNull(casServerName)) { SessionErrors.add(actionRequest, "casServerNameInvalid"); } if (Validator.isNotNull(casServerURL) && Validator.isNotNull(casServiceURL)) { SessionErrors.add(actionRequest, "casServerURLAndServiceURLConflict"); } else if (Validator.isNull(casServerURL) && Validator.isNull(casServiceURL)) { SessionErrors.add(actionRequest, "casServerURLAndServiceURLNotSet"); } else { if (Validator.isNotNull(casServerURL) && !Validator.isUrl(casServerURL)) { SessionErrors.add(actionRequest, "casServerURLInvalid"); } if (Validator.isNotNull(casServiceURL) && !Validator.isUrl(casServiceURL)) { SessionErrors.add(actionRequest, "casServiceURLInvalid"); } } if (Validator.isNotNull(casNoSuchUserRedirectURL) && !Validator.isUrl(casNoSuchUserRedirectURL)) { SessionErrors.add(actionRequest, "casNoSuchUserURLInvalid"); } }
protected void validate( long websiteId, long companyId, long classNameId, long classPK, String url, int typeId, boolean primary) throws PortalException, SystemException { if (!Validator.isUrl(url)) { throw new WebsiteURLException(); } if (websiteId > 0) { Website website = websitePersistence.findByPrimaryKey(websiteId); companyId = website.getCompanyId(); classNameId = website.getClassNameId(); classPK = website.getClassPK(); } listTypeService.validate(typeId, classNameId, ListTypeConstants.WEBSITE); validate(websiteId, companyId, classNameId, classPK, primary); }
protected String buildSourceURL(String baseSourceURL, String fileEntryName) { if (!Validator.isUrl(baseSourceURL)) { return null; } int pos = baseSourceURL.length() - 1; while (pos >= 0) { char c = baseSourceURL.charAt(pos); if (c != CharPool.SLASH) { break; } pos--; } StringBundler sb = new StringBundler(3); sb.append(baseSourceURL.substring(0, pos + 1)); if (!fileEntryName.startsWith(StringPool.SLASH)) { sb.append(StringPool.SLASH); } sb.append(fileEntryName); return sb.toString(); }
@Override public String getContent(String path) { try { String stackPath = _generatePathFromStack(); URL resourceURL = null; if (Validator.isUrl(path)) { resourceURL = new URL(path); } else { resourceURL = _servletContext.getResource(stackPath.concat(path)); } if (resourceURL == null) { return null; } URLConnection urlConnection = resourceURL.openConnection(); return StringUtil.read(urlConnection.getInputStream()); } catch (IOException ioe) { _log.error(ioe, ioe); } return null; }
/** * Returns the full, absolute URL (including the portal's URL) of the navigation item's layout. * * @return the full, absolute URL of the navigation item's layout * @throws Exception if an exception occurred */ public String getRegularFullURL() throws Exception { String portalURL = PortalUtil.getPortalURL(_request); String regularURL = getRegularURL(); if (StringUtil.startsWith(regularURL, portalURL) || Validator.isUrl(regularURL)) { return regularURL; } else { return portalURL.concat(regularURL); } }
protected void validate(String title, String content, String url) throws PortalException { if (Validator.isNull(title)) { throw new EntryTitleException(); } if (Validator.isNull(content)) { throw new EntryContentException(); } if (Validator.isNotNull(url) && !Validator.isUrl(url)) { throw new EntryURLException(); } }