@Override public Set<String> names() { return underlying.names(); }
@Override public Set<String> names() { return underlying.names(); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof ConfPairs)) { return false; } ConfPairs other = (ConfPairs) obj; Set<String> thisNames = names(); Set<String> otherNames = other.names(); if (!thisNames.equals(otherNames)) { return false; } for (String name : thisNames) { if (!CompareUtil.equalsObject(value(name), other.value(name))) { return false; } } return true; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof ConfPairs)) { return false; } ConfPairs other = (ConfPairs) obj; Set<String> thisNames = names(); Set<String> otherNames = other.names(); if (!thisNames.equals(otherNames)) { return false; } for (String name : thisNames) { if (!CompareUtil.equalsObject(value(name), other.value(name))) { return false; } } return true; }
public static String eraseSensitiveData(String conf) { if (conf == null || !conf.toLowerCase().contains("password")) { return conf; } try { ConfPairs pairs = new ConfPairs(conf); for (String name : pairs.names()) { if (name.toLowerCase().contains("password")) { String value = pairs.value(name); if (value != null && !StringUtil.startsWithIgnoreCase(value, "PBE:")) { pairs.putPair(name, "<sensitive>"); } } } return pairs.getEncoded(); } catch (Exception ex) { return conf; } }
public static AccessDescription createAccessDescription(String accessMethodAndLocation) throws BadInputException { Args.notNull(accessMethodAndLocation, "accessMethodAndLocation"); ConfPairs pairs; try { pairs = new ConfPairs(accessMethodAndLocation); } catch (IllegalArgumentException ex) { throw new BadInputException("invalid accessMethodAndLocation " + accessMethodAndLocation); } Set<String> oids = pairs.names(); if (oids == null || oids.size() != 1) { throw new BadInputException("invalid accessMethodAndLocation " + accessMethodAndLocation); } String accessMethodS = oids.iterator().next(); String taggedValue = pairs.value(accessMethodS); ASN1ObjectIdentifier accessMethod = new ASN1ObjectIdentifier(accessMethodS); GeneralName location = createGeneralName(taggedValue); return new AccessDescription(accessMethod, location); }
private static String convertSignerConf(FileOrValue confFv, Map<String, String> properties, String baseDir) throws IOException { String conf; if (confFv.getValue() != null) { conf = confFv.getValue(); } else { conf = getValue(confFv.getFile(), properties, baseDir); } conf = expandConf(conf, properties); if (!conf.contains("file:")) { return conf; } ConfPairs confPairs = new ConfPairs(conf); boolean changed = false; for (String name : confPairs.names()) { String value = confPairs.value(name); if (!value.startsWith("file:")) { continue; } changed = true; String fileName = value.substring("file:".length()); byte[] binValue = getBinary(fileName, properties, baseDir); confPairs.putPair(name, "base64:" + Base64.encodeToString(binValue)); } return changed ? confPairs.getEncoded() : conf; }