Package org.ejbca.core.model.ca.catoken

Examples of org.ejbca.core.model.ca.catoken.CATokenAuthenticationFailedException


            throw new WaitingForApprovalException(msg);
        }
        if (caid >= 0 && caid <= CAInfo.SPECIALCAIDBORDER) {
          String msg = intres.getLocalizedMessage("caadmin.erroractivatetoken", Integer.valueOf(caid));
          logSession.log(admin, caid, LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_CAEDITED, msg);
          throw new CATokenAuthenticationFailedException(msg);
        }
        CAData cadata = CAData.findById(entityManager, Integer.valueOf(caid));
        if (cadata == null) {
          String msg = intres.getLocalizedMessage("caadmin.errorcanotfound", Integer.valueOf(caid));
          logSession.log(admin, caid, LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_CAEDITED, msg);
          throw new EJBException(msg);
        }
        boolean cATokenDisconnected = false;
        try {
          if ((cadata.getCA().getCAToken().getCATokenInfo()).getCATokenStatus() == ICAToken.STATUS_OFFLINE) {
            cATokenDisconnected = true;
          }
        } catch (IllegalKeyStoreException e) {
          String msg = intres.getLocalizedMessage("caadmin.errorreadingtoken", Integer.valueOf(caid));
          log.error(msg, e);
        } catch (UnsupportedEncodingException e) {
          String msg = intres.getLocalizedMessage("caadmin.errorreadingtoken", Integer.valueOf(caid));
          log.error(msg, e);
        }
        if (cadata.getStatus() == SecConst.CA_OFFLINE || cATokenDisconnected) {
          try {
            cadata.getCA().getCAToken().activate(authorizationcode);
            // If the CA was off-line, this is activation of the CA, if
            // only the token was disconnected we only connect the token
            // If CA is waiting for certificate response we can not
            // change this status just by activating the token.
            if (cadata.getStatus() != SecConst.CA_WAITING_CERTIFICATE_RESPONSE) {
              cadata.setStatus(SecConst.CA_ACTIVE);
            }
            // Invalidate CA cache to refresh information
            CACacheManager.instance().removeCA(cadata.getCaId().intValue());
            String msg = intres.getLocalizedMessage("caadmin.catokenactivated", cadata.getName());
            logSession.log(admin, caid, LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_INFO_CAEDITED, msg);
          } catch (CATokenAuthenticationFailedException e) {
            String msg = intres.getLocalizedMessage("caadmin.badcaactivationcode", cadata.getName());
            logSession.log(admin, caid, LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_CAACTIVATIONCODE, msg);
            throw e;
          } catch (IllegalKeyStoreException e) {
            throw new EJBException(e);
          } catch (UnsupportedEncodingException e) {
            throw new EJBException(e);
          }
        } else {
          String msg = intres.getLocalizedMessage("caadmin.errornotoffline", cadata.getName());
          logSession.log(admin, caid, LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_CAEDITED, msg);
          throw new CATokenAuthenticationFailedException(msg);
        }
    }
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ca.catoken.CATokenAuthenticationFailedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.