/** * <span class="en"> Returns the SMTP protocol to use for connections. </span> * * <p><span class="ja"> 接続の為の SMTP プロトコールを設定します。 (smtp or smtps) * * @param contextString - SMTP プロトコール名 </span> */ public String smtpProtocolForContext(String contextString) { String contextSuffix = (contextString == null) ? "" : ("." + contextString); return ERXProperties.stringForKeyWithDefault( "er.javamail.smtpProtocol" + contextSuffix, ERXProperties.stringForKeyWithDefault( "er.javamail.smtpProtocol", ERXProperties.stringForKeyWithDefault("mail.smtp.protocol", "smtp"))); }
@Override public NSArray getRequestHandlerPathForRequest(WORequest request) { NSMutableArray<Object> requestHandlerPath = new NSMutableArray<Object>(); try { String path = request._uriDecomposed().requestHandlerPath(); ERXRoute matchingRoute = setupRequestWithRouteForMethodAndPath(request, request.method(), path); if (matchingRoute != null) { @SuppressWarnings("unchecked") NSDictionary<ERXRoute.Key, String> keys = (NSDictionary<ERXRoute.Key, String>) request.userInfo().objectForKey(ERXRouteRequestHandler.KeysKey); String controller = keys.objectForKey(ERXRoute.ControllerKey); String actionName = keys.objectForKey(ERXRoute.ActionKey); requestHandlerPath.addObject(controller); requestHandlerPath.addObject(actionName); } else { requestHandlerPath.addObject( ERXProperties.stringForKeyWithDefault( "ERXRest.missingControllerName", "ERXMissingRouteController")); requestHandlerPath.addObject("missing"); // throw new FileNotFoundException("There is no controller for the route '" + path + "'."); } } catch (Throwable t) { throw new RuntimeException("Failed to process the requested route.", t); } return requestHandlerPath; }
/** Constructs a new ERXRouteRequestHandler with the default entity name format. */ public ERXRouteRequestHandler() { this( new NameFormat( ERXProperties.booleanForKeyWithDefault("ERXRest.pluralEntityNames", true), ERXProperties.booleanForKeyWithDefault("ERXRest.pluralEntityNames", true), NameFormat.Case.valueOf( ERXProperties.stringForKeyWithDefault( "ERXRest.routeCase", ERXProperties.booleanForKeyWithDefault("ERXRest.lowercaseEntityNames", true) ? NameFormat.Case.LowerCamelCase.name() : NameFormat.Case.CamelCase.name())))); }
public void takeValuesFromRequest(WORequest request, WOContext context) { if (context._wasFormSubmitted()) { super.takeValuesFromRequest(request, context); String apiKey = ERXProperties.stringForKey("er.captcha.akismet.apiKey"); String url = ERXProperties.stringForKeyWithDefault( "er.captcha.akismet.url", "http://" + request._serverName()); Akismet api = new Akismet(apiKey, url); if (ERXApplication.isDevelopmentModeSafe()) { if (!api.verifyAPIKey()) { throw new RuntimeException( "The API key you provided is invalid. Please set a valid api key in the property 'er.captcha.akismet.apiKey'."); } } String ipAddress = stringValueForBinding("remoteAddress", request._remoteAddress()); String userAgent = stringValueForBinding("userAgent", request.headerForKey("user-agent")); String referrer = stringValueForBinding("referrer", request.headerForKey("referer")); String permalink = stringValueForBinding("permalink"); String commentType = stringValueForBinding("commentType"); String author = stringValueForBinding("author"); String authorEmail = stringValueForBinding("authorEmail"); String authorURL = stringValueForBinding("authorURL"); String content = stringValueForBinding("content"); Map other = null; boolean isSpam = api.commentCheck( ipAddress, userAgent, referrer, permalink, commentType, author, authorEmail, authorURL, content, other); if (isSpam) { validationFailedWithException( new NSValidation.ValidationException("Spam check failed."), this, ERXSimpleSpamCheck.SPAM_CHECK_KEY); setValueForBinding(Boolean.FALSE, "valid"); } else { setValueForBinding(Boolean.TRUE, "valid"); } } }
protected void setupSmtpProperties(Properties properties, String contextString) { String contextSuffix = contextString == null ? "" : ("." + contextString); // Smtp host String smtpProtocol = smtpProtocolForContext(contextString); String smtpHost = ERXProperties.stringForKeyWithDefault( "er.javamail.smtpHost" + contextSuffix, ERXProperties.stringForKey("er.javamail.smtpHost")); if ((smtpHost == null) || (smtpHost.length() == 0)) { // Try to fail back to default java config smtpHost = ERXProperties.stringForKey("mail." + smtpProtocol + ".host"); if ((smtpHost == null) || (smtpHost.length() == 0)) { // use the standard WO host smtpHost = ERXProperties.stringForKey("WOSMTPHost"); if ((smtpHost == null) || (smtpHost.length() == 0)) { throw new RuntimeException( "ERJavaMail: You must specify a SMTP host for outgoing mail with the property 'er.javamail.smtpHost'"); } // ... and then maybe actually do what the docs say this method is supposed to do properties.setProperty("mail." + smtpProtocol + ".host", smtpHost); properties.setProperty("er.javamail.smtpHost", smtpHost); } else { properties.setProperty("er.javamail.smtpHost", smtpHost); } } else { properties.setProperty("mail." + smtpProtocol + ".host", smtpHost); } log.debug("er.javamail.smtpHost: " + smtpHost); String port = ERXProperties.stringForKeyWithDefault( "er.javamail.smtpPort" + contextSuffix, ERXProperties.stringForKey("er.javamail.smtpPort")); if (port != null && port.length() > 0) { properties.setProperty("mail." + smtpProtocol + ".port", port); log.debug("ERJavaMail will use smtp port: " + port); } boolean smtpAuth = ERXProperties.booleanForKeyWithDefault( "er.javamail.smtpAuth" + contextSuffix, ERXProperties.booleanForKey("er.javamail.smtpAuth")); log.debug("ERJavaMail will use authenticated SMTP connections."); if (smtpAuth) { properties.setProperty("mail." + smtpProtocol + ".auth", String.valueOf(smtpAuth)); String user = ERXProperties.stringForKeyWithDefault( "er.javamail.smtpUser" + contextSuffix, ERXProperties.stringForKey("er.javamail.smtpUser")); if (user == null || user.length() == 0) { throw new RuntimeException( "You specified er.javamail.smtpAuth=true, but you didn't specify an er.javamail.smtpUser to use as the login name."); } properties.setProperty("mail." + smtpProtocol + ".user", user); String password = ERXProperties.stringForKeyWithDefault( "er.javamail.smtpPassword" + contextSuffix, ERXProperties.stringForKey("er.javamail.smtpPassword")); if (password == null || password.length() == 0) { log.warn( "You specified er.javamail.smtpAuth=true, but you didn't set er.javamail.smtpPassword for the " + user + " mail user."); } if (password != null) { properties.setProperty("mail." + smtpProtocol + ".password", password); } } if ("smtps".equals(smtpProtocol)) { properties.setProperty("mail.smtps.socketFactory.fallback", "false"); } }
private String _getSubVersion() { return ERXProperties.stringForKeyWithDefault("pachy.svnVersion", "0"); }
private String _getBuildTime() { return ERXProperties.stringForKeyWithDefault("pachy.buildTimeString", "- no build time -"); }
private String _getVersion() { return ERXProperties.stringForKeyWithDefault("pachy.ReleaseVersion", "0.0"); // svnVersion }
private String _getTitle() { return ERXProperties.stringForKeyWithDefault("pachy.TitleDisplay", "Pachyderm 3"); // title }