fix array out of bounds in cert service

This commit is contained in:
Mengyi Zhou 2015-12-03 14:51:08 +08:00
parent 59dc5680d2
commit 30470c2f46

View file

@ -36,14 +36,9 @@ public class CertificateServiceImpl implements CertificateService {
domainValue = searchRange[0]; domainValue = searchRange[0];
value = certificateDao.findMaxByDomainAndState(domainValue, state, CertificateEntity.READSET_FULL); value = certificateDao.findMaxByDomainAndState(domainValue, state, CertificateEntity.READSET_FULL);
} else { } else {
List<CertificateDo> check = certificateDao.grossByDomainAndState(domains, state, CertificateEntity.READSET_FULL); List<CertificateDo> check = certificateDao.grossByDomainAndState(searchRange, state, CertificateEntity.READSET_FULL);
if (check.isEmpty()) if (check.isEmpty())
throw new ValidationException("Cannot find corresponding certificate."); throw new ValidationException("Cannot find corresponding certificate.");
Iterator<CertificateDo> iter = check.iterator();
while (iter.hasNext()) {
if (!searchRange[0].equals(iter.next().getDomain()))
iter.remove();
}
if (check.size() > 1) { if (check.size() > 1) {
throw new ValidationException("Multiple certificates found referring the domain list."); throw new ValidationException("Multiple certificates found referring the domain list.");
} }
@ -150,11 +145,12 @@ public class CertificateServiceImpl implements CertificateService {
return domains; return domains;
else { else {
Arrays.sort(domains); Arrays.sort(domains);
String[] values = new String[domains.length + 1]; // String[] values = new String[domains.length + 1];
String[] values = new String[1];
values[0] = Joiner.on("|").join(domains); values[0] = Joiner.on("|").join(domains);
for (int i = 1; i < values.length; i++) { // for (int i = 1; i < values.length; i++) {
values[i] = domains[i - 1]; // values[i] = domains[i - 1];
} // }
return values; return values;
} }
} }