List of usage examples for java.util Locale UK
Locale UK
To view the source code for java.util Locale UK.
Click Source Link
From source file:org.alfresco.repo.virtual.store.VirtualStoreImpl.java
@Override public Map<QName, Serializable> getProperties(Reference reference) throws VirtualizationException { final Protocol protocol = reference.getProtocol(); if (Protocols.VIRTUAL.protocol.equals(protocol) || Protocols.VANILLA.protocol.equals(protocol)) { VirtualFolderDefinition folderDefinition = resolveVirtualFolderDefinition(reference); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); // We first set default property values. They might be overridden by // folder definition properties. properties.put(ContentModel.PROP_NAME, folderDefinition.getName()); StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; properties.put(ContentModel.PROP_STORE_IDENTIFIER, storeRef.getIdentifier()); properties.put(ContentModel.PROP_STORE_PROTOCOL, storeRef.getProtocol()); properties.put(ContentModel.PROP_LOCALE, Locale.UK.toString()); properties.put(ContentModel.PROP_MODIFIED, new Date()); properties.put(ContentModel.PROP_MODIFIER, AuthenticationUtil.SYSTEM_USER_NAME); properties.put(ContentModel.PROP_CREATED, new Date()); properties.put(ContentModel.PROP_CREATOR, AuthenticationUtil.SYSTEM_USER_NAME); properties.put(ContentModel.PROP_NODE_DBID, 0); properties.put(ContentModel.PROP_DESCRIPTION, folderDefinition.getDescription()); // ACE-5303 : ContentModel.PROP_TITLE remains unset // We add virtual folder definition structure properties. They might // override the above defaults. Map<String, String> nodeProperties = folderDefinition.getProperties(); if (nodeProperties != null) { Set<Entry<String, String>> propertyEntries = nodeProperties.entrySet(); NamespacePrefixResolver nsPrefixResolver = environment.getNamespacePrefixResolver(); for (Entry<String, String> propertyValueEntry : propertyEntries) { QName propertyQName = QName.createQName(propertyValueEntry.getKey(), nsPrefixResolver); properties.put(propertyQName, propertyValueEntry.getValue().toString()); }/*from w w w . j a va 2 s . c om*/ } return properties; } else { NodeRef actual = reference.execute(new GetActualNodeRefMethod(environment)); Map<QName, Serializable> properties = environment.getProperties(actual); properties.put(VirtualContentModel.PROP_ACTUAL_NODE_REF, actual.toString()); return properties; } }
From source file:biz.taoconsulting.dominodav.resource.DAVAbstractResource.java
/** * @param dateString//from w w w.ja v a 2 s . co m * a String that looks like a date * @return date the newly found date */ private Date getLocaleDate(String dateString) { // TODO Check if implementation is clean String creatFormat = "dd'/'mm'/'yyyy' 'H':'m':'s"; // "02/02/2006 09:34:20"; SimpleDateFormat fmt = new SimpleDateFormat(creatFormat, Locale.UK); Date tmpDate; try { tmpDate = fmt.parse(dateString); } catch (ParseException e) { LOGGER.error(e); tmpDate = new Date(); // Default value just in case } return tmpDate; }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
private void generateCertificateKeyUsageNotForEncryption() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPrivateKey = "30820276020100300d06092a864886f70d0101010500048202603082025c" + "0201000281810096383c89ad7b3c3be9dfcb24c1ba2b19f681847eaf862c" + "eec3cb2daf20da3f68f30221b46444c259228cc84f35095af19d2496a486" + "b4e818ce17241dd792a6c6ad07f8601c728f71f8016e1dbc5905fade3ecf" + "37b6374f4668bb3a5de16059125cea11ef3bd712a375dd33894670faa18b" + "8c733227a530ec569fcb5ade02523d020301000102818030202c24df934f" + "a4d234845c6e443a72c2ea938c12a7a5d5889c9b32341037a863d2170237" + "ed5f66370f6b4d14ecbe5a11c21b10f2a71a8477e22a0bf578623d5e961d" + "41151118d6114296baa55c479a33de26ef872f61eb59388bddb43c970614" + "52983edf79e71def89879820f06667b237be04b1fb18eaa203fb59d82ebc" + "71024100c9b7820310a62a3815564519a038bcfd99965ed9adf494214fca" + "d0d08019b9ba6821bcfc9faf448f1650e9e7aeba6b9ce3e7d6f9449c1897" + "d7dd7d0f4e8c39fb024100bea50896dc44c9cd710611e229fd7fe01c06f8" + "db7ea4428c99b243ba26937eaedfd9fae5eed02e292a8a4c7092320e29dc" + "143223b85cfeb43efbb1603ebce72702407bc7f82819575e20fc36ec4045" + "698bcfb327eb1c78fad4cb7c4360d0114bb805035170bf34de409bed7dc9" + "8b3a557b23d356b93c4d35dc81911d81589b42c17102406eb7cfc6358469" + "a2bb8a27e6ae364006baa03df4d396b7e389fb62a4007556745f22ec388f" + "3a2e24d044e361d935e2cde2b783eb04ce5549feee13b46e9b2caf024100" + "a8c35546c2241ce9b90b14c667d2b83512a6ad3b50f1511696c3eb7f608b" + "c292bad19c4fe11b466a045ebfdb92f371199369e22e5ce6a16578c9a25c" + "7b67e997"; String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d003081890281810096" + "383c89ad7b3c3be9dfcb24c1ba2b19f681847eaf862ceec3cb2daf20da3f" + "68f30221b46444c259228cc84f35095af19d2496a486b4e818ce17241dd7" + "92a6c6ad07f8601c728f71f8016e1dbc5905fade3ecf37b6374f4668bb3a" + "5de16059125cea11ef3bd712a375dd33894670faa18b8c733227a530ec56" + "9fcb5ade02523d0203010001"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); String email = "test@example.com"; subjectBuilder.setCommonName("Valid certificate"); subjectBuilder.setEmail(email);/*from w w w. jav a2 s . co m*/ subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("Amsterdam"); subjectBuilder.setState("NH"); AltNamesBuilder altNamesBuider = new AltNamesBuilder(); altNamesBuider.setRFC822Names(email); X500Principal subject = subjectBuilder.buildPrincipal(); GeneralNames altNames = altNamesBuider.buildAltNames(); // use TreeSet because we want a deterministic certificate (ie. hash should not change) Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.DIGITALSIGNATURE); keyUsage.add(KeyUsageType.NONREPUDIATION); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION); BigInteger serialNumber = new BigInteger("1178c336c7b51cadd4ccecdd14daf22", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-Nov-2007 10:38:35"); certificateBuilder.setSubject(subject); certificateBuilder.setAltNames(altNames, true); certificateBuilder.setKeyUsage(keyUsage, true); certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, true /* critical */); 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("KeyUsageNotForEncryption", privateKey, null, chain); }
From source file:com.gtwm.pb.servlets.ServletDataMethods.java
private static void logDataChanges(HttpServletRequest request, DatabaseInfo databaseDefn, String operation) throws DisallowedException, ObjectNotFoundException { AppUserInfo currentUser = databaseDefn.getAuthManager().getUserByUserName(request, request.getRemoteUser()); String fullname = currentUser.getForename() + " " + currentUser.getSurname(); String timestamp = String.format(Locale.UK, "%1$td-%1$tb-%1$tY %1$tH:%1$tM:%1$tS", new Date()); logger.info(fullname + " (" + currentUser + ") " + operation + " at " + timestamp); }
From source file:no.imr.stox.functions.acoustic.PgNapesIO.java
public static void export(String cruise, String country, String callSignal, String path, String fileName, List<DistanceBO> distances, String species, Double intDist, Double pchThick) { // Atle: implement! Integer acoCat = PgNapesEchoConvert.getAcoCatFromPgNapesSpecies(species); BufferedWriter bWriter1 = null; BufferedWriter bWriter2 = null; try {/*ww w . ja v a 2 s.c om*/ String fil1 = path + "/" + fileName + "_Acoustic.txt"; String fil2 = path + "/" + fileName + "_AcousticValues.txt"; bWriter1 = new BufferedWriter(new FileWriter(fil1)); bWriter2 = new BufferedWriter(new FileWriter(fil2)); bWriter1.write("Country" + "" + "\t" + "Vessel" + "" + "\t" + "Cruise" + "" + "\t" + "Log" + "" + "\t"); bWriter1.write("Year" + "" + "\t" + "Month" + "" + "\t" + "Day" + "" + "\t" + "Hour" + "" + "\t"); bWriter1.write("Min" + "" + "\t" + "AcLat" + "" + "\t" + "AcLon" + "" + "\t" + "Logint" + "" + "\t"); bWriter1.write("Frequency" + "" + "\t" + "Sv_threshold"); bWriter1.newLine(); bWriter2.write("Country" + "" + "\t" + "Vessel" + "" + "\t" + "Cruise" + "" + "\t" + "Log" + "" + "\t"); bWriter2.write("Year" + "" + "\t" + "Month" + "" + "\t" + "Day" + "" + "\t" + "Species" + "" + "\t"); bWriter2.write("ChUppDepth" + "" + "\t" + "ChLowDepth" + "" + "\t" + "SA"); bWriter2.newLine(); Boolean isEnd = true; //Vertical Resolution/new channel thickness from filter Double totintdist = 0.0; Integer countdist = 0; Double sa50ch[] = new Double[1001]; //sa pr intdist Double saout[] = new Double[1001]; //sa accumulated over 5 nm. Output to files for (int g = 0; g < sa50ch.length; g++) { sa50ch[g] = 0.0; saout[g] = 0.0; } String hout1[] = new String[14]; // Sheet1: header info from first intdist in 5 nm dist for (int h = 0; h < hout1.length; h++) { hout1[h] = null; } String hout2[] = new String[8]; // Sheet2: header info from first intdist in 5 nm dist for (int h = 0; h < hout2.length; h++) { hout2[h] = null; } Resolution rr = new Resolution(); //GO THROUGH ALL OBSERVATIONS IN SELECTED DATASETT ONE OBS AT THE TIME Integer nobs = distances.size(); for (int line = 0; line < nobs; line++) { DistanceBO dist = distances.get(line); for (FrequencyBO f : dist.getFrequencies()) { FrequencyBO frequency = f; //PS! What if threshold change within a 5 nm ?? Use first value OK??? String threshold = Double.toString(frequency.getThreshold()); //String helpNumPel = Integer.toString(freq.getNum_pel_ch()); Date d = dist.getStart_time(); String helpymd = IMRdate.formatDate(d, "yyyyMMdd"); String year = helpymd.substring(0, 4); String month = helpymd.substring(4, 6); String day = helpymd.substring(6, 8); String helphms = IMRdate.formatDate(d, "HHmmss"); String hour = helphms.substring(0, 2); String min = helphms.substring(2, 4); // String Log = df.format(dist.getLog_start()/*LogFloor*/); String log = Conversion.formatDoubletoDecimalString(dist.getLog_start().doubleValue(), "0.0"); //Check if this is the end of the integrator distance (using the filter value rr.setIntDist(Math.max(intDist, dist.getIntegrator_dist())); rr.setLog(Conversion.safeStringtoDouble(log)); isEnd = rr.getIsEnd(); String acLat = Conversion.formatDoubletoDecimalString(dist.getLat_start(), "0.000"); String acLon = Conversion.formatDoubletoDecimalString(dist.getLon_start(), "0.000"); Double helppct = dist.getPel_ch_thickness(); Integer helppctR = (int) Math.round(helppct); //Number of ch per 50 meter ch Double vertRes = null; if (pchThick != null && pchThick > dist.getPel_ch_thickness()) { vertRes = pchThick; } else { vertRes = dist.getPel_ch_thickness(); } Double ww = vertRes / helppct; Integer helpnchch = ww.intValue(); //Number of 50 meter channels Integer q = frequency.getNum_pel_ch(); Integer ww1 = frequency.getNum_pel_ch() % helpnchch; Integer ww2 = (frequency.getNum_pel_ch() / helpnchch); Integer helpnch = ww2.intValue(); if (ww1 > 0) { helpnch = helpnch + 1; } if (helpnch > sa50ch[0]) { sa50ch[0] = helpnch.doubleValue(); } // SUM UP P SA VALUES FOR THIS OBSERVATION IN 50 meter CHANNELS List<SABO> salist = frequency.getSa(); for (Integer ch = 1; ch <= frequency.getNum_pel_ch(); ch++) { if (ch <= frequency.getNum_pel_ch()) { //Double saval = 0.0; for (Integer i = 0; i < salist.size(); i++) { //storage.getSaByFrequencyChannelTypeAcousticCategory(freq, "P", f.getId_acoustic_category()); SABO elm = salist.get(i); if (elm.getAcoustic_category() == null || elm.getCh() == null || elm.getCh_type() == null || !elm.getCh().equals(ch) || !elm.getCh_type().equals("P") || !elm.getAcoustic_category().equalsIgnoreCase(acoCat.toString())) { continue; } Double ch50a = (ch * helppctR.doubleValue()) % vertRes; Double ch50b = (ch * helppctR.doubleValue()) / vertRes; Integer ch50c = ch50b.intValue(); if (ch50a > 0) { ch50c = ch50c + 1; } sa50ch[ch50c] = elm.getSa() + sa50ch[ch50c]; sa50ch[1000] = elm.getSa() + sa50ch[1000]; break; } } } //IF START OF A NEW 5 NM DISTANCE KEEP HEADING VALUES if (isEnd.equals(true)) { hout1[0] = country; hout1[1] = callSignal; hout1[2] = cruise; hout1[3] = log; hout1[4] = year; hout1[5] = month; hout1[6] = day; hout1[7] = hour; hout1[8] = min; hout1[9] = acLat; hout1[10] = acLon; //hout1[11] = Logint; hout1[12] = frequency.getFreq().toString(); hout1[13] = threshold; hout2[0] = country; hout2[1] = callSignal; hout2[2] = cruise; hout2[3] = log; hout2[4] = year; hout2[5] = month; hout2[6] = day; hout2[7] = species; } //KEEP SA-VALUES FROM THIS INTEGRATOR DISTANCE if (sa50ch[0] > saout[0]) { saout[0] = sa50ch[0]; } for (int k = 1; k < saout.length; k++) { saout[k] = saout[k] + sa50ch[k]; } //Count number of intdist + totaldist countdist = countdist + 1; totintdist = totintdist + dist.getIntegrator_dist(); boolean okIntDist = false; //Check if distance from previous output distance is not to large due to holes in data: boolean okPrevDist = false; if ((rr.getEndLog() != null) && (rr.getIntDist() != null)) { if ((rr.getLog() - rr.getEndLog()) - 0.05 <= rr.getIntDist()) { okPrevDist = true; } else { okPrevDist = false; } } else { okPrevDist = true; } //Check if sum of distances is correct + check if stoplog minus startlog is equal to sum of distances if (rr.getIntDist() == null) { okIntDist = true; } else { if ((((rr.getIntDist() - 0.05) < totintdist) && (totintdist < (rr.getIntDist() + 0.05))) && okPrevDist) { okIntDist = true; } } //PRINT TO FILES if (okIntDist && isEnd) { for (int k = 1; k < saout.length; k++) { saout[k] = saout[k] / countdist; } //Sheet file 1: hout1[11] = Conversion.formatDoubletoDecimalString(totintdist, "0.0"); for (Integer elm = 0; elm < 14; elm++) { if (hout1[elm] != null) { bWriter1.write(hout1[elm] + "" + "\t"); } else { bWriter1.write(" " + "" + "\t"); } } bWriter1.newLine(); //Sheet file 2: for (Integer elm = 0; elm < saout[0].intValue(); elm++) { for (Integer e = 0; e < 8; e++) { bWriter2.write(hout2[e] + "" + "\t"); } bWriter2.write((elm * vertRes) + "" + "\t"); bWriter2.write(((elm * vertRes) + vertRes) + "" + "\t"); String sa = String.format(Locale.UK, "%11.5f", (saout[elm + 1])); bWriter2.write(sa + "" + "\t"); bWriter2.newLine(); } } else { for (int k = 1; k < sa50ch.length; k++) { sa50ch[k] = 0.0; } } if (isEnd.equals(true)) { for (int g = 0; g < sa50ch.length; g++) { sa50ch[g] = 0.0; saout[g] = 0.0; } //Total sa all channels, this variable is not used, test only sa50ch[1000] = 0.0; //Max number of 50 meter channels in 5 nm distance sa50ch[0] = 0.0; countdist = 0; totintdist = 0.0; } } // Have to look up by frequency here in future. } bWriter1.close(); bWriter2.close(); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
private void generateCertificateKeyUsageNotForSigning() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPrivateKey = "30820278020100300d06092a864886f70d0101010500048202623082025e" + "02010002818100c5ca31e3581e600cd09c7892837aecedc10d4b5eeb9d1d" + "77ac0ab497deeb842b6fe3cdd3d021bb9680691310387259acc73e6d8173" + "fa734069d0d9216c58eae254f68a075f8f9fa99c77c0383f1736be7e697a" + "859f476de03c54cb171e984f29b42813244625ff75916bb66b2839cfb661" + "acafbf045b08d682544c3a832e9f6102030100010281805a7f5328344f61" + "9f3b6bfc76fd15a78679483dee265bf2f9a88c15694fa3ef0b78dc8076a3" + "ca6b6c4740cc6a25899ca2435fbaf6fa3be3b3db36a5c277328ff544736c" + "6042e589f910f3c1df23701dec59a8e2679cde9e9984fc6032b6c8734416" + "07f062afdd59ac5d48a902b02915892d8b07ed222ba63986e02c7c2b3e3a" + "09024100f252c537b30837deb16283ac2691229a9d1a90d0832e9717a6b9" + "7321026d8a9ed001d0ce192794e1a1466371cec0e68f06a3def7daed21a0" + "32fc101021e98e3f024100d0f3fa76613b4320d47817741841c4bd36c19a" + "4a01bb57c39e854a4678d237e08b27ff4778eca5440e04856f64be56bc8b" + "67b42d32f3450fb63d2d5be1b3aa5f024100a8a1cf1af6dd063c54073188" + "908239a98d20da9c305e30c945be128f6b281dea6ce8868d9655c436cc4b" + "b69291860e2c843b6fc3de375d4a2590e200c808c7730241008e673832a5" + "61360691c6a6754072d21a01cf3fcf600ec569540792ef2438604c6f89fa" + "b842f9444875252fab1305852749fa8b18a2b8984074fa8c8729f2c01102" + "4100808c7c7d221cd46df7a56112b0fd424ca4b2755a416bf8ba23a7b292" + "253157c35eac72069a07b0145cc48bb3f15cc3f2b1e924be4af863801ba3" + "ad0d909505c8"; String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100c5" + "ca31e3581e600cd09c7892837aecedc10d4b5eeb9d1d77ac0ab497deeb84" + "2b6fe3cdd3d021bb9680691310387259acc73e6d8173fa734069d0d9216c" + "58eae254f68a075f8f9fa99c77c0383f1736be7e697a859f476de03c54cb" + "171e984f29b42813244625ff75916bb66b2839cfb661acafbf045b08d682" + "544c3a832e9f610203010001"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); String email = "test@example.com"; subjectBuilder.setCommonName("Valid certificate"); subjectBuilder.setEmail(email);/*from w w w. j a v a 2 s. c om*/ subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("Amsterdam"); subjectBuilder.setState("NH"); AltNamesBuilder altNamesBuider = new AltNamesBuilder(); altNamesBuider.setRFC822Names(email); X500Principal subject = subjectBuilder.buildPrincipal(); GeneralNames altNames = altNamesBuider.buildAltNames(); // use TreeSet because we want a deterministic certificate (ie. hash should not change) Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.KEYENCIPHERMENT); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION); BigInteger serialNumber = new BigInteger("1178c38151374d6c4b29f891b9b4a77", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-Nov-2007 10:38:35"); certificateBuilder.setSubject(subject); certificateBuilder.setAltNames(altNames, true); certificateBuilder.setKeyUsage(keyUsage, true); certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, true /* critical */); 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("KeyUsageNotForSigning", privateKey, null, chain); }
From source file:com.gtwm.pb.servlets.AppController.java
public static void carryOutPostSessionActions(HttpServletRequest request, SessionDataInfo sessionData, DatabaseInfo databaseDefn, EnumSet<SessionAction> sessionActions) throws SQLException, ObjectNotFoundException, MissingParametersException, DisallowedException { for (SessionAction sessionAction : sessionActions) { String sessionActionParam = request.getParameter(sessionAction.toString().toLowerCase(Locale.UK)); if (sessionActionParam != null) { switch (sessionAction) { case POSTSET_TABLE: ServletSessionMethods.setTable(sessionData, request, sessionActionParam, databaseDefn); break; case POSTSET_REPORT: ServletSessionMethods.setReport(request, sessionData, sessionActionParam, databaseDefn); break; case POSTSET_CUSTOM_TABLE: ServletSessionMethods.setCustomTable(sessionData, request, false, databaseDefn); break; case POSTSET_CUSTOM_REPORT: ServletSessionMethods.setCustomReport(sessionData, request, false, databaseDefn); break; }/*from ww w.java2 s.c o m*/ } } }
From source file:org.musicbrainz.search.index.RecordingIndex.java
public Document documentFromResultSet(ResultSet rs, Map<Integer, List<Tag>> tags, Map<Integer, List<String>> isrcs, Map<Integer, ArtistCreditWrapper> artistCredits, Map<Integer, ArtistCreditWrapper> trackArtistCredits, Map<Integer, List<TrackWrapper>> tracks, Map<Integer, Release> releases, Map<Integer, ArtistCreditWrapper> releaseArtists) throws SQLException { buildClock.resume();/*from w w w. ja v a2s. c om*/ Set<Integer> durations = new HashSet<Integer>(); Set<Integer> qdurs = new HashSet<Integer>(); Set<String> trackNames = new HashSet<String>(); int id = rs.getInt("recordingId"); MbDocument doc = new MbDocument(); ObjectFactory of = new ObjectFactory(); Recording recording = of.createRecording(); doc.addField(RecordingIndexField.ID, id); String guid = rs.getString("trackid"); doc.addField(RecordingIndexField.RECORDING_ID, guid); recording.setId(guid); String recordingName = rs.getString("trackname"); //Just add an accent version for recording name not track names doc.addField(RecordingIndexField.RECORDING_ACCENT, recordingName); recording.setTitle(recordingName); trackNames.add(recordingName.toLowerCase(Locale.UK)); int recordingDuration = rs.getInt("duration"); if (recordingDuration > 0) { durations.add(recordingDuration); recording.setLength(BigInteger.valueOf(recordingDuration)); } String comment = rs.getString("comment"); doc.addFieldOrNoValue(RecordingIndexField.COMMENT, comment); if (!Strings.isNullOrEmpty(comment)) { recording.setDisambiguation(comment); } boolean video = rs.getBoolean("video"); if (video) { doc.addField(RecordingIndexField.VIDEO, Boolean.toString(video)); recording.setVideo("true"); } if (isrcs.containsKey(id)) { IsrcList isrcList = of.createIsrcList(); for (String nextIsrc : isrcs.get(id)) { doc.addField(RecordingIndexField.ISRC, nextIsrc); Isrc isrc = of.createIsrc(); isrc.setId(nextIsrc); isrcList.getIsrc().add(isrc); } recording.setIsrcList(isrcList); } else { doc.addFieldOrNoValue(RecordingIndexField.ISRC, null); } //Recording Artist Credit ArtistCreditWrapper ac = artistCredits.get(id); if (ac != null) { ArtistCreditHelper.buildIndexFieldsOnlyFromArtistCredit(doc, ac.getArtistCredit(), RecordingIndexField.ARTIST, RecordingIndexField.ARTIST_NAMECREDIT, RecordingIndexField.ARTIST_ID, RecordingIndexField.ARTIST_NAME); recording.setArtistCredit(ac.getArtistCredit()); } else { System.out.println("\nNo artist credit found for recording:" + rs.getString("trackid")); } if (tracks.containsKey(id)) { ReleaseList releaseList = of.createReleaseList(); recording.setReleaseList(releaseList); // For each track that uses recording for (TrackWrapper trackWrapper : tracks.get(id)) { //Get the release details for this track Release origRelease = releases.get(trackWrapper.getReleaseId()); if (origRelease != null) { //Get Artist Credit for Track ArtistCreditWrapper taw = trackArtistCredits.get(trackWrapper.getTrackId()); //This release instance will be shared by all recordings that have a track on the release so we need //to copy details so we can append track specific details Release release = of.createRelease(); release.setId(origRelease.getId()); release.setTitle(origRelease.getTitle()); MediumList ml = of.createMediumList(); release.setReleaseGroup(origRelease.getReleaseGroup()); release.setStatus(origRelease.getStatus()); //This will be a va release if (origRelease.getArtistCredit() != null) { release.setArtistCredit(origRelease.getArtistCredit()); } //Only add if release artist credit is different to track artist, or if that not set //because same as recording artist only set if different to recording artist else { ArtistCreditWrapper racWrapper = releaseArtists.get(trackWrapper.getReleaseId()); if (racWrapper != null) { if (taw != null) { if (taw.getArtistCreditId() != racWrapper.getArtistCreditId()) { release.setArtistCredit(racWrapper.getArtistCredit()); } } else if (ac != null) { if (ac.getArtistCreditId() != racWrapper.getArtistCreditId()) { release.setArtistCredit(racWrapper.getArtistCredit()); } } } } ml.setTrackCount(origRelease.getMediumList().getTrackCount()); release.setMediumList(ml); release.setReleaseEventList(origRelease.getReleaseEventList()); releaseList.getRelease().add(release); ReleaseGroup rg = release.getReleaseGroup(); String trackGuid = trackWrapper.getTrackGuid(); doc.addNonEmptyField(RecordingIndexField.TRACK_ID, trackGuid); String primaryType = ""; if (rg.getPrimaryType() != null) { primaryType = rg.getPrimaryType().getContent(); } doc.addFieldOrUnknown(RecordingIndexField.RELEASEGROUP_ID, rg.getId()); doc.addFieldOrUnknown(RecordingIndexField.RELEASE_PRIMARY_TYPE, primaryType); if ((rg.getSecondaryTypeList() != null) && (rg.getSecondaryTypeList().getSecondaryType() != null)) { List<String> secondaryTypeStringList = new ArrayList<String>(); for (SecondaryType secondaryType : rg.getSecondaryTypeList().getSecondaryType()) { String st = ""; if (secondaryType != null) { st = secondaryType.getContent(); } doc.addField(RecordingIndexField.RELEASE_SECONDARY_TYPE, st); secondaryTypeStringList.add(st); } String type = ReleaseGroupHelper.calculateOldTypeFromPrimaryType(primaryType, secondaryTypeStringList); doc.addFieldOrNoValue(RecordingIndexField.RELEASE_TYPE, type); rg.setType(type); } else { String pt = ""; if (release.getReleaseGroup().getPrimaryType() != null) { pt = release.getReleaseGroup().getPrimaryType().getContent(); } doc.addFieldOrNoValue(RecordingIndexField.RELEASE_TYPE, pt); rg.setType(pt); } doc.addNumericField(RecordingIndexField.NUM_TRACKS, trackWrapper.getTrackCount()); doc.addNumericField(RecordingIndexField.TRACKNUM, trackWrapper.getTrackPosition()); doc.addFieldOrNoValue(RecordingIndexField.NUMBER, trackWrapper.getTrackNumber()); DefTrackData track = of.createDefTrackData(); track.setId(trackGuid); track.setTitle(trackWrapper.getTrackName()); track.setLength(BigInteger.valueOf(trackWrapper.getDuration())); track.setNumber(trackWrapper.getTrackNumber()); Medium medium = of.createMedium(); medium.setPosition(BigInteger.valueOf(trackWrapper.getMediumPosition())); Format format = new Format(); format.setContent(trackWrapper.getMediumFormat()); medium.setFormat(format); Medium.TrackList tl = of.createMediumTrackList(); tl.setCount(BigInteger.valueOf(trackWrapper.getTrackCount())); tl.setOffset(BigInteger.valueOf(trackWrapper.getTrackPosition() - 1)); release.getMediumList().getMedium().add(medium); medium.setTrackList(tl); tl.getDefTrack().add(track); String st = ""; if (release.getStatus() != null) { st = release.getStatus().getContent(); } doc.addFieldOrNoValue(RecordingIndexField.RELEASE_STATUS, st); if ((release.getReleaseEventList() != null) && (release.getReleaseEventList().getReleaseEvent().size() > 0)) { for (ReleaseEvent re : release.getReleaseEventList().getReleaseEvent()) { doc.addNonEmptyField(RecordingIndexField.RELEASE_DATE, re.getDate()); if (re.getArea() != null) { if (re.getArea().getIso31661CodeList() != null) { doc.addNonEmptyField(RecordingIndexField.COUNTRY, re.getArea().getIso31661CodeList().getIso31661Code().get(0)); } } } Collections.sort(release.getReleaseEventList().getReleaseEvent(), new ReleaseEventComparator()); ReleaseEvent firstReleaseEvent = release.getReleaseEventList().getReleaseEvent().get(0); if (!Strings.isNullOrEmpty(firstReleaseEvent.getDate())) { release.setDate(firstReleaseEvent.getDate()); } if (firstReleaseEvent.getArea() != null) { if (firstReleaseEvent.getArea().getIso31661CodeList() != null) { release.setCountry( firstReleaseEvent.getArea().getIso31661CodeList().getIso31661Code().get(0)); } } } else { doc.addFieldOrNoValue(RecordingIndexField.RELEASE_DATE, null); doc.addFieldOrNoValue(RecordingIndexField.COUNTRY, null); } doc.addField(RecordingIndexField.RELEASE_ID, release.getId()); doc.addField(RecordingIndexField.RELEASE, release.getTitle()); doc.addNumericField(RecordingIndexField.NUM_TRACKS_RELEASE, release.getMediumList().getTrackCount().intValue()); trackNames.add(trackWrapper.getTrackName().toLowerCase(Locale.UK)); doc.addField(RecordingIndexField.POSITION, String.valueOf(trackWrapper.getMediumPosition())); doc.addFieldOrNoValue(RecordingIndexField.FORMAT, trackWrapper.getMediumFormat()); //If different to the Artist Credit for the recording if (taw != null && ((ac == null) || (taw.getArtistCreditId() != ac.getArtistCreditId()))) { ArtistCreditHelper.buildIndexFieldsOnlyFromArtistCredit(doc, taw.getArtistCredit(), RecordingIndexField.ARTIST, RecordingIndexField.ARTIST_NAMECREDIT, RecordingIndexField.ARTIST_ID, RecordingIndexField.ARTIST_NAME); track.setArtistCredit(taw.getArtistCredit()); } } } } else { doc.addFieldOrNoValue(RecordingIndexField.RELEASE_TYPE, "standalone"); } if (tags.containsKey(id)) { recording.setTagList( TagHelper.addTagsToDocAndConstructTagList(of, doc, tags, id, RecordingIndexField.TAG)); } //If we have no recording length in the recording itself or the track length then we add this value so //they can search for recordings/tracks with no length if (durations.size() == 0) { doc.addField(RecordingIndexField.DURATION, Index.NO_VALUE); doc.addField(RecordingIndexField.QUANTIZED_DURATION, Index.NO_VALUE); } else { for (Integer dur : durations) { doc.addNumericField(RecordingIndexField.DURATION, dur); qdurs.add(dur / QUANTIZED_DURATION); } for (Integer qdur : qdurs) { doc.addNumericField(RecordingIndexField.QUANTIZED_DURATION, qdur); } } //Allow searching of all unique recording/track names for (String next : trackNames) { doc.addNonEmptyField(RecordingIndexField.RECORDING, next); } buildClock.suspend(); storeClock.resume(); doc.addField(RecordingIndexField.RECORDING_STORE, MMDSerializer.serialize(recording)); storeClock.suspend(); return doc.getLuceneDocument(); }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
private void generateCertificateKeyUsageOnlyNonRepudiation() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPrivateKey = "30820277020100300d06092a864886f70d0101010500048202613082025d" + "02010002818100b342cf47e9e631e987a91cd281303c79be1ee94355e439" + "4a11606b740e30752eedd3a4d4c476963be7a329d7c92ed1f818f862389b" + "2c6bbec1b3f37e83a19aa05444d89c0d3bf7e567368320d1c1f4f1ef53c0" + "cb939f1c5cd01d4a8f4f637f0c4b16ff8e6ee4ba3beb4beddfc588ae1490" + "414dcaf1277f9c3287c9ea77897219020301000102818059a6a813c71ea1" + "07b21919990d931a2ba8b1bce7382593a13f5f815de15acac055a0eb669d" + "7ad157d458fdac35a97cc91f73d96b85ef8953357cd1e20be2de79470d67" + "841c79736d3938cf751816e214c176932d1ba26158d80da6f3f5ba61ac54" + "c1c9446435b2a0ef12b5cf25a03eabd931995175d40fe6aaef17b7b46bb8" + "01024100ff909d5f9ae1d2d3317137c9a9d775c0bdbf66b88b4a5d4893a4" + "ad9c7be321b78f00e76525e4269f0c1529750e87a4d4d6e5ac20e86a7095" + "c3441663ccb5f5f9024100b390f04e1944969dc3c05a4a699e6f9ae3e28b" + "e88d5d749271c849f4ca044648bff99de49257d07bcde0900a46294e233b" + "689bd447ce1280c1f3034416b5e521024100acb70c54677504a92c39eacd" + "045693c30db983ef665b7c8da7125d2e6b5f8612eab75eaab21feda60161" + "6fe2274eaeac150ba4f79c7b0ad97bdcd110e37179e9024100a17326ed41" + "80cedf68bad133e8c50059c69dd1e7b4fb1b2df4c9fddcefaa6a3b4d08b5" + "b366f537c9a8f148f143e62d9036013762e570de68107a5c2c633306a102" + "400cb68f16900107b2d2db6175807a05261caa05cf5bb14bcbafd9202cc4" + "5f75922185187c30f95d4ce5f44481d59174548e5bddd7bfe2896e6401a8" + "ed79797fed"; String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100b3" + "42cf47e9e631e987a91cd281303c79be1ee94355e4394a11606b740e3075" + "2eedd3a4d4c476963be7a329d7c92ed1f818f862389b2c6bbec1b3f37e83" + "a19aa05444d89c0d3bf7e567368320d1c1f4f1ef53c0cb939f1c5cd01d4a" + "8f4f637f0c4b16ff8e6ee4ba3beb4beddfc588ae1490414dcaf1277f9c32" + "87c9ea778972190203010001"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); String email = "test@example.com"; subjectBuilder.setCommonName("Valid certificate"); subjectBuilder.setEmail(email);// w w w.j av a 2s . com subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("Amsterdam"); subjectBuilder.setState("NH"); AltNamesBuilder altNamesBuider = new AltNamesBuilder(); altNamesBuider.setRFC822Names(email); X500Principal subject = subjectBuilder.buildPrincipal(); GeneralNames altNames = altNamesBuider.buildAltNames(); // use TreeSet because we want a deterministic certificate (ie. hash should not change) Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.NONREPUDIATION); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION); BigInteger serialNumber = new BigInteger("1178c3b653829e895acb7100eb1f627", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-Nov-2007 10:38:35"); certificateBuilder.setSubject(subject); certificateBuilder.setAltNames(altNames, true); certificateBuilder.setKeyUsage(keyUsage, true); certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, true /* critical */); 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("KeyUsageOnlyNonRepudiation", privateKey, null, chain); }
From source file:sos.settings.SOSSettingsDialog.java
/** * @param locale/*from w w w . j a va 2 s. c o m*/ * The locale to set. */ public void setLanguage(String language) throws Exception { if (language != null && language.length() != 0) { if (language.equalsIgnoreCase("en")) { this.locale = Locale.UK; } else if (language.equalsIgnoreCase("de")) { this.locale = Locale.GERMANY; } } if (this.locale == null) { this.locale = Locale.UK; } if (this.rb == null) { this.rb = new SOSResourceBundle(); } this.rb.setBundle(this.bundleName, this.locale); SOSDate.locale = this.locale; this.sosLang = this.locale.getLanguage().toLowerCase(); }