- String submitText=UPDATE;
- boolean delete=true;
- try {
- Artifact arti =gui.cmClientAsUser(trans.getUserPrincipal(), new Retryable<Artifact>() {
- @Override
- public Artifact code(Rcli<?> client) throws CadiException, ConnectException, APIException {
- Future<Artifacts> fa = client.read("/cert/artifacts/"+incomingID+'/'+incomingMach, gui.artifactsDF);
- if(fa.get(AAFcli.timeout())) {
- for(Artifact arti : fa.value.getArtifact()) {
- return arti; // just need the first one
- }
- }
- return null;
- }
- });
- if(arti==null) {
- Organization org = OrganizationFactory.get(trans);
- Identity user = org.getIdentity(trans, incomingID);
- if(user==null) {
- hgen.p("The mechID you typed, \"" + incomingID + "\", is not a valid " + org.getName() + " ID");
- return;
- }
- arti = new Artifact();
- arti.setMechid(incomingID);
- Identity managedBy = user.responsibleTo();
- if(managedBy == null) {
- arti.setSponsor("Unknown Sponsor");
- } else {
- arti.setSponsor(managedBy.fullID());
- }
- arti.setMachine(incomingMach);
- arti.setNs(incomingNS);
- arti.setDir("");
- arti.setCa("aaf");
- arti.setOsUser("");
- arti.setRenewDays(30);
- arti.setNotification("mailto:"+user.email());
- arti.getType().add(types[0]);
- arti.getType().add(types[3]);
- submitText = CREATE;
- delete = false;
- } else {
- if(arti.getNotification()==null) {
- Organization org = OrganizationFactory.get(trans);
- Identity user = org.getIdentity(trans, incomingID);
- arti.setNotification("mailto:"+user.email());
- }
- }
- Mark table = new Mark(TABLE);
- hgen.incr(table)
- .input(fields[0],"AppID*",true,"value="+arti.getMechid())
- .input("sponsor", "Sponsor",false,"value="+arti.getSponsor(),"readonly","style=border:none;background-color:white;")
- .input(fields[1],"FQDN*",true,"value="+arti.getMachine(),"style=width:130%;");
-// if(maySans) {
- hgen.incr(HTMLGen.TR).incr(HTMLGen.TD).end()
- .incr(HTMLGen.TD,"class=subtext").text("Use Fully Qualified Domain Names (that will be in DNS), ");
- if(!trans.fish(getPerm(arti.getCa(),"ip"))) {
- hgen.text("NO ");
- }
- StringBuilder sb = null;
- for(String s: arti.getSans()) {
- if(sb==null) {
- sb = new StringBuilder();
- } else {
- sb.append(", ");
- }
- sb.append(s);
- }
-
- hgen.text("IPs allowed, separated by commas.").end()
- .input(fields[11], "SANs", false, "value="+(sb==null?"":sb.toString()),"style=width:130%;");
-// }
- hgen.input(fields[2],"Namespace",true,"value="+arti.getNs(),"style=width:130%;")
- .input(fields[3],"Directory", true, "value="+arti.getDir(),"style=width:130%;")
- .input(fields[4],"Certificate Authority",true,"value="+arti.getCa(),"style=width:130%;")
- .input(fields[5],"O/S User",true,"value="+arti.getOsUser())
- .input(fields[6],"Renewal Days before Expiration", true, "value="+arti.getRenewDays(),"style=width:20%;")
- .input(fields[7],"Notification",true,"value="+arti.getNotification())
- .incr(HTMLGen.TR)
- .incr(HTMLGen.TD).leaf("label","for=types","required").text("Artifact Types").end(2)
- .incr(HTMLGen.TD);
- for(int i=0;i<types.length;++i) {
- hgen.leaf("input","type=checkbox","name=types."+i,arti.getType().contains(types[i])?"checked":"").text(types[i]).end().br();
- }
-
- Mark tr = new Mark();
- hgen.incr(tr,HTMLGen.TR).incr(HTMLGen.TD,"id=trcopy")
- .leaf("input","id=cbcopy","type=checkbox","onclick="+COPY_ARTIFACT+"()").text("Copy Artifact").end(2)
- .incr(HTMLGen.TD,"id=tdcopy","style:display:none;")
- .incr("label","id=instruct","style=font-style:italic;font-size:80%;display:none;")
- .text("Add full machine names, separated by commas.").end()
- .tagOnly("input","id="+fields[9],"name="+fields[9],"style=display:none;width:150%;").end(2)
- .end(tr);
- hgen.incr(tr,HTMLGen.TR,"id=trdelete").incr(HTMLGen.TD,"id=tddelete")
- .leaf("input","id=cbdelete","type=checkbox","onclick="+DELETE_ARTIFACT+"()",delete?"style:display:none;":"").text("Delete Artifact").end(2)
- .end(tr);
- hgen.end(table);
-
- hgen.tagOnly("input","id="+fields[8],"name="+fields[8],"value="+submitText,"style=display:none;");
- hgen.tagOnly("input","id=theButton","type=submit", "orig="+submitText,"value="+submitText);
-
- } catch(CadiException | LocatorException | OrganizationException e) {
- throw new APIException(e);
- }
- }
+ String submitText=UPDATE;
+ boolean delete=true;
+ try {
+ Artifact arti =gui.cmClientAsUser(trans.getUserPrincipal(), new Retryable<Artifact>() {
+ @Override
+ public Artifact code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ Future<Artifacts> fa = client.read("/cert/artifacts/"+incomingID+'/'+incomingMach, gui.artifactsDF);
+ if(fa.get(AAFcli.timeout())) {
+ for(Artifact arti : fa.value.getArtifact()) {
+ return arti; // just need the first one
+ }
+ }
+ return null;
+ }
+ });
+ if(arti==null) {
+ Organization org = OrganizationFactory.get(trans);
+ Identity user = org.getIdentity(trans, incomingID);
+ if(user==null) {
+ hgen.p("The mechID you typed, \"" + incomingID + "\", is not a valid " + org.getName() + " ID");
+ return;
+ }
+ arti = new Artifact();
+ arti.setMechid(incomingID);
+ Identity managedBy = user.responsibleTo();
+ if(managedBy == null) {
+ arti.setSponsor("Unknown Sponsor");
+ } else {
+ arti.setSponsor(managedBy.fullID());
+ }
+ arti.setMachine(incomingMach);
+ arti.setNs(incomingNS);
+ arti.setDir("");
+ arti.setCa("aaf");
+ arti.setOsUser("");
+ arti.setRenewDays(30);
+ arti.setNotification("mailto:"+user.email());
+ arti.getType().add(types[0]);
+ arti.getType().add(types[3]);
+ submitText = CREATE;
+ delete = false;
+ } else {
+ if(arti.getNotification()==null) {
+ Organization org = OrganizationFactory.get(trans);
+ Identity user = org.getIdentity(trans, incomingID);
+ arti.setNotification("mailto:"+user.email());
+ }
+ }
+ Mark table = new Mark(TABLE);
+ hgen.incr(table)
+ .input(fields[0],"AppID*",true,"value="+arti.getMechid())
+ .input("sponsor", "Sponsor",false,"value="+arti.getSponsor(),"readonly","style=border:none;background-color:white;")
+ .input(fields[1],"FQDN*",true,"value="+arti.getMachine(),"style=width:130%;");
+// if(maySans) {
+ hgen.incr(HTMLGen.TR).incr(HTMLGen.TD).end()
+ .incr(HTMLGen.TD,"class=subtext").text("Use Fully Qualified Domain Names (that will be in DNS), ");
+ if(!trans.fish(getPerm(arti.getCa(),"ip"))) {
+ hgen.text("NO ");
+ }
+ StringBuilder sb = null;
+ for(String s: arti.getSans()) {
+ if(sb==null) {
+ sb = new StringBuilder();
+ } else {
+ sb.append(", ");
+ }
+ sb.append(s);
+ }
+
+ hgen.text("IPs allowed, separated by commas.").end()
+ .input(fields[11], "SANs", false, "value="+(sb==null?"":sb.toString()),"style=width:130%;");
+// }
+ hgen.input(fields[2],"Namespace",true,"value="+arti.getNs(),"style=width:130%;")
+ .input(fields[3],"Directory", true, "value="+arti.getDir(),"style=width:130%;")
+ .input(fields[4],"Certificate Authority",true,"value="+arti.getCa(),"style=width:130%;")
+ .input(fields[5],"O/S User",true,"value="+arti.getOsUser())
+ .input(fields[6],"Renewal Days before Expiration", true, "value="+arti.getRenewDays(),"style=width:20%;")
+ .input(fields[7],"Notification",true,"value="+arti.getNotification())
+ .incr(HTMLGen.TR)
+ .incr(HTMLGen.TD).leaf("label","for=types","required").text("Artifact Types").end(2)
+ .incr(HTMLGen.TD);
+ for(int i=0;i<types.length;++i) {
+ hgen.leaf("input","type=checkbox","name=types."+i,arti.getType().contains(types[i])?"checked":"").text(types[i]).end().br();
+ }
+
+ Mark tr = new Mark();
+ hgen.incr(tr,HTMLGen.TR).incr(HTMLGen.TD,"id=trcopy")
+ .leaf("input","id=cbcopy","type=checkbox","onclick="+COPY_ARTIFACT+"()").text("Copy Artifact").end(2)
+ .incr(HTMLGen.TD,"id=tdcopy","style:display:none;")
+ .incr("label","id=instruct","style=font-style:italic;font-size:80%;display:none;")
+ .text("Add full machine names, separated by commas.").end()
+ .tagOnly("input","id="+fields[9],"name="+fields[9],"style=display:none;width:150%;").end(2)
+ .end(tr);
+ hgen.incr(tr,HTMLGen.TR,"id=trdelete").incr(HTMLGen.TD,"id=tddelete")
+ .leaf("input","id=cbdelete","type=checkbox","onclick="+DELETE_ARTIFACT+"()",delete?"style:display:none;":"").text("Delete Artifact").end(2)
+ .end(tr);
+ hgen.end(table);
+
+ hgen.tagOnly("input","id="+fields[8],"name="+fields[8],"value="+submitText,"style=display:none;");
+ hgen.tagOnly("input","id=theButton","type=submit", "orig="+submitText,"value="+submitText);
+
+ } catch(CadiException | LocatorException | OrganizationException e) {
+ throw new APIException(e);
+ }
+ }