List of usage examples for java.lang Boolean getBoolean
public static boolean getBoolean(String name)
From source file:org.opencastproject.distribution.youtube.YoutubeDistributionService.java
/** * {@inheritDoc}/*from ww w . j a va 2s . c om*/ * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ @Override public synchronized void updated(Dictionary properties) throws ConfigurationException { logger.info("Update method from managed service"); String username = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.username")); String password = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.password")); String clientid = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.clientid")); String developerkey = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.developerkey")); String category = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.category")); String keywords = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.keywords")); String privacy = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.private")); String isChunked = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.chunked")); defaultPlaylist = StringUtils .trimToNull((String) properties.get("org.opencastproject.distribution.youtube.default.playlist")); // Setup configuration from properties if (StringUtils.isBlank(clientid)) throw new IllegalArgumentException("Youtube clientid must be specified"); if (StringUtils.isBlank(developerkey)) throw new IllegalArgumentException("Youtube developerkey must be specified"); if (StringUtils.isBlank(username)) throw new IllegalArgumentException("Youtube username must be specified"); if (StringUtils.isBlank(password)) throw new IllegalArgumentException("Youtube password must be specified"); if (StringUtils.isBlank(category)) throw new IllegalArgumentException("Youtube category must be specified"); if (StringUtils.isBlank(keywords)) throw new IllegalArgumentException("Youtube keywords must be specified"); if (StringUtils.isBlank(privacy)) throw new IllegalArgumentException("Youtube privacy must be specified"); String uploadUrl = VIDEO_ENTRY_URL.replaceAll("\\{username\\}", username); config.setClientId(clientid); config.setDeveloperKey(developerkey); config.setUserId(username); config.setUploadUrl(uploadUrl); config.setPassword(password); config.setKeywords(keywords); config.setCategory(category); config.setVideoPrivate(Boolean.getBoolean(privacy)); if (StringUtils.isNotBlank(isChunked)) isDefaultChunked = Boolean.getBoolean(isChunked); }
From source file:com.headstrong.npi.raas.Utils.java
public static boolean[] stringArrayToBooleanArray(String[] stringArray) { boolean[] booleanArray = new boolean[stringArray.length]; for (int i = 0; i < stringArray.length; i++) { booleanArray[i] = Boolean.getBoolean(stringArray[i]); }//from w ww. j a v a 2 s . co m return booleanArray; }
From source file:org.opennms.install.Installer.java
/** * <p>install</p>// w w w. j a va 2 s. co m * * @param argv an array of {@link java.lang.String} objects. * @throws java.lang.Exception if any. */ public void install(final String[] argv) throws Exception { printHeader(); loadProperties(); parseArguments(argv); final boolean doDatabase = (m_update_database || m_do_inserts || m_update_iplike || m_update_unicode || m_fix_constraint); if (!doDatabase && m_tomcat_conf == null && !m_install_webapp && m_library_search_path == null) { usage(options, m_commandLine, "Nothing to do. Use -h for help.", null); System.exit(1); } if (doDatabase) { final File cfgFile = ConfigFileConstants .getFile(ConfigFileConstants.OPENNMS_DATASOURCE_CONFIG_FILE_NAME); InputStream is = new FileInputStream(cfgFile); final JdbcDataSource adminDsConfig = new DataSourceConfigurationFactory(is) .getJdbcDataSource(ADMIN_DATA_SOURCE_NAME); final DataSource adminDs = new SimpleDataSource(adminDsConfig); is.close(); is = new FileInputStream(cfgFile); final JdbcDataSource dsConfig = new DataSourceConfigurationFactory(is) .getJdbcDataSource(OPENNMS_DATA_SOURCE_NAME); final DataSource ds = new SimpleDataSource(dsConfig); is.close(); m_installerDb.setForce(m_force); m_installerDb.setIgnoreNotNull(m_ignore_not_null); m_installerDb.setNoRevert(m_do_not_revert); m_installerDb.setAdminDataSource(adminDs); m_installerDb.setPostgresOpennmsUser(dsConfig.getUserName()); m_installerDb.setDataSource(ds); m_installerDb.setDatabaseName(dsConfig.getDatabaseName()); m_migrator.setDataSource(ds); m_migrator.setAdminDataSource(adminDs); m_migrator.setValidateDatabaseVersion(!m_ignore_database_version); m_migration.setDatabaseName(dsConfig.getDatabaseName()); m_migration.setSchemaName(dsConfig.getSchemaName()); m_migration.setAdminUser(adminDsConfig.getUserName()); m_migration.setAdminPassword(adminDsConfig.getPassword()); m_migration.setDatabaseUser(dsConfig.getUserName()); m_migration.setDatabasePassword(dsConfig.getPassword()); m_migration.setChangeLog("changelog.xml"); } checkIPv6(); /* * Make sure we can execute the rrdtool binary when the * JniRrdStrategy is enabled. */ boolean using_jni_rrd_strategy = System.getProperty("org.opennms.rrd.strategyClass", "") .contains("JniRrdStrategy"); if (using_jni_rrd_strategy) { File rrd_binary = new File(System.getProperty("rrd.binary")); if (!rrd_binary.canExecute()) { throw new Exception("Cannot execute the rrdtool binary '" + rrd_binary.getAbsolutePath() + "' required by the current RRD strategy. Update the rrd.binary field in opennms.properties appropriately."); } } /* * make sure we can load the ICMP library before we go any farther */ if (!Boolean.getBoolean("skip-native")) { String icmp_path = findLibrary("jicmp", m_library_search_path, false); String icmp6_path = findLibrary("jicmp6", m_library_search_path, false); String jrrd_path = findLibrary("jrrd", m_library_search_path, false); String jrrd2_path = findLibrary("jrrd2", m_library_search_path, false); writeLibraryConfig(icmp_path, icmp6_path, jrrd_path, jrrd2_path); } /* * Everything needs to use the administrative data source until we * verify that the opennms database is created below (and where we * create it if it doesn't already exist). */ verifyFilesAndDirectories(); if (m_install_webapp) { checkWebappOldOpennmsDir(); checkServerXmlOldOpennmsContext(); } if (m_update_database || m_fix_constraint) { // OLDINSTALL m_installerDb.readTables(); } m_installerDb.disconnect(); if (doDatabase) { m_migrator.validateDatabaseVersion(); System.out.println( String.format("* using '%s' as the PostgreSQL user for OpenNMS", m_migration.getAdminUser())); System.out.println(String.format("* using '%s' as the PostgreSQL database name for OpenNMS", m_migration.getDatabaseName())); if (m_migration.getSchemaName() != null) { System.out.println(String.format("* using '%s' as the PostgreSQL schema name for OpenNMS", m_migration.getSchemaName())); } } if (m_update_database) { m_migrator.prepareDatabase(m_migration); } if (doDatabase) { m_installerDb.checkUnicode(); } handleConfigurationChanges(); final GenericApplicationContext context = new GenericApplicationContext(); context.setClassLoader(Bootstrap.loadClasses(new File(m_opennms_home), true)); if (m_update_database) { m_installerDb.databaseSetUser(); m_installerDb.disconnect(); for (final Resource resource : context.getResources("classpath*:/changelog.xml")) { System.out.println("- Running migration for changelog: " + resource.getDescription()); m_migration.setAccessor(new ExistingResourceAccessor(resource)); m_migrator.migrate(m_migration); } } if (m_update_unicode) { System.out.println("WARNING: the -U option is deprecated, it does nothing now"); } if (m_do_vacuum) { m_installerDb.vacuumDatabase(m_do_full_vacuum); } if (m_install_webapp) { installWebApp(); } if (m_tomcat_conf != null) { updateTomcatConf(); } if (m_update_iplike) { m_installerDb.updateIplike(); } if (m_update_database && m_remove_database) { m_installerDb.disconnect(); m_installerDb.databaseRemoveDB(); } if (doDatabase) { m_installerDb.disconnect(); } if (m_update_database) { createConfiguredFile(); } System.out.println(); System.out.println("Installer completed successfully!"); if (!m_skip_upgrade_tools) { System.setProperty("opennms.manager.class", "org.opennms.upgrade.support.Upgrade"); Bootstrap.main(new String[] {}); } context.close(); }
From source file:com.github.mrstampy.esp.neurosky.MultiConnectionThinkGearSocket.java
/** * Connects to the ThinkGear socket on the specified host, allowing * programmatic control of broadcasting for {@link ThinkGearSocketConnector}s, * and the system property 'send.neurosky.messages' is used to enable/disable * remote {@link ThinkGearSocketConnector}s sending messages to the Neurosky * device.//from w w w. j av a2 s .co m * * @param host * @param broadcasting * @throws IOException */ public MultiConnectionThinkGearSocket(String host, boolean broadcasting) throws IOException { this(host, broadcasting, Boolean.getBoolean(SEND_NEUROSKY_MESSAGES)); }
From source file:org.ejbca.config.ScepConfiguration.java
/** * @see ScepConfiguration#getClientCertificateRenewal(String) for information about Client Certificate Renewal * //from w w w.j a va 2 s . c om * The SCEP draft makes it optional whether or not old keys may be reused during Client Certificate Renewal * * @param alias A SCEP configuration alias * @return true of old keys are allowed Client Certificate Renewal */ public boolean getAllowClientCertificateRenewalWithOldKey(final String alias) { String key = alias + "." + SCEP_CLIENT_CERTIFICATE_RENEWAL_WITH_OLD_KEY; String value = getValue(key, alias); //Lazy initialization for SCEP configurations older than 6.3.1 if (value == null) { data.put(alias + "." + SCEP_CLIENT_CERTIFICATE_RENEWAL_WITH_OLD_KEY, DEFAULT_ALLOW_CLIENT_CERTIFICATE_RENEWAL_WITH_OLD_KEY); return Boolean.getBoolean(DEFAULT_ALLOW_CLIENT_CERTIFICATE_RENEWAL_WITH_OLD_KEY); } return Boolean.valueOf(value); }
From source file:com.konakart.actions.gateways.CyberSourceSAResponseAction.java
public String execute() { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); String transactionId = null;//w w w . j ava 2s . com String merchantReference = null; String reasonCode = null; String authAmount = null; String decision = null; String referenceNumber = null; String customerEmail = null; String signature = null; String orderAmount = null; String authCode = null; String responseEnvironment = null; String authResponse = null; String message = null; String signedFields = null; KKAppEng kkAppEng = null; if (log.isDebugEnabled()) { log.debug(CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE + " Response Action"); } SortedMap<String, String> responseHash = new TreeMap<String, String>(); int maxParamNameSize = 0; try { // Process the parameters sent in the callback StringBuffer sb = new StringBuffer(); if (request != null) { Enumeration<String> en = request.getParameterNames(); while (en.hasMoreElements()) { String paramName = en.nextElement(); String paramValue = request.getParameter(paramName); if (sb.length() > 0) { sb.append("\n"); } sb.append(paramName); sb.append(" = "); sb.append(paramValue); // Capture important variables so that we can determine whether the transaction // was successful if (paramName != null) { responseHash.put(paramName, paramValue); if (paramName.equalsIgnoreCase("kkret")) { if (paramValue.equalsIgnoreCase("true")) { return "Approved"; } return "CheckoutError"; } if (paramName.length() > maxParamNameSize) { maxParamNameSize = paramName.length(); } } } } // Dump the Hashtable if (log.isDebugEnabled()) { String str = "Response fields:"; for (Map.Entry<String, String> entry : responseHash.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); str += "\n " + Utils.padRight(key, maxParamNameSize) + " = " + value; } log.debug(str); } // Pick out values of interest decision = responseHash.get("decision"); transactionId = responseHash.get("transaction_id"); merchantReference = responseHash.get("req_merchant_defined_data1"); responseEnvironment = responseHash.get("req_merchant_defined_data2"); authCode = responseHash.get("auth_code"); reasonCode = responseHash.get("reason_code"); authAmount = responseHash.get("auth_amount"); authResponse = responseHash.get("auth_response"); referenceNumber = responseHash.get("req_reference_number"); orderAmount = responseHash.get("req_amount"); signature = responseHash.get("signature"); message = responseHash.get("message"); signedFields = responseHash.get("signed_field_names"); String fullGatewayResponse = sb.toString(); if (log.isDebugEnabled()) { //log.debug(CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE + " Raw Response data:\n" // + fullGatewayResponse); log.debug("\n decision = " + decision + "\n message = " + message + "\n transactionId = " + transactionId + "\n merchantReference = " + merchantReference + "\n authCode = " + authCode + "\n reasonCode = " + reasonCode + "\n authAmount = " + authAmount + "\n authResponse = " + authResponse + "\n orderAmount = " + orderAmount + "\n referenceNumber = " + referenceNumber + "\n signature = " + signature + "\n responseEnvironment = " + responseEnvironment); } // Pick out the values from the merchantReference // Split the merchantReference into orderId, orderNumber and store information if (merchantReference == null) { throw new Exception("A merchant reference wasn't received from CyberSource"); } StringTokenizer st = new StringTokenizer(merchantReference, "~"); String orderIdStr = null; int orderId = -1; String orderNumberStr = null; String storeId = null; int engineMode = -1; boolean customersShared = false; boolean productsShared = false; boolean categoriesShared = false; String countryCode = null; if (st.hasMoreTokens()) { orderIdStr = st.nextToken(); orderId = Integer.parseInt(orderIdStr); } if (st.hasMoreTokens()) { orderNumberStr = st.nextToken(); } if (st.hasMoreTokens()) { storeId = st.nextToken(); } if (st.hasMoreTokens()) { engineMode = Integer.parseInt(st.nextToken()); } if (st.hasMoreTokens()) { customersShared = Boolean.getBoolean(st.nextToken()); } if (st.hasMoreTokens()) { productsShared = Boolean.getBoolean(st.nextToken()); } if (st.hasMoreTokens()) { categoriesShared = Boolean.getBoolean(st.nextToken()); } if (st.hasMoreTokens()) { countryCode = st.nextToken(); } if (log.isDebugEnabled()) { log.debug("Derived from merchantReference: \n" + " OrderId = " + orderId + "\n" + " OrderNumber = " + orderNumberStr + "\n" + " StoreId = " + storeId + "\n" + " EngineMode = " + engineMode + "\n" + " CustomersShared = " + customersShared + "\n" + " ProductsShared = " + productsShared + "\n" + " CategoriesShared = " + categoriesShared + "\n" + " CountryCode = " + countryCode); } // Get an instance of the KonaKart engine // kkAppEng = this.getKKAppEng(request); // v3.2 code kkAppEng = this.getKKAppEng(request, response); // v4.1 code int custId = this.loggedIn(request, response, kkAppEng, "Checkout", false, null); // Check to see whether the user is logged in if (custId < 0) { if (log.isInfoEnabled()) { log.info("Customer is not logged in"); } return KKLOGIN; } // If we didn't receive a decision, we log a warning and return if (decision == null) { String msg = "No decision returned for the " + CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE + " module"; saveIPNrecord(kkAppEng, orderId, CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE, fullGatewayResponse, decision, transactionId, RET1_DESC + msg, RET1); throw new Exception(msg); } String sharedSecret = kkAppEng.getCustomConfig(orderIdStr + "-CUSTOM1", true); boolean validateSignature = false; if (sharedSecret == null) { if (log.isWarnEnabled()) { log.warn("CyberSource shared secret is null"); } validateSignature = false; } else { if (log.isDebugEnabled()) { log.debug("Shared Secret found on session for order " + orderIdStr); } // Check the authenticity of the message by checking the signature String data = null; String dataStr = "Data to Sign:"; for (String field : signedFields.split(",")) { if (data == null) { data = field + "=" + responseHash.get(field); } else { data += "," + field + "=" + responseHash.get(field); } dataStr += "\n " + Utils.padRight(field, maxParamNameSize) + " = " + responseHash.get(field); } if (log.isDebugEnabled()) { log.debug("Validate Signed Fields : " + data); log.debug(dataStr); } validateSignature = CyberSourceSAHMACTools.verifyBase64EncodedSignature(sharedSecret, signature, data); } if (log.isDebugEnabled()) { log.debug("Signature Validation Result: " + validateSignature); } // If the signature on the amount doesn't validate we log a warning and return if (!validateSignature) { String msg = "Signature Validation Failed for the " + CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE + " module - orderId " + orderId; saveIPNrecord(kkAppEng, orderId, CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE, fullGatewayResponse, decision, transactionId, RET1_DESC + msg, RET1); throw new Exception(msg); } // Validate we are in the correct environment boolean validateEnvironment = true; String sessionEnvironment = kkAppEng.getCustomConfig(orderIdStr + "-CUSTOM2", true); if (sessionEnvironment == null) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment is null on the session"); } validateEnvironment = false; } else if (illegalEnvironmentValue(sessionEnvironment)) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment on the session is illegal"); } validateEnvironment = false; } else if (illegalEnvironmentValue(responseEnvironment)) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment in the session is illegal"); } validateEnvironment = false; } else if (!sessionEnvironment.equals(responseEnvironment)) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment in the session (" + sessionEnvironment + ") does not match that in the response (" + responseEnvironment + ")"); } validateEnvironment = false; } // If the signature on the amount doesn't validate we log a warning and return if (!validateEnvironment) { String msg = "Environment Validation Failed for the " + CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE + " module - orderId " + orderId; saveIPNrecord(kkAppEng, orderId, CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE, fullGatewayResponse, decision, transactionId, RET1_DESC + msg, RET1); throw new Exception(msg); } // See if we need to send an email, by looking at the configuration String sendEmailsConfig = kkAppEng.getConfig(ConfigConstants.SEND_EMAILS); boolean sendEmail = false; if (sendEmailsConfig != null && sendEmailsConfig.equalsIgnoreCase("true")) { sendEmail = true; } // If we didn't receive an ACCEPT decision, we let the user Try Again OrderUpdateIf updateOrder = new OrderUpdate(); updateOrder.setUpdatedById(kkAppEng.getActiveCustId()); if (!decision.equals("ACCEPT")) { if (log.isDebugEnabled()) { log.debug("Payment Not Approved for orderId: " + orderId + " for customer: " + customerEmail + " reason: " + getReasonDescription(reasonCode)); } saveIPNrecord(kkAppEng, orderId, CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE, fullGatewayResponse, decision, transactionId, RET2_DESC + decision + " : " + getReasonDescription(reasonCode), RET2); String comment = ORDER_HISTORY_COMMENT_KO + decision; kkAppEng.getEng().updateOrder(kkAppEng.getSessionId(), orderId, com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, sendEmail, comment, updateOrder); if (sendEmail) { sendOrderConfirmationMail(kkAppEng, orderId, /* success */false); } String msg = kkAppEng.getMsg("checkout.cc.gateway.error", new String[] { comment }); addActionError(msg); /* * Add a parameter that is sent back to this action when trying to break out of the * frame */ if (request != null) { StringBuffer retUrl = request.getRequestURL(); retUrl.append("?kkret=false"); this.url = retUrl.toString(); return "redirect"; } throw new KKException("The HttpServletRequest is null"); } // If successful, we forward to "Approved" if (log.isDebugEnabled()) { log.debug("Payment Approved for orderId " + orderId + " for customer " + customerEmail); } saveIPNrecord(kkAppEng, orderId, CyberSourceSA.CYBERSOURCESA_GATEWAY_CODE, fullGatewayResponse, decision, transactionId, RET0_DESC, RET0); String comment = ORDER_HISTORY_COMMENT_OK + transactionId; kkAppEng.getEng().updateOrder(kkAppEng.getSessionId(), orderId, com.konakart.bl.OrderMgr.PAYMENT_RECEIVED_STATUS, sendEmail, comment, updateOrder); // If the order payment was approved we update the inventory kkAppEng.getEng().updateInventory(kkAppEng.getSessionId(), orderId); if (sendEmail) { sendOrderConfirmationMail(kkAppEng, orderId, /* success */true); } // If we received no exceptions, delete the basket kkAppEng.getBasketMgr().emptyBasket(); /* * Add a parameter that is sent back to this action when trying to break out of the * frame */ if (request != null) { StringBuffer retUrl = request.getRequestURL(); retUrl.append("?kkret=true"); this.url = retUrl.toString(); return "redirect"; } throw new KKException("The HttpServletRequest is null"); } catch (Exception e) { e.printStackTrace(); return super.handleException(request, e); } }
From source file:com.konakart.actions.gateways.CyberSourceHOPResponseAction.java
public String execute() { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); String reconciliationID = null; String merchantReference = null; String reasonCode = null;/*w ww . j av a 2s. c o m*/ String ccAuthReply_amount = null; String decision = null; String ccAuthReply_authorizationCode = null; String requestId = null; String customerEmail = null; String orderAmount_publicSignature = null; String orderAmount = null; String responseEnvironment = null; KKAppEng kkAppEng = null; if (log.isDebugEnabled()) { log.debug(CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE + " Response Action"); } try { // Process the parameters sent in the callback StringBuffer sb = new StringBuffer(); if (request != null) { Enumeration<String> en = request.getParameterNames(); while (en.hasMoreElements()) { String paramName = en.nextElement(); String paramValue = request.getParameter(paramName); if (sb.length() > 0) { sb.append("\n"); } sb.append(paramName); sb.append(" = "); sb.append(paramValue); // Capture important variables so that we can determine whether the transaction // was successful if (paramName != null) { if (paramName.equalsIgnoreCase("kkret")) { if (paramValue.equalsIgnoreCase("true")) { return "Approved"; } return "CheckoutError"; } else if (paramName.equalsIgnoreCase("decision")) { decision = paramValue; } else if (paramName.equalsIgnoreCase("reconciliationID")) { reconciliationID = paramValue; } else if (paramName.equalsIgnoreCase(CyberSourceHOP.CYBERSOURCEHOP_MERCHANT_REF)) { merchantReference = paramValue; } else if (paramName.equalsIgnoreCase(CyberSource.CYBERSOURCE_ENVIRONMENT)) { responseEnvironment = paramValue; } else if (paramName.equalsIgnoreCase("reasonCode")) { reasonCode = paramValue; } else if (paramName.equalsIgnoreCase("ccAuthReply_amount")) { ccAuthReply_amount = paramValue; } else if (paramName.equalsIgnoreCase("ccAuthReply_authorizationCode")) { ccAuthReply_authorizationCode = paramValue; } else if (paramName.equalsIgnoreCase("requestId")) { requestId = paramValue; } else if (paramName.equalsIgnoreCase("orderAmount")) { orderAmount = paramValue; } else if (paramName.equalsIgnoreCase("CUSTOMER_EMAIL")) { customerEmail = paramValue; } else if (paramName.equalsIgnoreCase("orderAmount_publicSignature")) { orderAmount_publicSignature = paramValue; } else { if (log.isDebugEnabled()) { log.debug("Un-processed parameter in response: '" + paramName + "' = '" + paramValue + "'"); } } } } } String fullGatewayResponse = sb.toString(); if (log.isDebugEnabled()) { log.debug( CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE + " Raw Response data:\n" + fullGatewayResponse); log.debug("\n decision = " + decision + "\n reconciliationID = " + reconciliationID + "\n merchantReference = " + merchantReference + "\n orderPage_environment = " + responseEnvironment + "\n reasonCode = " + reasonCode + "\n ccAuthReply_amount = " + ccAuthReply_amount + "\n ccAuthReply_authorizationCode = " + ccAuthReply_authorizationCode + "\n orderAmount = " + orderAmount + "\n requestId = " + requestId + "\n orderAmount_publicSignature = " + orderAmount_publicSignature + "\n customerEmail = " + customerEmail); } // Pick out the values from the merchantReference // Split the merchantReference into orderId, orderNumber and store information if (merchantReference == null) { throw new Exception("A merchant reference wasn't received from CyberSource"); } StringTokenizer st = new StringTokenizer(merchantReference, "~"); String orderIdStr = null; int orderId = -1; String orderNumberStr = null; String storeId = null; int engineMode = -1; boolean customersShared = false; boolean productsShared = false; boolean categoriesShared = false; String countryCode = null; if (st.hasMoreTokens()) { orderIdStr = st.nextToken(); orderId = Integer.parseInt(orderIdStr); } if (st.hasMoreTokens()) { orderNumberStr = st.nextToken(); } if (st.hasMoreTokens()) { storeId = st.nextToken(); } if (st.hasMoreTokens()) { engineMode = Integer.parseInt(st.nextToken()); } if (st.hasMoreTokens()) { customersShared = Boolean.getBoolean(st.nextToken()); } if (st.hasMoreTokens()) { productsShared = Boolean.getBoolean(st.nextToken()); } if (st.hasMoreTokens()) { categoriesShared = Boolean.getBoolean(st.nextToken()); } if (st.hasMoreTokens()) { countryCode = st.nextToken(); } if (log.isDebugEnabled()) { log.debug("Derived from merchantReference: \n" + " OrderId = " + orderId + "\n" + " OrderNumber = " + orderNumberStr + "\n" + " StoreId = " + storeId + "\n" + " EngineMode = " + engineMode + "\n" + " CustomersShared = " + customersShared + "\n" + " ProductsShared = " + productsShared + "\n" + " CategoriesShared = " + categoriesShared + "\n" + " CountryCode = " + countryCode); } // Get an instance of the KonaKart engine // kkAppEng = this.getKKAppEng(request); // v3.2 code kkAppEng = this.getKKAppEng(request, response); // v4.1 code int custId = this.loggedIn(request, response, kkAppEng, "Checkout"); // Check to see whether the user is logged in if (custId < 0) { if (log.isInfoEnabled()) { log.info("Customer is not logged in"); } return KKLOGIN; } // If we didn't receive a decision, we log a warning and return if (decision == null) { String msg = "No decision returned for the " + CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE + " module"; saveIPNrecord(kkAppEng, orderId, CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE, fullGatewayResponse, decision, reconciliationID, RET1_DESC + msg, RET1); throw new Exception(msg); } String sharedSecret = kkAppEng.getCustomConfig(orderIdStr + "-CUSTOM1", true); boolean validateSignature = false; if (sharedSecret == null) { if (log.isWarnEnabled()) { log.warn("CyberSource shared secret is null"); } validateSignature = false; } else { if (log.isDebugEnabled()) { log.debug("Shared Secret found on session for order " + orderIdStr); } // Check the authenticity of the message by checking the signature validateSignature = CyberSourceHOPHMACTools.verifyBase64EncodedSignature(sharedSecret, orderAmount_publicSignature, orderAmount); } if (log.isDebugEnabled()) { log.debug("Signature Validation Result: " + validateSignature); } // If the signature on the amount doesn't validate we log a warning and return if (!validateSignature) { String msg = "Signature Validation Failed for the " + CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE + " module - orderId " + orderId; saveIPNrecord(kkAppEng, orderId, CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE, fullGatewayResponse, decision, reconciliationID, RET1_DESC + msg, RET1); throw new Exception(msg); } // Validate we are in the correct environment boolean validateEnvironment = true; String sessionEnvironment = kkAppEng.getCustomConfig(orderIdStr + "-CUSTOM2", true); if (sessionEnvironment == null) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment is null on the session"); } validateEnvironment = false; } else if (illegalEnvironmentValue(sessionEnvironment)) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment on the session is illegal"); } validateEnvironment = false; } else if (illegalEnvironmentValue(responseEnvironment)) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment in the session is illegal"); } validateEnvironment = false; } else if (!sessionEnvironment.equals(responseEnvironment)) { if (log.isWarnEnabled()) { log.warn("CyberSource Operating Environment in the session (" + sessionEnvironment + ") does not match that in the response (" + responseEnvironment + ")"); } validateEnvironment = false; } // If the signature on the amount doesn't validate we log a warning and return if (!validateEnvironment) { String msg = "Environment Validation Failed for the " + CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE + " module - orderId " + orderId; saveIPNrecord(kkAppEng, orderId, CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE, fullGatewayResponse, decision, reconciliationID, RET1_DESC + msg, RET1); throw new Exception(msg); } // See if we need to send an email, by looking at the configuration String sendEmailsConfig = kkAppEng.getConfig(ConfigConstants.SEND_EMAILS); boolean sendEmail = false; if (sendEmailsConfig != null && sendEmailsConfig.equalsIgnoreCase("true")) { sendEmail = true; } // If we didn't receive an ACCEPT decision, we let the user Try Again OrderUpdateIf updateOrder = new OrderUpdate(); updateOrder.setUpdatedById(kkAppEng.getActiveCustId()); if (!decision.equals("ACCEPT")) { if (log.isDebugEnabled()) { log.debug("Payment Not Approved for orderId: " + orderId + " for customer: " + customerEmail + " reason: " + getReasonDescription(reasonCode)); } saveIPNrecord(kkAppEng, orderId, CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE, fullGatewayResponse, decision, reconciliationID, RET2_DESC + decision + " : " + getReasonDescription(reasonCode), RET2); String comment = ORDER_HISTORY_COMMENT_KO + decision; kkAppEng.getEng().updateOrder(kkAppEng.getSessionId(), orderId, com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, sendEmail, comment, updateOrder); if (sendEmail) { sendOrderConfirmationMail(kkAppEng, orderId, /* success */false); } String msg = kkAppEng.getMsg("checkout.cc.gateway.error", new String[] { comment }); addActionError(msg); /* * Add a parameter that is sent back to this action when trying to break out of the * frame */ if (request != null) { StringBuffer retUrl = request.getRequestURL(); retUrl.append("?kkret=false"); this.url = retUrl.toString(); return "redirect"; } throw new KKException("The HttpServletRequest is null"); } // If successful, we forward to "Approved" if (log.isDebugEnabled()) { log.debug("Payment Approved for orderId " + orderId + " for customer " + customerEmail); } saveIPNrecord(kkAppEng, orderId, CyberSourceHOP.CYBERSOURCEHOP_GATEWAY_CODE, fullGatewayResponse, decision, reconciliationID, RET0_DESC, RET0); String comment = ORDER_HISTORY_COMMENT_OK + reconciliationID; kkAppEng.getEng().updateOrder(kkAppEng.getSessionId(), orderId, com.konakart.bl.OrderMgr.PAYMENT_RECEIVED_STATUS, sendEmail, comment, updateOrder); // If the order payment was approved we update the inventory kkAppEng.getEng().updateInventory(kkAppEng.getSessionId(), orderId); if (sendEmail) { sendOrderConfirmationMail(kkAppEng, orderId, /* success */true); } // If we received no exceptions, delete the basket kkAppEng.getBasketMgr().emptyBasket(); /* * Add a parameter that is sent back to this action when trying to break out of the * frame */ if (request != null) { StringBuffer retUrl = request.getRequestURL(); retUrl.append("?kkret=true"); this.url = retUrl.toString(); return "redirect"; } throw new KKException("The HttpServletRequest is null"); } catch (Exception e) { e.printStackTrace(); return super.handleException(request, e); } }
From source file:org.apache.phoenix.hive.util.PhoenixStorageHandlerUtil.java
public static void printConfiguration(Configuration config) { if (Boolean.getBoolean("dev")) { for (Iterator<Entry<String, String>> iterator = config.iterator(); iterator.hasNext();) { Entry<String, String> entry = iterator.next(); System.out.println(entry.getKey() + "=" + entry.getValue()); }/* ww w . j av a2 s . c o m*/ } }
From source file:com.comcast.cns.persistence.CNSAttributesCassandraPersistence.java
@Override public CNSSubscriptionAttributes getSubscriptionAttributes(String subscriptionArn) throws Exception { CNSSubscriptionAttributes subscriptionAttributes = null; CmbColumnSlice<String, String> slice = cassandraHandler.readColumnSlice( AbstractDurablePersistence.CNS_KEYSPACE, columnFamilySubscriptionAttributes, subscriptionArn, null, null, 10, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER); if (slice != null) { subscriptionAttributes = new CNSSubscriptionAttributes(); if (slice.getColumnByName("confirmationWasAuthenticated") != null) { subscriptionAttributes.setConfirmationWasAuthenticated( Boolean.getBoolean(slice.getColumnByName("confirmationWasAuthenticated").getValue())); }//from w w w. ja va 2 s.co m if (slice.getColumnByName("deliveryPolicy") != null) { subscriptionAttributes.setDeliveryPolicy(new CNSSubscriptionDeliveryPolicy( new JSONObject(slice.getColumnByName("deliveryPolicy").getValue()))); } // if "ignore subscription override" is checked, get effective delivery policy from topic delivery policy, otherwise // get effective delivery policy from subscription delivery policy CNSSubscription subscription = PersistenceFactory.getSubscriptionPersistence() .getSubscription(subscriptionArn); if (subscription == null) { throw new SubscriberNotFoundException("Subscription not found. arn=" + subscriptionArn); } CNSTopicAttributes topicAttributes = getTopicAttributes(subscription.getTopicArn()); if (topicAttributes != null) { CNSTopicDeliveryPolicy topicEffectiveDeliveryPolicy = topicAttributes.getEffectiveDeliveryPolicy(); if (topicEffectiveDeliveryPolicy != null) { if (topicEffectiveDeliveryPolicy.isDisableSubscriptionOverrides() || subscriptionAttributes.getDeliveryPolicy() == null) { CNSSubscriptionDeliveryPolicy effectiveDeliveryPolicy = new CNSSubscriptionDeliveryPolicy(); effectiveDeliveryPolicy .setHealthyRetryPolicy(topicEffectiveDeliveryPolicy.getDefaultHealthyRetryPolicy()); effectiveDeliveryPolicy .setSicklyRetryPolicy(topicEffectiveDeliveryPolicy.getDefaultSicklyRetryPolicy()); effectiveDeliveryPolicy .setThrottlePolicy(topicEffectiveDeliveryPolicy.getDefaultThrottlePolicy()); subscriptionAttributes.setEffectiveDeliveryPolicy(effectiveDeliveryPolicy); } else { subscriptionAttributes .setEffectiveDeliveryPolicy(subscriptionAttributes.getDeliveryPolicy()); } } } if (slice.getColumnByName("topicArn") != null) { subscriptionAttributes.setTopicArn(slice.getColumnByName("topicArn").getValue()); } if (slice.getColumnByName("userId") != null) { subscriptionAttributes.setUserId(slice.getColumnByName("userId").getValue()); } subscriptionAttributes.setSubscriptionArn(subscriptionArn); } return subscriptionAttributes; }
From source file:org.apache.maven.wagon.providers.http.LightweightHttpWagon.java
protected void openConnectionInternal() throws ConnectionException, AuthenticationException { final ProxyInfo proxyInfo = getProxyInfo("http", getRepository().getHost()); if (proxyInfo != null) { this.proxy = getProxy(proxyInfo); }//w ww. j av a2s . c om authenticator.setWagon(this); boolean usePreemptiveAuthentication = Boolean.getBoolean("maven.wagon.http.preemptiveAuthentication") || Boolean.parseBoolean(repository.getParameter("preemptiveAuthentication")) || this.preemptiveAuthentication; setPreemptiveAuthentication(usePreemptiveAuthentication); }