public void setSubjectDN(String value) throws ParserException { checkMutable(); ImmutableList.Builder<GlobusPrincipal> dns = ImmutableList.builder(); if (type == TRUST_ANCHOR) { GlobusPrincipal p = new GlobusPrincipal(checkValidQuotedDn(value)); dns.add(p); IGTFInfo.this.dns = dns.build(); } else { // REVISIT: how to handle DNs with a double-quote? for (String dn : Splitter.on(',').omitEmptyStrings().trimResults().split(value)) { GlobusPrincipal p = new GlobusPrincipal(checkValidQuotedDn(dn)); dns.add(p); } ImmutableList<GlobusPrincipal> list = dns.build(); checkValid(!list.isEmpty(), "no Distinguished Names"); IGTFInfo.this.dns = list; } }
builder.setFilename(path.getFileName().toString()); switch (key) { case "alias": builder.setAlias(value); break; case "version": builder.setVersion(value); break; case "ca_url": builder.setCAUrl(value); break; case "crl_url": builder.setCRLUrl(value); break; case "policy_url": builder.setPolicyUrl(value); break; case "email": builder.setEmail(value); break; case "status": builder.setStatus(value); break; case "url": builder.setUrl(value); break; case "sha1fp.0": builder.setSHA1FP0(value);
public void setSHA1FP0(String value) throws ParserException { checkMutable(); StringBuilder onlyHex = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); if (VALID_HEX.matches(c)) { onlyHex.append(c); } else if (c != ':') { throw new ParserException("Invalid character '" + c + "'"); } } try { IGTFInfo.this.sha1fp0 = new BigInteger(onlyHex.toString(), 16); } catch (NumberFormatException e) { throw new ParserException("Invalid value: " + e.getMessage(), e); } }
public static IGTFInfo.Builder builder(Type type) { return new IGTFInfo(type).new Builder(); }
public void setRequires(String value) throws ParserException { checkMutable(); switch (type) { case POLICY: Map<String,String> pr = Splitter.on(',').trimResults(). withKeyValueSeparator(Splitter.on('=').trimResults()).split(value); IGTFInfo.this.policyRequires = ImmutableMap.copyOf(pr); break; case TRUST_ANCHOR: IGTFInfo.this.trustAnchorRequires = ImmutableList.copyOf(Splitter.on(',').trimResults().split(value)); break; } }
public void setUrl(String url) throws ParserException { checkMutable(); try { IGTFInfo.this.url = new URI(url); } catch (URISyntaxException e) { throw new ParserException(e); } }
public void setEmail(String address) throws ParserException { checkMutable(); try { IGTFInfo.this.email = new URI("mailto:" + address); } catch (URISyntaxException e) { throw new ParserException(e); } }
public void setPolicyUrl(String url) throws ParserException { checkMutable(); try { IGTFInfo.this.policyUrl = new URI(url); } catch (URISyntaxException e) { throw new ParserException(e); } }
public void setCAUrl(String url) throws ParserException { checkMutable(); try { IGTFInfo.this.caUrl = new URI(url); } catch (URISyntaxException e) { throw new ParserException(e); } }
public void setAlias(String alias) { checkMutable(); IGTFInfo.this.alias = alias; }
public void setCRLUrl(String urlList) throws ParserException { checkMutable(); try { ImmutableList.Builder<URI> urls = ImmutableList.builder(); for (String url : Splitter.on(';').trimResults().split(urlList)) { urls.add(new URI(url)); } IGTFInfo.this.crlUrl = urls.build(); } catch (URISyntaxException e) { throw new ParserException(e); } }
private String checkValidQuotedDn(String value) throws ParserException { checkMutable(); checkValid(value.startsWith("\""), "value does not start with '\"'"); checkValid(value.endsWith("\""), "value does not end with '\"'"); checkValid(value.length() > 2, "missing quoted content"); return value.substring(1, value.length()-1); }
public void setVersion(String version) throws ParserException { checkMutable(); IGTFInfo.this.version = new Version(version); }
public void setObsoletes(String value) { checkMutable(); ImmutableList.Builder<String> obsoletes = ImmutableList.builder(); for (String item : Splitter.on(',').trimResults().split(value)) { obsoletes.add(item); } IGTFInfo.this.obsoletes = obsoletes.build(); }
public void setStatus(String status) throws ParserException { checkMutable(); IGTFInfo.this.status = TO_STATUS.get(status); if (IGTFInfo.this.status == null) { throw new ParserException("Unknown value '" + status + "'"); } }
public void setFilename(String name) { checkMutable(); if (name.startsWith("policy-")) { name = name.substring(7); } if (name.endsWith(".info")) { name = name.substring(0, name.length()-5); } IGTFInfo.this.name = name; }