use of org.nhindirect.config.model.Certificate in project nhin-d by DirectProject.
the class ConfigServiceRESTCertificateStore_getCertificateWithHSMKeyTest method testGetCertifcateWithPrivKey_noPrivKeyInHSM.
public void testGetCertifcateWithPrivKey_noPrivKeyInHSM() throws Exception {
if (certService == null)
return;
final X509Certificate cert = TestUtils.loadCertificate("digSigOnly.der", null);
final Certificate modelCert = new Certificate();
modelCert.setData(cert.getEncoded());
final Collection<Certificate> certsReturned = new ArrayList<Certificate>();
certsReturned.add(modelCert);
when(proxy.getCertificatesByOwner((String) any())).thenReturn(certsReturned);
final Collection<X509Certificate> retCerts = certService.getCertificates("test.com");
assertEquals(1, retCerts.size());
final X509Certificate retCert = retCerts.iterator().next();
assertTrue(retCert instanceof X509CertificateEx);
assertTrue(((X509CertificateEx) retCert).hasPrivateKey());
}
use of org.nhindirect.config.model.Certificate in project nhin-d by DirectProject.
the class EntityModelConversion method toEntityCertificate.
public static org.nhindirect.config.store.Certificate toEntityCertificate(Certificate cert) throws CertificateException {
if (cert == null)
return null;
final org.nhindirect.config.store.Certificate retVal = new org.nhindirect.config.store.Certificate();
retVal.setOwner(cert.getOwner());
retVal.setCreateTime(cert.getCreateTime());
retVal.setData(cert.getData());
retVal.setId(cert.getId());
if (cert.getStatus() != null)
retVal.setStatus(org.nhindirect.config.store.EntityStatus.valueOf(cert.getStatus().toString()));
final CertContainer cont = CertUtils.toCertContainer(retVal.getData());
final Calendar endDate = Calendar.getInstance(Locale.getDefault());
endDate.setTime(cont.getCert().getNotAfter());
retVal.setValidEndDate(endDate);
final Calendar startDate = Calendar.getInstance(Locale.getDefault());
startDate.setTime(cont.getCert().getNotBefore());
retVal.setValidStartDate(startDate);
return retVal;
}
use of org.nhindirect.config.model.Certificate in project nhin-d by DirectProject.
the class DNSController method refreshModelFromService.
public void refreshModelFromService(Model model) {
// GET A RECORDS
Collection<DNSRecord> arecords = null;
arecords = getDnsRecords(DNSType.A.getValue());
final Collection<DNSEntryForm> aform = new ArrayList<DNSEntryForm>();
if (arecords != null) {
for (Iterator<DNSRecord> iter = arecords.iterator(); iter.hasNext(); ) {
final DNSRecord t = (DNSRecord) iter.next();
try {
final ARecord newrec = (ARecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
final DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getAddress());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
aform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsARecordResults", aform);
// GET A4 RECORDS
Collection<DNSRecord> a4records = null;
a4records = getDnsRecords(DNSType.AAAA.getValue());
final Collection<DNSEntryForm> a4form = new ArrayList<DNSEntryForm>();
if (a4records != null) {
for (Iterator<DNSRecord> iter = a4records.iterator(); iter.hasNext(); ) {
final DNSRecord t = (DNSRecord) iter.next();
try {
final AAAARecord newrec = (AAAARecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
final DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getAddress());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
a4form.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsA4RecordResults", a4form);
// GET CNAME RECORDS
Collection<DNSRecord> crecords = null;
crecords = getDnsRecords(DNSType.CNAME.getValue());
final Collection<DNSEntryForm> cform = new ArrayList<DNSEntryForm>();
if (crecords != null) {
for (Iterator<DNSRecord> iter = crecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
final CNAMERecord newrec = (CNAMERecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
final DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getTarget());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
cform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsCnameRecordResults", cform);
// GET MX RECORDS
Collection<DNSRecord> mxrecords = null;
mxrecords = getDnsRecords(DNSType.MX.getValue());
final Collection<DNSEntryForm> mxform = new ArrayList<DNSEntryForm>();
if (mxrecords != null) {
for (Iterator<DNSRecord> iter = mxrecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
final MXRecord newrec = (MXRecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
final DNSEntryForm tmp = new DNSEntryForm();
tmp.setPriority(newrec.getPriority());
tmp.setId(t.getId());
tmp.setDest("" + newrec.getTarget());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
mxform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsMxRecordResults", mxform);
// GET Cert RECORDS
Collection<DNSRecord> certrecords = null;
certrecords = getDnsRecords(DNSType.CERT.getValue());
// get the thumbprint and assign
// create a new collection
final Collection<SrvRecord> form = new ArrayList<SrvRecord>();
CertContainer cont;
if (certrecords != null) {
for (Iterator<DNSRecord> iter = certrecords.iterator(); iter.hasNext(); ) {
final DNSRecord t = (DNSRecord) iter.next();
final SrvRecord srv = new SrvRecord();
srv.setCreateTime(t.getCreateTime());
srv.setData(t.getData());
srv.setDclass(t.getDclass());
srv.setId(t.getId());
srv.setName(t.getName());
srv.setTtl(t.getTtl());
srv.setType(t.getType());
srv.setThumb("");
try {
final CERTRecord newrec = (CERTRecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
String thumb = "";
byte[] certData = newrec.getCert();
if (certData != null) {
// get the owner from the certificate information
// first transform into a certificate
cont = toCertContainer(certData);
if (cont != null && cont.getCert() != null) {
Certificate cert2 = new Certificate();
cert2.setData(certData);
thumb = getThumbPrint(cont.getCert());
srv.setThumb(thumb);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
form.add(srv);
}
}
model.addAttribute("dnsCertRecordResults", form);
// GET SRV RECORDS
Collection<DNSRecord> srvrecords = null;
srvrecords = getDnsRecords(DNSType.SRV.getValue());
// create a new collection
final Collection<SrvRecord> form2 = new ArrayList<SrvRecord>();
if (srvrecords != null) {
for (Iterator<DNSRecord> iter = srvrecords.iterator(); iter.hasNext(); ) {
final DNSRecord t = (DNSRecord) iter.next();
final SrvRecord srv = new SrvRecord();
try {
SRVRecord srv4 = (SRVRecord) SRVRecord.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
srv.setCreateTime(t.getCreateTime());
srv.setData(t.getData());
srv.setDclass(t.getDclass());
srv.setId(t.getId());
srv.setName(t.getName());
final String name = t.getName();
// parse the name to get service, protocol, priority , weight,
// port
int firstpos = name.indexOf("_");
if (firstpos == 0) {
// then this can be parsed as a srv record
// ("_"+SrvdnsForm.getService()+"._"+SrvdnsForm.getProtocol()+"._"+SrvdnsForm.getPriority()+"._"+SrvdnsForm.getWeight()+"._"+SrvdnsForm.getPort()+"._"+SrvdnsForm.getDest()+"."+SrvdnsForm.getName()
int secondpos = name.indexOf("._");
int thirdpos = name.indexOf(".", secondpos + 2);
// from first to second is service
final String service_ = name.substring(firstpos + 1, secondpos);
srv.setService(service_);
// from second to third is protocol
final String protocol_ = name.substring(secondpos + 2, thirdpos);
;
srv.setProtocol(protocol_);
int last2pos = name.indexOf(".", thirdpos);
final String name_ = name.substring(last2pos + 1, name.length());
srv.setName(name_);
}
srv.setTtl(t.getTtl());
srv.setType(t.getType());
srv.setPort(srv4.getPort());
srv.setWeight(srv4.getWeight());
srv.setPriority("" + srv4.getPriority());
srv.setTarget("" + srv4.getTarget().toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
form2.add(srv);
}
}
model.addAttribute("dnsSrvRecordResults", form2);
// GET SOA RECORDS
Collection<DNSRecord> soarecords = null;
soarecords = getDnsRecords(DNSType.SOA.getValue());
final Collection<DNSEntryForm> soaform = new ArrayList<DNSEntryForm>();
if (soarecords != null) {
for (Iterator<DNSRecord> iter = soarecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
final SOARecord newrec = (SOARecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
final DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setAdmin("" + newrec.getAdmin());
tmp.setExpire(newrec.getExpire());
tmp.setMinimum(newrec.getMinimum());
tmp.setRefresh(newrec.getRefresh());
tmp.setRetry(newrec.getRetry());
tmp.setSerial(newrec.getSerial());
tmp.setDest("" + newrec.getHost());
tmp.setDomain("" + newrec.getHost());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
soaform.add(tmp);
} catch (TextParseException e) {
e.printStackTrace();
}
}
}
model.addAttribute("dnsSOARecordResults", soaform);
// GET NS RECORDS
Collection<DNSRecord> nsrecords = null;
nsrecords = getDnsRecords(DNSType.NS.getValue());
final Collection<DNSEntryForm> nsform = new ArrayList<DNSEntryForm>();
if (nsrecords != null) {
for (Iterator<DNSRecord> iter = nsrecords.iterator(); iter.hasNext(); ) {
final DNSRecord t = (DNSRecord) iter.next();
try {
NSRecord newrec = (NSRecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getTarget());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
nsform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsNSRecordResults", nsform);
// *****************
model.addAttribute("NSdnsForm", new DNSEntryForm());
model.addAttribute("SoadnsForm", new DNSEntryForm());
model.addAttribute("AdnsForm", new DNSEntryForm());
model.addAttribute("AAdnsForm", new DNSEntryForm());
model.addAttribute("CdnsForm", new DNSEntryForm());
model.addAttribute("MXdnsForm", new DNSEntryForm());
model.addAttribute("CertdnsForm", new DNSEntryForm());
model.addAttribute("SrvdnsForm", new DNSEntryForm());
}
use of org.nhindirect.config.model.Certificate in project nhin-d by DirectProject.
the class MainController method refreshModelFromService.
public void refreshModelFromService(Model model) {
// GET A RECORDS
Collection<DNSRecord> arecords = null;
arecords = getDnsRecords(DNSType.A.getValue());
Collection<DNSEntryForm> aform = new ArrayList<DNSEntryForm>();
if (arecords != null) {
for (DNSRecord t : arecords) {
try {
ARecord newrec = (ARecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getAddress());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
aform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsARecordResults", aform);
// GET A4 RECORDS
Collection<DNSRecord> a4records = null;
a4records = getDnsRecords(DNSType.AAAA.getValue());
Collection<DNSEntryForm> a4form = new ArrayList<DNSEntryForm>();
if (a4records != null) {
for (Iterator<DNSRecord> iter = a4records.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
AAAARecord newrec = (AAAARecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getAddress());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
a4form.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsA4RecordResults", a4form);
// GET CNAME RECORDS
Collection<DNSRecord> crecords = null;
crecords = getDnsRecords(DNSType.CNAME.getValue());
Collection<DNSEntryForm> cform = new ArrayList<DNSEntryForm>();
if (crecords != null) {
for (Iterator<DNSRecord> iter = crecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
CNAMERecord newrec = (CNAMERecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getTarget());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
cform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsCnameRecordResults", cform);
// GET MX RECORDS
Collection<DNSRecord> mxrecords = null;
mxrecords = getDnsRecords(DNSType.MX.getValue());
Collection<DNSEntryForm> mxform = new ArrayList<DNSEntryForm>();
if (mxrecords != null) {
for (Iterator<DNSRecord> iter = mxrecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
MXRecord newrec = (MXRecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
DNSEntryForm tmp = new DNSEntryForm();
tmp.setPriority(newrec.getPriority());
tmp.setId(t.getId());
tmp.setDest("" + newrec.getTarget());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
mxform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsMxRecordResults", mxform);
// GET Cert RECORDS
Collection<DNSRecord> certrecords = null;
certrecords = getDnsRecords(DNSType.CERT.getValue());
// get the thumbprint and assign
// create a new collection
Collection<SrvRecord> form = new ArrayList<SrvRecord>();
CertContainer cont;
if (certrecords != null) {
for (Iterator<DNSRecord> iter = certrecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
SrvRecord srv = new SrvRecord();
srv.setCreateTime(t.getCreateTime());
srv.setData(t.getData());
srv.setDclass(t.getDclass());
srv.setId(t.getId());
srv.setName(t.getName());
srv.setTtl(t.getTtl());
srv.setType(t.getType());
srv.setThumb("");
try {
CERTRecord newrec = (CERTRecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
String thumb = "";
byte[] certData = newrec.getCert();
if (certData != null) {
// get the owner from the certificate information
// first transform into a certificate
cont = CertUtils.toCertContainer(certData);
if (cont != null && cont.getCert() != null) {
Certificate cert2 = new Certificate();
cert2.setData(certData);
thumb = getThumbPrint(cont.getCert());
srv.setThumb(thumb);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
form.add(srv);
}
}
model.addAttribute("dnsCertRecordResults", form);
// GET SRV RECORDS
Collection<DNSRecord> srvrecords = null;
srvrecords = getDnsRecords(DNSType.SRV.getValue());
// create a new collection
Collection<SrvRecord> form2 = new ArrayList<SrvRecord>();
if (srvrecords != null) {
for (Iterator<DNSRecord> iter = srvrecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
SrvRecord srv = new SrvRecord();
try {
SRVRecord srv4 = (SRVRecord) SRVRecord.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
srv.setCreateTime(t.getCreateTime());
srv.setData(t.getData());
srv.setDclass(t.getDclass());
srv.setId(t.getId());
srv.setName(t.getName());
String name = t.getName();
// parse the name to get service, protocol, priority , weight,
// port
int firstpos = name.indexOf("_");
if (firstpos == 0) {
// then this can be parsed as a srv record
// ("_"+SrvdnsForm.getService()+"._"+SrvdnsForm.getProtocol()+"._"+SrvdnsForm.getPriority()+"._"+SrvdnsForm.getWeight()+"._"+SrvdnsForm.getPort()+"._"+SrvdnsForm.getDest()+"."+SrvdnsForm.getName()
int secondpos = name.indexOf("._");
int thirdpos = name.indexOf(".", secondpos + 2);
// from first to second is service
String service_ = name.substring(firstpos + 1, secondpos);
srv.setService(service_);
// from second to third is protocol
String protocol_ = name.substring(secondpos + 2, thirdpos);
;
srv.setProtocol(protocol_);
int last2pos = name.indexOf(".", thirdpos);
String name_ = name.substring(last2pos + 1, name.length());
srv.setName(name_);
}
srv.setTtl(t.getTtl());
srv.setType(t.getType());
srv.setPort(srv4.getPort());
srv.setWeight(srv4.getWeight());
srv.setPriority("" + srv4.getPriority());
srv.setTarget("" + srv4.getTarget().toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
form2.add(srv);
}
}
model.addAttribute("dnsSrvRecordResults", form2);
// GET SOA RECORDS
Collection<DNSRecord> soarecords = null;
soarecords = getDnsRecords(DNSType.SOA.getValue());
Collection<DNSEntryForm> soaform = new ArrayList<DNSEntryForm>();
if (soarecords != null) {
for (Iterator<DNSRecord> iter = soarecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
SOARecord newrec = (SOARecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setAdmin("" + newrec.getAdmin());
tmp.setExpire(newrec.getExpire());
tmp.setMinimum(newrec.getMinimum());
tmp.setRefresh(newrec.getRefresh());
tmp.setRetry(newrec.getRetry());
tmp.setSerial(newrec.getSerial());
tmp.setDest("" + newrec.getHost());
tmp.setDomain("" + newrec.getHost());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
soaform.add(tmp);
} catch (TextParseException e) {
e.printStackTrace();
}
}
}
model.addAttribute("dnsSOARecordResults", soaform);
// GET NS RECORDS
Collection<DNSRecord> nsrecords = null;
nsrecords = getDnsRecords(DNSType.NS.getValue());
Collection<DNSEntryForm> nsform = new ArrayList<DNSEntryForm>();
if (nsrecords != null) {
for (Iterator<DNSRecord> iter = nsrecords.iterator(); iter.hasNext(); ) {
DNSRecord t = (DNSRecord) iter.next();
try {
NSRecord newrec = (NSRecord) Record.newRecord(Name.fromString(t.getName()), t.getType(), t.getDclass(), t.getTtl(), t.getData());
DNSEntryForm tmp = new DNSEntryForm();
tmp.setId(t.getId());
tmp.setDest("" + newrec.getTarget());
tmp.setTtl(newrec.getTTL());
tmp.setName("" + newrec.getName());
nsform.add(tmp);
} catch (TextParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("dnsNSRecordResults", nsform);
// *****************
model.addAttribute("NSdnsForm", new DNSEntryForm());
model.addAttribute("SoadnsForm", new DNSEntryForm());
model.addAttribute("AdnsForm", new DNSEntryForm());
model.addAttribute("AAdnsForm", new DNSEntryForm());
model.addAttribute("CdnsForm", new DNSEntryForm());
model.addAttribute("MXdnsForm", new DNSEntryForm());
model.addAttribute("CertdnsForm", new DNSEntryForm());
model.addAttribute("SrvdnsForm", new DNSEntryForm());
}
use of org.nhindirect.config.model.Certificate in project nhin-d by DirectProject.
the class CertificatesController method removeCertificates.
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/removecertifcates", method = RequestMethod.POST)
public ModelAndView removeCertificates(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute CertificateForm simpleForm, Model model, @RequestParam(value = "submitType") String actionPath) {
final ModelAndView mav = new ModelAndView();
if (log.isDebugEnabled())
log.debug("Enter domain/removecertificates");
if (simpleForm.getRemove() != null) {
if (log.isDebugEnabled())
log.debug("the list of checkboxes checked or not is: " + simpleForm.getRemove().toString());
}
if (certService != null && simpleForm != null && actionPath != null && (actionPath.equalsIgnoreCase("deletecertificate") || actionPath.equalsIgnoreCase("Remove Selected")) && simpleForm.getRemove() != null) {
int cnt = simpleForm.getRemove().size();
if (log.isDebugEnabled())
log.debug("removing certificates");
try {
// get list of certificates for this domain
final Collection<Certificate> certs = certService.getAllCertificates();
final ArrayList<Long> certtoberemovedlist = new ArrayList<Long>();
// now iterate over each one and remove the appropriate ones
for (int x = 0; x < cnt; x++) {
final String removeid = simpleForm.getRemove().get(x);
for (Certificate t : certs) {
//rest of the code block removed
if (t.getId() == Long.parseLong(removeid)) {
if (log.isDebugEnabled()) {
log.debug(" ");
log.debug("domain address id: " + t.getId());
log.debug(" ");
}
// create a collection of matching anchor ids
certtoberemovedlist.add(t.getId());
break;
}
}
}
// with the collection of anchor ids now remove them from the anchorService
if (log.isDebugEnabled())
log.debug(" Trying to remove certificates from database");
certService.deleteCertificatesByIds(certtoberemovedlist);
if (log.isDebugEnabled())
log.debug(" SUCCESS Trying to update certificates");
} catch (ServiceException e) {
if (log.isDebugEnabled())
log.error(e);
}
}
model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
// BEGIN: temporary code for mocking purposes
final CertificateForm cform = new CertificateForm();
cform.setId(0);
model.addAttribute("certificateForm", cform);
mav.setViewName("certificates");
// the Form's default button action
final String action = "Update";
model.addAttribute("action", action);
model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
mav.addObject("action", action);
Collection<Certificate> certlist = null;
try {
certlist = certService.getAllCertificates();
if (this.keyManager != null && this.keyManager instanceof MutableKeyStoreProtectionManager) {
final KeyStore keyStore = ((MutableKeyStoreProtectionManager) keyManager).getKS();
// the key store manager to see if they have private keys
for (Certificate cert : certlist) {
if (!cert.isPrivateKey()) {
try {
final X509Certificate checkCert = CertUtils.toX509Certificate(cert.getData());
final String alias = keyStore.getCertificateAlias(checkCert);
if (!StringUtils.isEmpty(alias)) {
// check if this entry has a private key associated with
// it
final PrivateKey privKey = (PrivateKey) keyStore.getKey(alias, "".toCharArray());
if (privKey != null)
cert.setPrivateKey(true);
}
} catch (Exception e) {
}
}
}
}
} catch (ServiceException e) {
e.printStackTrace();
}
model.addAttribute("certificatesResults", certlist);
// END: temporary code for mocking purposes
mav.addObject("privKeyTypeList", PrivateKeyType.getPrivKeyTypeList());
mav.addObject("statusList", EntityStatus.getEntityStatusList());
model.addAttribute("simpleForm", simpleForm);
final String strid = "" + simpleForm.getId();
if (log.isDebugEnabled())
log.debug(" the value of id of simpleform is: " + strid);
return mav;
}
Aggregations