List of usage examples for java.text DateFormat MEDIUM
int MEDIUM
To view the source code for java.text DateFormat MEDIUM.
Click Source Link
From source file:org.hoteia.qalingo.core.web.mvc.factory.BackofficeViewBeanFactory.java
/** * @throws Exception/*from w ww .j av a 2 s . c o m*/ * */ public RuleViewBean buildViewBeanRule(final RequestData requestData, final AbstractRuleReferential rule) throws Exception { RuleViewBean ruleViewBean = new RuleViewBean(); if (rule.getId() != null) { ruleViewBean.setId(rule.getId().toString()); } ruleViewBean.setVersion(rule.getVersion()); ruleViewBean.setCode(rule.getCode()); ruleViewBean.setName(rule.getName()); ruleViewBean.setDescription(rule.getDescription()); ruleViewBean.setSalience(rule.getSalience()); DateFormat dateFormat = requestUtil.getCommonFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); if (rule.getDateCreate() != null) { ruleViewBean.setDateCreate(dateFormat.format(rule.getDateCreate())); } else { ruleViewBean.setDateCreate(Constants.NOT_AVAILABLE); } if (rule.getDateUpdate() != null) { ruleViewBean.setDateUpdate(dateFormat.format(rule.getDateUpdate())); } else { ruleViewBean.setDateUpdate(Constants.NOT_AVAILABLE); } ruleViewBean.setDetailsUrl(backofficeUrlService.generateUrl(BoUrls.RULE_DETAILS, requestData, rule)); ruleViewBean.setEditUrl(backofficeUrlService.generateUrl(BoUrls.RULE_EDIT, requestData, rule)); return ruleViewBean; }
From source file:org.hoteia.qalingo.core.web.mvc.factory.ViewBeanFactory.java
/** * //from ww w . j av a 2 s . co m */ public RetailerViewBean buildViewBeanRetailerWithoutStore(final RequestData requestData, final Retailer retailer) throws Exception { final MarketArea marketArea = requestData.getMarketArea(); final Localization localization = requestData.getMarketAreaLocalization(); final String localizationCode = localization.getCode(); final Locale locale = requestData.getLocale(); final RetailerViewBean retailerViewBean = new RetailerViewBean(); retailerViewBean.setCode(retailer.getCode()); retailerViewBean.setName(retailer.getName()); retailerViewBean.setDescription(retailer.getDescription()); retailerViewBean.setI18nName(retailer.getI18nName(localizationCode)); retailerViewBean.setI18nDescription(retailer.getI18nDescription(localizationCode)); retailerViewBean.setOfficialRetailer(retailer.isOfficialRetailer()); retailerViewBean.setBrand(retailer.isBrand()); retailerViewBean.setEcommerce(retailer.isEcommerce()); retailerViewBean.setCorner(retailer.isCorner()); String logo = retailerService.buildRetailerLogoWebPath(retailer.getLogo()); retailerViewBean.setImg(logo); if (Hibernate.isInitialized(retailer.getAddresses()) && retailer.getAddresses() != null) { RetailerAddress defaultAddress = retailer.getDefaultAddress(); if (defaultAddress != null) { retailerViewBean.getDefaultAddress().setAddress1(defaultAddress.getAddress1()); retailerViewBean.getDefaultAddress().setAddress2(defaultAddress.getAddress2()); retailerViewBean.getDefaultAddress() .setAddressAdditionalInformation(defaultAddress.getAddressAdditionalInformation()); retailerViewBean.getDefaultAddress().setPostalCode(defaultAddress.getPostalCode()); retailerViewBean.getDefaultAddress().setCity(defaultAddress.getCity()); retailerViewBean.getDefaultAddress().setStateCode(defaultAddress.getStateCode()); retailerViewBean.getDefaultAddress().setStateLabel(defaultAddress.getStateCode()); retailerViewBean.getDefaultAddress().setAreaCode(defaultAddress.getAreaCode()); retailerViewBean.getDefaultAddress().setAreaLabel(defaultAddress.getAreaCode()); retailerViewBean.getDefaultAddress().setCountryCode(defaultAddress.getCountryCode()); String countryLabel = referentialDataService.getCountryByLocale(defaultAddress.getCountryCode(), locale); retailerViewBean.getDefaultAddress().setCountry(countryLabel); retailerViewBean.getDefaultAddress().setLongitude(defaultAddress.getLongitude()); retailerViewBean.getDefaultAddress().setLatitude(defaultAddress.getLatitude()); retailerViewBean.getDefaultAddress().setPhone(defaultAddress.getPhone()); retailerViewBean.getDefaultAddress().setMobile(defaultAddress.getMobile()); retailerViewBean.getDefaultAddress().setFax(defaultAddress.getFax()); retailerViewBean.getDefaultAddress().setEmail(defaultAddress.getEmail()); retailerViewBean.getDefaultAddress().setWebsite(defaultAddress.getWebsite()); } } retailerViewBean.setQualityOfService(retailer.getQualityOfService()); retailerViewBean.setPriceScore(retailer.getPriceScore()); retailerViewBean.setRatioQualityPrice(retailer.getRatioQualityPrice()); int reviewCount = retailerViewBean.getComments().size(); retailerViewBean.setReviewCount(reviewCount); Object[] reviewCountLabelParams = { reviewCount }; retailerViewBean.setReviewCountLabel( getSpecificMessage(ScopeWebMessage.SOCIAL, "review_count_label", reviewCountLabelParams, locale)); Set<RetailerCustomerComment> customerComments = retailer.getCustomerComments(); if (Hibernate.isInitialized(customerComments) && customerComments != null) { for (RetailerCustomerComment customerComment : customerComments) { RetailerCustomerCommentViewBean customerCommentViewBean = buildViewBeanRetailerCustomerComment( requestData, retailer, customerComment); retailerViewBean.getComments().add(customerCommentViewBean); } } // // TAGS // Set<RetailerTag> tags = retailer.getTags(); // if (Hibernate.isInitialized(tags) && // tags != null) { // for (Iterator<RetailerTag> iterator = tags.iterator(); iterator.hasNext();) { // RetailerTag retailerTag = (RetailerTag) iterator.next(); // RetailerTagViewBean retailerTagViewBean = new RetailerTagViewBean(); // retailerTagViewBean.setCode(retailerTag.getCode()); // retailerTagViewBean.setName(retailerTag.getName()); // retailerTagViewBean.setDescription(retailerTag.getDescription()); // retailerViewBean.getTags().add(retailerTagViewBean); // } // } final String contextNameValue = requestUtil.getCurrentContextNameValue(); List<String> shareOptions = marketArea.getShareOptions(contextNameValue); if (shareOptions != null) { for (String shareOption : shareOptions) { String relativeUrl = urlService.generateUrl(FoUrls.RETAILER_DETAILS, requestData, retailer); ShareOptionViewBean shareOptionViewBean = buildViewBeanShareOption(requestData, shareOption, relativeUrl); retailerViewBean.getShareOptions().add(shareOptionViewBean); } } DateFormat dateFormat = requestUtil.getCommonFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); if (retailer.getDateCreate() != null) { retailerViewBean.setDateCreate(dateFormat.format(retailer.getDateCreate())); } if (retailer.getDateUpdate() != null) { retailerViewBean.setDateUpdate(dateFormat.format(retailer.getDateUpdate())); } // CLONE THE CURRENT REQUEST DATE TO BUILD THE CHANGE CONTEXT URL (MENU) RequestData requestDataChangecontext = new RequestData(); BeanUtils.copyProperties(requestData, requestDataChangecontext); requestDataChangecontext.setMarketAreaRetailer(retailer); retailerViewBean.setChangeContextUrl(urlService.buildChangeContextUrl(requestDataChangecontext)); retailerViewBean.setHomeUrl(urlService.generateUrl(FoUrls.HOME, requestDataChangecontext)); retailerViewBean.setDetailsUrl(urlService.generateUrl(FoUrls.RETAILER_DETAILS, requestData, retailer)); return retailerViewBean; }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
/** * Generates a certificate with javascript in the certificate fields to test XSS injections. * /* w ww . j av a2 s .c o m*/ * @throws Exception */ private void generateCertificateXSS() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100ab" + "c1cb1ce9ac2acef6ab4c6c6cfe38840f25095652038529aa34e21c36b1b9" + "833c8f91b34c97a803af002ed9dd6d79fc23d5e5190180a9235e61ec596d" + "b084ac78aef9f65e182977e918b9b8aa423c707bd4189e44eb9dfb68d585" + "a828ea6b16b22f382e6084140bde8a65391894b32cbd13d3b49a6a72adeb" + "49472da5995dc70203010001"; String encodedPrivateKey = "30820278020100300d06092a864886f70d0101010500048202623082025e" + "02010002818100abc1cb1ce9ac2acef6ab4c6c6cfe38840f250956520385" + "29aa34e21c36b1b9833c8f91b34c97a803af002ed9dd6d79fc23d5e51901" + "80a9235e61ec596db084ac78aef9f65e182977e918b9b8aa423c707bd418" + "9e44eb9dfb68d585a828ea6b16b22f382e6084140bde8a65391894b32cbd" + "13d3b49a6a72adeb49472da5995dc702030100010281810084959e52fd56" + "b7dcf7b117d782f363711db7bb53750fde95611c5d86e5f99f78dd20fe99" + "e80011e4760cb01de1be06b24a7f6cd036c6b8c9e2abb8a4f7f59113c67c" + "d06b3a642d67e3a4035a8cfccf0992184451adfcfccd3157e5a2f79ee0f1" + "8659c6ee801c5c081876cbd2db6390b3102b656adf7e249889ee108a4fb6" + "23f1024100d3beeecb8841cef45343138df276eb30293489ed74855dae41" + "c7b713dee7e6b4a8904fc24cab09e313f9968b4db6988fc5530da7b0f1b8" + "e71dfe26c09aed79f5024100cfa75532fa6fb39ae86dd8f05effdf9862e3" + "4ad51d71a9c6f15e6ec0d5618e7dcab1cbe93e5991fed42f913faca7d115" + "7fdcc255b6fec086070f04a736a7374b024100a619635693471421c2629e" + "a73da89d2b0557aa4e7395de7bc02bfae80276251a5814040ce57951e328" + "1b2445982b81175e719d078b1cc2afc16e4955d2f23035024100ca854b6d" + "dd9c0592062fe40d82c9909bc18e25d4b5d3be1e7e177872ef69271c7e0c" + "6b703ed402b482e32588f16df6583e8ce2a7d042a327d4488c643cc45703" + "02404b3b36fd231a6eab54303121dad4a66d732cc2d7d72b4a76108e2fc6" + "e1ee0080dd9733046009f19a96885cdad46bcd0a1ca1f62ce7eed073ca41" + "320fa140753f"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); String email = "<script>alert('test')</script>"; subjectBuilder.setCommonName("<script>alert('test')</script>"); subjectBuilder.setEmail(email); subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("<script>alert('test')</script>"); subjectBuilder.setState("<script>alert('test')</script>"); AltNamesBuilder altNamesBuider = new AltNamesBuilder(); altNamesBuider.setRFC822Names(email); X500Principal subject = subjectBuilder.buildPrincipal(); GeneralNames altNames = altNamesBuider.buildAltNames(); Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.DIGITALSIGNATURE); keyUsage.add(KeyUsageType.KEYENCIPHERMENT); keyUsage.add(KeyUsageType.NONREPUDIATION); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION); BigInteger serialNumber = new BigInteger("115fd003be5a87522cb76cfab2ec85f", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-Nov-2007 11:45:35"); certificateBuilder.setSubject(subject); certificateBuilder.setAltNames(altNames, true); certificateBuilder.setKeyUsage(keyUsage, true); certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false); certificateBuilder.setNotBefore(DateUtils.addDays(now, -20)); certificateBuilder.setNotAfter(DateUtils.addYears(now, 20)); certificateBuilder.setPublicKey(publicKey); certificateBuilder.setSerialNumber(serialNumber); certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption"); certificateBuilder.addSubjectKeyIdentifier(true); X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate); assertNotNull(certificate); certificates.add(certificate); Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate }; keyStore.setKeyEntry("certificateXSS", privateKey, null, chain); }
From source file:fr.hoteia.qalingo.core.web.mvc.factory.impl.ViewBeanFactoryImpl.java
/** * /* w w w .j ava2s. c om*/ */ public CustomerViewBean buildCustomerViewBean(final RequestData requestData, final Customer customer) throws Exception { final HttpServletRequest request = requestData.getRequest(); final Localization localization = requestData.getLocalization(); final Locale locale = localization.getLocale(); final CustomerViewBean customerViewBean = new CustomerViewBean(); if (customer != null) { customerViewBean.setAvatarImg(requestUtil.getCustomerAvatar(request, customer)); customerViewBean.setFirstname(customer.getFirstname()); customerViewBean.setLastname(customer.getLastname()); customerViewBean.setEmail(customer.getEmail()); DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); if (customer.getDateCreate() != null) { customerViewBean.setDateCreate(dateFormat.format(customer.getDateCreate())); } else { customerViewBean.setDateCreate(Constants.NOT_AVAILABLE); } if (customer.getDateUpdate() != null) { customerViewBean.setDateUpdate(dateFormat.format(customer.getDateUpdate())); } else { customerViewBean.setDateUpdate(Constants.NOT_AVAILABLE); } if (customer.getConnectionLogs() != null && customer.getConnectionLogs().size() > 0) { CustomerConnectionLog customerConnectionLog = customer.getConnectionLogs().iterator().next(); if (customerConnectionLog.getLoginDate() != null) { customerViewBean.setLastConnectionDate(dateFormat.format(customerConnectionLog.getLoginDate())); } else { customerViewBean.setLastConnectionDate(Constants.NOT_AVAILABLE); } } final ValueBean customerScreenNameValueBean = new ValueBean(); customerScreenNameValueBean .setKey(getSpecificMessage(ScopeWebMessage.CUSTOMER, "screenname.label", locale)); customerScreenNameValueBean.setValue(customer.getScreenName()); customerViewBean.getCustomerAttributes().put(CustomerViewBean.SCREEN_NAME, customerScreenNameValueBean); } return customerViewBean; }
From source file:org.tinymediamanager.core.movie.entities.Movie.java
/** * Gets the first aired as a string, formatted in the system locale. *//*w ww . j a va2s .c o m*/ public String getReleaseDateAsString() { if (this.releaseDate == null) { return ""; } return SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault()).format(releaseDate); }
From source file:org.hoteia.qalingo.core.web.mvc.factory.ViewBeanFactory.java
/** * //from ww w. j ava 2 s. c o m */ public RetailerCustomerCommentViewBean buildViewBeanRetailerCustomerComment(final RequestData requestData, final Retailer retailer, final RetailerCustomerComment customerComment) throws Exception { final Localization localization = requestData.getMarketAreaLocalization(); final String localizationCode = localization.getCode(); final RetailerCustomerCommentViewBean customerCommentViewBean = new RetailerCustomerCommentViewBean(); customerCommentViewBean.setTitle(customerComment.getTitle()); customerCommentViewBean.setComment(customerComment.getComment()); if (customerComment.getCustomer() != null) { customerCommentViewBean.setCustomerDisplayName(customerComment.getCustomer().getScreenName()); customerCommentViewBean.setCustomerUrl( urlService.buildCustomerDetailsUrl(requestData, customerComment.getCustomer().getPermalink())); customerCommentViewBean.setCustomerAvatarImg( requestUtil.getCustomerAvatar(requestData.getRequest(), customerComment.getCustomer())); } customerCommentViewBean.setComment(customerComment.getComment()); DateFormat dateFormat = requestUtil.getCommonFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); if (customerComment.getDateCreate() != null) { customerCommentViewBean.setDateCreate(dateFormat.format(customerComment.getDateCreate())); } if (customerComment.getDateUpdate() != null) { customerCommentViewBean.setDateUpdate(dateFormat.format(customerComment.getDateUpdate())); } ReviewDataVocabularyPojo reviewDataVocabulary = new ReviewDataVocabularyPojo(); reviewDataVocabulary.setItemreviewed(retailer.getI18nName(localizationCode)); if (customerComment.getCustomer() != null) { reviewDataVocabulary.setReviewer(customerComment.getCustomer().getScreenName()); } // DateFormat dateFormatDataVocabulary = requestUtil.getDataVocabularyFormatDate(requestData); reviewDataVocabulary.setDtreviewed(dateFormat.format(customerComment.getDateCreate())); // reviewDataVocabulary.setSummary(summary); reviewDataVocabulary.setDescription(customerComment.getComment()); // reviewDataVocabulary.setRating(rating); customerCommentViewBean.setReviewDataVocabulary(reviewDataVocabulary); return customerCommentViewBean; }
From source file:org.hoteia.qalingo.core.web.mvc.factory.impl.BackofficeViewBeanFactoryImpl.java
/** * /* w ww.j a v a 2s . co m*/ */ public PaymentGatewayViewBean buildPaymentGatewayViewBean(final RequestData requestData, final AbstractPaymentGateway paymentGateway) throws Exception { final PaymentGatewayViewBean paymentGatewayViewBean = new PaymentGatewayViewBean(); if (paymentGateway != null) { paymentGatewayViewBean.setName(paymentGateway.getName()); paymentGatewayViewBean.setDescription(paymentGateway.getDescription()); paymentGatewayViewBean.setCode(paymentGateway.getCode()); Set<PaymentGatewayAttribute> paymentGatewayAttributes = paymentGateway.getPaymentGatewayAttributes(); for (Iterator<PaymentGatewayAttribute> iterator = paymentGatewayAttributes.iterator(); iterator .hasNext();) { PaymentGatewayAttribute paymentGatewayAttribute = (PaymentGatewayAttribute) iterator.next(); paymentGatewayViewBean.getPaymentGatewayAttributes().put( paymentGatewayAttribute.getAttributeDefinition().getCode(), paymentGatewayAttribute.getValueAsString()); } DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); Date dateCreate = paymentGateway.getDateCreate(); if (dateCreate != null) { paymentGatewayViewBean.setDateCreate(dateFormat.format(dateCreate)); } else { paymentGatewayViewBean.setDateCreate(Constants.NOT_AVAILABLE); } Date dateUpdate = paymentGateway.getDateUpdate(); if (dateUpdate != null) { paymentGatewayViewBean.setDateUpdate(dateFormat.format(dateUpdate)); } else { paymentGatewayViewBean.setDateUpdate(Constants.NOT_AVAILABLE); } paymentGatewayViewBean.setDetailsUrl( backofficeUrlService.generateUrl(BoUrls.PAYMENT_GATEWAY_DETAILS, requestData, paymentGateway)); paymentGatewayViewBean.setEditUrl( backofficeUrlService.generateUrl(BoUrls.PAYMENT_GATEWAY_EDIT, requestData, paymentGateway)); } return paymentGatewayViewBean; }
From source file:org.sakaiproject.evaluation.logic.EvalEmailsLogicImpl.java
/** * INTERNAL METHOD<br/>/*from w ww .j a v a 2s . co m*/ * @param jobId * @param userMap * @param jobStatusReporter * @return */ protected List<String> processConsolidatedEmails(String jobId, List<Map<String, Object>> userMap, JobStatusReporter jobStatusReporter) { Integer reportingInterval = (Integer) this.settings.get(EvalSettings.LOG_PROGRESS_EVERY); if (reportingInterval == null) { // setting reportingInterval to zero results in no incremental reports. reportingInterval = 0; } int userCounter = 0; int emailCounter = 0; List<String> recipients = new ArrayList<>(); Set<String> inProgressEvaluationOwners = new HashSet<>(); boolean saveWithoutSubmit = (Boolean) settings.get(EvalSettings.ENABLE_JOB_COMPLETION_EMAIL); if (saveWithoutSubmit) { inProgressEvaluationOwners = evaluationService.getInProgressEvaluationOwners(); } for (Map<String, Object> entry : userMap) { String userId = (String) entry.get(EvalConstants.KEY_USER_ID); Date earliestDueDate = (Date) entry.get(EvalConstants.KEY_EARLIEST_DUE_DATE); Long emailTemplateId = (Long) entry.get(EvalConstants.KEY_EMAIL_TEMPLATE_ID); EvalEmailTemplate template = evaluationService.getEmailTemplate(emailTemplateId); Map<String, String> replacementValues = new HashMap<>(); EvalUser user = commonLogic.getEvalUserById(userId); // get user's locale Locale locale = commonLogic.getUserLocale(userId); // use a date which is related to the current users locale DateFormat df; boolean useDateTime = (Boolean) settings.get(EvalSettings.EVAL_USE_DATE_TIME); if (useDateTime) { // show date and time if date/time enabled df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale); } else { df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); } // add date to replacementValues replacementValues.put("EarliestEvalDueDate", df.format(earliestDueDate)); replacementValues.put("EvalCLE", commonLogic.getConfigurationSetting("ui.service", "Sakai")); // get eval tool title from settings? from message bundle? replacementValues.put("EvalToolTitle", "Teaching Evaluations"); replacementValues.put("EvalSite", "MyWorkspace"); String from = (String) settings.get(EvalSettings.FROM_EMAIL_ADDRESS); // we can get it from the eval if needed, but it should come from settings replacementValues.put("HelpdeskEmail", from); replacementValues.put("MyWorkspaceDashboard", commonLogic.getMyWorkspaceDashboard(userId)); replacementValues.put("InProgress", (inProgressEvaluationOwners.contains(userId) ? "true" : "false")); replacementValues.put("URLtoSystem", commonLogic.getServerUrl()); try { String message = TextTemplateLogicUtils.processTextTemplate(template.getMessage(), replacementValues); String subject = TextTemplateLogicUtils.processTextTemplate(template.getSubject(), replacementValues); if (message == null || subject == null) { if (jobStatusReporter != null) { jobStatusReporter.reportError(jobId, false, "error", "Error attempting to send email to user (" + user.displayId + "). "); } LOG.warn("Error trying to send consolidated email to user " + user.displayId, new RuntimeException("\nsubject == " + subject + "\nmessage == " + message)); } else { this.commonLogic.sendEmailsToUsers(from, new String[] { userId }, subject, message, false, EvalConstants.EMAIL_DELIVERY_DEFAULT); emailCounter++; recipients.add(user.displayId); } } catch (Exception e) { if (jobStatusReporter != null) { jobStatusReporter.reportError(jobId, false, "error", "Error attempting to send email to user (" + user.displayId + "). " + e); } LOG.warn("Error trying to send consolidated email to user " + user.displayId, e); } if (jobId != null && reportingInterval > 0) { userCounter++; if (userCounter % reportingInterval == 0) { if (jobStatusReporter != null) { jobStatusReporter.reportProgress(jobId, "ProcessingEmails", "Processed " + userCounter + " of " + userMap.size() + " evaluatees and sent " + emailCounter + " emails."); } } } } return recipients; }
From source file:org.hoteia.qalingo.core.web.mvc.factory.BackofficeViewBeanFactory.java
/** * // w w w. ja va2 s . co m */ public EngineSettingViewBean buildViewBeanEngineSetting(final RequestData requestData, final EngineSetting engineSetting) throws Exception { final EngineSettingViewBean engineSettingViewBean = new EngineSettingViewBean(); engineSettingViewBean.setName(engineSetting.getName()); engineSettingViewBean.setCode(engineSetting.getCode()); engineSettingViewBean.setDescription(engineSetting.getDescription()); if (StringUtils.isNotEmpty(engineSetting.getDefaultValue())) { engineSettingViewBean.setDefaultValue(engineSetting.getDefaultValue()); } else { engineSettingViewBean.setDefaultValue(Constants.NOT_AVAILABLE); } Set<EngineSettingValue> engineSettingValues = engineSetting.getEngineSettingValues(); if (engineSettingValues != null) { for (Iterator<EngineSettingValue> iterator = engineSettingValues.iterator(); iterator.hasNext();) { EngineSettingValue engineSettingValue = (EngineSettingValue) iterator.next(); engineSettingViewBean.getEngineSettingValues() .add(buildViewBeanEngineSettingValue(requestData, engineSettingValue)); } } DateFormat dateFormat = requestUtil.getCommonFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); Date dateCreate = engineSetting.getDateCreate(); if (dateCreate != null) { engineSettingViewBean.setDateCreate(dateFormat.format(dateCreate)); } else { engineSettingViewBean.setDateCreate(Constants.NOT_AVAILABLE); } Date dateUpdate = engineSetting.getDateUpdate(); if (dateUpdate != null) { engineSettingViewBean.setDateUpdate(dateFormat.format(dateUpdate)); } else { engineSettingViewBean.setDateUpdate(Constants.NOT_AVAILABLE); } engineSettingViewBean.setDetailsUrl( backofficeUrlService.generateUrl(BoUrls.ENGINE_SETTING_DETAILS, requestData, engineSetting)); engineSettingViewBean.setEditUrl( backofficeUrlService.generateUrl(BoUrls.ENGINE_SETTING_EDIT, requestData, engineSetting)); return engineSettingViewBean; }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
/** * Generates a certificate without S/MIME extended key usage extension * /*from w w w.j ava 2 s . c o m*/ * @throws Exception */ private void generateCertificateNoSMIMEExtKeyUsage() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d00308189028181008e" + "702f7941ce945a10c965ddd2113331506fb868c59760548bf8cedc35589e" + "9233e3552f518ce72e75fd22b01add0662502ade276d07f12cadfaeea440" + "edc01b0f7c01babad5ade01a759a908f5c3279c3fd02aae54940798d56a4" + "b8d3a8f3472ffa0fbad9a8d1348ec8b24cb0fc3283aac33f9bfd97b0a338" + "75b7fdea432f7b0203010001"; String encodedPrivateKey = "30820275020100300d06092a864886f70d01010105000482025f3082025b" + "020100028181008e702f7941ce945a10c965ddd2113331506fb868c59760" + "548bf8cedc35589e9233e3552f518ce72e75fd22b01add0662502ade276d" + "07f12cadfaeea440edc01b0f7c01babad5ade01a759a908f5c3279c3fd02" + "aae54940798d56a4b8d3a8f3472ffa0fbad9a8d1348ec8b24cb0fc3283aa" + "c33f9bfd97b0a33875b7fdea432f7b02030100010281807b8e43100b0e78" + "4f7c3a477bd86a051f24e8146e05e05eb65848b69ffc426822e891ad6603" + "76975f0d084cdbb821bc14f1f78d8763a3bd0805cf22cd266955f6972ba6" + "10280e6751a3219a4f89ef87faab1d4170b5d0af820844782f7317b025d2" + "9de7dcd271776d7c45da37ac5c190e9698ad84129f424d1df6bdd14c1027" + "59024100ccb868a0fe755d4327c8a02ef0a80306ee6a31726075748d04ef" + "713da09050931c0604bf2c93cca29afd65f7a56d5d501e80eac8775c5701" + "2a0ed48be3726af5024100b21df7637604312e4c80ebf2b4c04112b22938" + "611755f579d205e2c5826b32039d200cd37d1171639ee503748ac963d71c" + "f65df92a65bf6965764b7465548aaf0240388d5899e0b11b2a49fb2a04cd" + "861c0ff61c6fbc60d911714343c1cc7c66615bc20a0795a802cc2cbf13f0" + "ef104bbdd33c19f0c19ff76a317024d8a22c1a976102405ff2627c126ba9" + "ae7e098890422bba21ff14d34901d00d1ea53304784e8bbdf252669c6224" + "620c0994e35a9c21d2e0545546a5527e33370be85af3c46c7d410302401f" + "86906b598370b2fc4bc60be15521decaf16cd81d047242dc0dd316ba2902" + "baf93db44acf00d07c7762ccce97de2841fd565a9c8fee6e70da8e2779af" + "248bf1"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); String email = "test@example.com"; subjectBuilder.setCommonName("No S/MIME extended key usage"); subjectBuilder.setEmail(email); subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("Amsterdam"); subjectBuilder.setState("NH"); AltNamesBuilder altNamesBuider = new AltNamesBuilder(); altNamesBuider.setRFC822Names(email); X500Principal subject = subjectBuilder.buildPrincipal(); GeneralNames altNames = altNamesBuider.buildAltNames(); Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.DIGITALSIGNATURE); keyUsage.add(KeyUsageType.KEYENCIPHERMENT); keyUsage.add(KeyUsageType.NONREPUDIATION); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); BigInteger serialNumber = new BigInteger("115fd035ba042503bcc6ca44680f9f8", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-November-2007 11:46:35"); certificateBuilder.setSubject(subject); certificateBuilder.setAltNames(altNames, true); certificateBuilder.setKeyUsage(keyUsage, true); // make extended key usage critical certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, true); certificateBuilder.setNotBefore(DateUtils.addDays(now, -20)); certificateBuilder.setNotAfter(DateUtils.addYears(now, 20)); certificateBuilder.setPublicKey(publicKey); certificateBuilder.setSerialNumber(serialNumber); certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption"); X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate); assertNotNull(certificate); certificates.add(certificate); Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate }; keyStore.setKeyEntry("NoSMIMEExtKeyUsage", privateKey, null, chain); }