mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-20 21:43:18 +00:00
Merge pull request #372 from nsacyber/base64-decode-error
Base64 decode exception
This commit is contained in:
commit
8abffb54e2
@ -1,5 +1,6 @@
|
|||||||
package hirs.attestationca.portal.page.controllers;
|
package hirs.attestationca.portal.page.controllers;
|
||||||
|
|
||||||
|
import hirs.FilteredRecordsList;
|
||||||
import hirs.attestationca.portal.datatables.DataTableInput;
|
import hirs.attestationca.portal.datatables.DataTableInput;
|
||||||
import hirs.attestationca.portal.datatables.DataTableResponse;
|
import hirs.attestationca.portal.datatables.DataTableResponse;
|
||||||
import hirs.attestationca.portal.datatables.OrderedListQueryDataTableAdapter;
|
import hirs.attestationca.portal.datatables.OrderedListQueryDataTableAdapter;
|
||||||
@ -8,26 +9,6 @@ import hirs.attestationca.portal.page.PageController;
|
|||||||
import hirs.attestationca.portal.page.PageMessages;
|
import hirs.attestationca.portal.page.PageMessages;
|
||||||
import hirs.attestationca.portal.page.params.NoPageParams;
|
import hirs.attestationca.portal.page.params.NoPageParams;
|
||||||
import hirs.attestationca.portal.util.CertificateStringMapBuilder;
|
import hirs.attestationca.portal.util.CertificateStringMapBuilder;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.security.cert.CertificateEncodingException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import static org.apache.logging.log4j.LogManager.getLogger;
|
|
||||||
import org.hibernate.Criteria;
|
|
||||||
import org.hibernate.criterion.Restrictions;
|
|
||||||
import org.hibernate.sql.JoinType;
|
|
||||||
import hirs.FilteredRecordsList;
|
|
||||||
import hirs.data.persist.certificate.Certificate;
|
import hirs.data.persist.certificate.Certificate;
|
||||||
import hirs.data.persist.certificate.CertificateAuthorityCredential;
|
import hirs.data.persist.certificate.CertificateAuthorityCredential;
|
||||||
import hirs.data.persist.certificate.EndorsementCredential;
|
import hirs.data.persist.certificate.EndorsementCredential;
|
||||||
@ -38,17 +19,38 @@ import hirs.persist.CriteriaModifier;
|
|||||||
import hirs.persist.CrudManager;
|
import hirs.persist.CrudManager;
|
||||||
import hirs.persist.DBManagerException;
|
import hirs.persist.DBManagerException;
|
||||||
import hirs.persist.OrderedListQuerier;
|
import hirs.persist.OrderedListQuerier;
|
||||||
import java.util.List;
|
import org.apache.logging.log4j.Logger;
|
||||||
import java.util.stream.Collectors;
|
import org.bouncycastle.util.encoders.DecoderException;
|
||||||
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.hibernate.sql.JoinType;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
import org.springframework.web.servlet.view.RedirectView;
|
import org.springframework.web.servlet.view.RedirectView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.security.cert.CertificateEncodingException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.apache.logging.log4j.LogManager.getLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the Device page.
|
* Controller for the Device page.
|
||||||
*/
|
*/
|
||||||
@ -627,6 +629,12 @@ public class CertificateRequestPageController extends PageController<NoPageParam
|
|||||||
LOGGER.error(failMessage, e);
|
LOGGER.error(failMessage, e);
|
||||||
messages.addError(failMessage + e.getMessage());
|
messages.addError(failMessage + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
|
} catch (DecoderException dEx) {
|
||||||
|
final String failMessage = String.format(
|
||||||
|
"Failed to parse uploaded pem file (%s): ", fileName);
|
||||||
|
LOGGER.error(failMessage, dEx);
|
||||||
|
messages.addError(failMessage + dEx.getMessage());
|
||||||
|
return null;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
final String failMessage = String.format(
|
final String failMessage = String.format(
|
||||||
"Certificate format not recognized(%s): ", fileName);
|
"Certificate format not recognized(%s): ", fileName);
|
||||||
|
@ -10,6 +10,7 @@ import org.bouncycastle.openssl.PEMKeyPair;
|
|||||||
import org.bouncycastle.openssl.PEMParser;
|
import org.bouncycastle.openssl.PEMParser;
|
||||||
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
|
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
|
||||||
import org.bouncycastle.util.encoders.Base64;
|
import org.bouncycastle.util.encoders.Base64;
|
||||||
|
import org.bouncycastle.util.encoders.DecoderException;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
@ -154,6 +155,8 @@ public class CredentialParser {
|
|||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println("Unable to locate private key file: " + filename);
|
System.out.println("Unable to locate private key file: " + filename);
|
||||||
|
} catch (DecoderException e) {
|
||||||
|
System.out.println("Failed to parse uploaded pem file: " + e.getMessage());
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
System.out.println("Unable to instantiate KeyFactory with algorithm: " + algorithm);
|
System.out.println("Unable to instantiate KeyFactory with algorithm: " + algorithm);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user