public void setSignerCertFile(String signerCertFile) { if (StringUtil.isNotBlank(signerCertFile)) { this.signer = null; this.signerCertFile = signerCertFile; } }
protected static boolean isNotBlank(String str) { return StringUtil.isNotBlank(str); }
protected static boolean isNotBlank(String str) { return StringUtil.isNotBlank(str); }
protected String readPrompt(String prompt) throws IOException { String tmpPrompt = prompt; if (StringUtil.isNotBlank(prompt)) { if (!prompt.endsWith(" ")) { tmpPrompt += " "; } } return readLine(tmpPrompt, null); }
protected String readPrompt(String prompt) throws IOException { String tmpPrompt = prompt; if (StringUtil.isNotBlank(prompt)) { if (!prompt.endsWith(" ")) { tmpPrompt += " "; } } return readLine(tmpPrompt, null); }
private static BufferedReader getReader(String propKey, String fallbackResource) { String confFile = System.getProperty(propKey); if (StringUtil.isNotBlank(confFile)) { LOG.info("read from file " + confFile); try { return Files.newBufferedReader(Paths.get(confFile)); } catch (IOException ex) { throw new IllegalStateException("could not access non-existing file " + confFile); } } else { InputStream confStream = SubjectDnSpec.class.getResourceAsStream(fallbackResource); if (confStream == null) { throw new IllegalStateException( "could not access non-existing resource " + fallbackResource); } LOG.info("read from resource " + fallbackResource); return new BufferedReader(new InputStreamReader(confStream)); } }
public static Date parseUtcTimeyyyyMMdd(String utcTime) { String coreUtcTime = utcTime; if (StringUtil.isNotBlank(utcTime)) { char ch = utcTime.charAt(utcTime.length() - 1); if (ch == 'z' || ch == 'Z') { coreUtcTime = utcTime.substring(0, utcTime.length() - 1); } } if (coreUtcTime == null || coreUtcTime.length() != 8) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "'"); } try { LocalDateTime localDate = LocalDateTime.parse(coreUtcTime + "000000", SDF1); Instant instant = localDate.atZone(ZONE_UTC).toInstant(); return Date.from(instant); } catch (DateTimeParseException ex) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "': " + ex.getMessage()); } }
public static Date parseUtcTimeyyyyMMddhhmmss(String utcTime) { String coreUtcTime = utcTime; if (StringUtil.isNotBlank(utcTime)) { char ch = utcTime.charAt(utcTime.length() - 1); if (ch == 'z' || ch == 'Z') { coreUtcTime = utcTime.substring(0, utcTime.length() - 1); } } if (coreUtcTime == null || coreUtcTime.length() != 14) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "'"); } try { LocalDateTime localDate = LocalDateTime.parse(coreUtcTime, SDF1); Instant instant = localDate.atZone(ZONE_UTC).toInstant(); return Date.from(instant); } catch (DateTimeParseException ex) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "': " + ex.getMessage()); } }
public static Date parseUtcTimeyyyyMMdd(String utcTime) { String coreUtcTime = utcTime; if (StringUtil.isNotBlank(utcTime)) { char ch = utcTime.charAt(utcTime.length() - 1); if (ch == 'z' || ch == 'Z') { coreUtcTime = utcTime.substring(0, utcTime.length() - 1); } } if (coreUtcTime == null || coreUtcTime.length() != 8) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "'"); } try { LocalDateTime localDate = LocalDateTime.parse(coreUtcTime + "000000", SDF1); Instant instant = localDate.atZone(ZONE_UTC).toInstant(); return Date.from(instant); } catch (DateTimeParseException ex) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "': " + ex.getMessage()); } }
public static Date parseUtcTimeyyyyMMddhhmmss(String utcTime) { String coreUtcTime = utcTime; if (StringUtil.isNotBlank(utcTime)) { char ch = utcTime.charAt(utcTime.length() - 1); if (ch == 'z' || ch == 'Z') { coreUtcTime = utcTime.substring(0, utcTime.length() - 1); } } if (coreUtcTime == null || coreUtcTime.length() != 14) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "'"); } try { LocalDateTime localDate = LocalDateTime.parse(coreUtcTime, SDF1); Instant instant = localDate.atZone(ZONE_UTC).toInstant(); return Date.from(instant); } catch (DateTimeParseException ex) { throw new IllegalArgumentException("invalid utcTime '" + utcTime + "': " + ex.getMessage()); } }
private static Set<String> splitAlgoNameTokens(String algoName) { Args.notBlank(algoName, "algoName"); String tmpAlgoName = algoName.toUpperCase(); int idx = tmpAlgoName.indexOf("AND"); Set<String> set = new HashSet<>(); if (idx == -1) { set.add(tmpAlgoName); return set; } final int len = tmpAlgoName.length(); int beginIndex = 0; int endIndex = idx; while (true) { String token = tmpAlgoName.substring(beginIndex, endIndex); if (StringUtil.isNotBlank(token)) { set.add(token); } if (endIndex >= len) { return set; } beginIndex = endIndex + 3; // 3 = "AND".length() endIndex = tmpAlgoName.indexOf("AND", beginIndex); if (endIndex == -1) { endIndex = len; } } }
private List<String> namesFromTable(String table, String nameColumn) throws CaMgmtException { final String sql = concat("SELECT ", nameColumn, " FROM ", table); Statement stmt = null; ResultSet rs = null; try { stmt = createStatement(); rs = stmt.executeQuery(sql); List<String> names = new LinkedList<>(); while (rs.next()) { String name = rs.getString(nameColumn); if (StringUtil.isNotBlank(name)) { names.add(name); } } return names; } catch (SQLException ex) { throw new CaMgmtException(datasource.translate(sql, ex)); } finally { datasource.releaseResources(stmt, rs); } } // method getNamesFromTable
if (StringUtil.isNotBlank(description)) { sb.append(description); char ch = description.charAt(description.length() - 1);
if (StringUtil.isNotBlank(description)) { sb.append(description); char ch = description.charAt(description.length() - 1);
while ((line = reader.readLine()) != null) { line = line.trim(); if (StringUtil.isNotBlank(line) && !line.startsWith("#")) { passwordHint = line; break;
sb.append("server returns ").append(httpUrlConnection.getResponseCode()); String respMsg = httpUrlConnection.getResponseMessage(); if (StringUtil.isNotBlank(respMsg)) { sb.append(" ").append(respMsg);
@Override public void init(String conf) throws PasswordResolverException { if (StringUtil.isBlank(conf)) { quorum = 1; return; } ConfPairs pairs = new ConfPairs(conf); String str = pairs.value("quorum"); quorum = Integer.valueOf(str); if (quorum < 1 || quorum > 10) { throw new PasswordResolverException("quorum " + quorum + " is not in [1,10]"); } str = pairs.value("tries"); if (StringUtil.isNotBlank(str)) { int intValue = Integer.parseInt(str); if (intValue > 0) { this.tries = intValue; } } }
@Override protected Object execute0() throws Exception { MgmtEntry.Ca ca = caManager.getCa(caName); if (ca == null) { throw new CmdFailure("CA " + caName + " not available"); } Date notBefore = StringUtil.isNotBlank(notBeforeS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(notBeforeS) : null; Date notAfter = StringUtil.isNotBlank(notAfterS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(notAfterS) : null; byte[] encodedCsr = IoUtil.read(csrFile); X509Certificate cert = caManager.generateCertificate(caName, profileName, encodedCsr, notBefore, notAfter); saveVerbose("saved certificate to file", outFile, encodeCert(cert.getEncoded(), outform)); return null; }
Date validTo = getDate(validToS); X500Name subjectPattern = null; if (StringUtil.isNotBlank(subjectPatternS)) { subjectPattern = new X500Name(subjectPatternS);
extraControl = extraControl.trim(); if (StringUtil.isNotBlank(extraControl)) { entry.setExtraControl(new ConfPairs(extraControl).unmodifiable());