Package org.ejbca.core.protocol.ws.objects

Examples of org.ejbca.core.protocol.ws.objects.HardTokenDataWS


   * Method used to convert a HardToken data to a WS version
   * @param data
   * @throws EjbcaException
   */
  protected HardTokenDataWS convertHardTokenToWS(HardTokenData data, Collection<java.security.cert.Certificate> certificates, boolean includePUK) throws EjbcaException {
    HardTokenDataWS retval = new HardTokenDataWS();
    retval.setHardTokenSN(data.getTokenSN());
    retval.setLabel(data.getHardToken().getLabel());
    retval.setCopyOfSN(data.getCopyOf());
    ArrayList<String> copies = new ArrayList<String>();
    if(data.getCopies() != null){
      Iterator<String> iter = data.getCopies().iterator();
      while(iter.hasNext()){
        copies.add(iter.next());

      }
    }
    retval.setCopies(copies);
    try{
      retval.setModifyTime(dateToXMKGregorianCalendar(data.getModifyTime()));
      retval.setCreateTime(dateToXMKGregorianCalendar(data.getCreateTime()));
      retval.setEncKeyKeyRecoverable(false);

      Iterator<java.security.cert.Certificate> iter = certificates.iterator();
      while(iter.hasNext()){
        retval.getCertificates().add(new Certificate(iter.next()));
      }
    }catch(DatatypeConfigurationException e){
      log.error("EJBCA WebService error, getHardToken: ",e);
      throw new EjbcaException(ErrorCode.INTERNAL_ERROR, e.getMessage());
    }catch(CertificateEncodingException e){
      log.error("EJBCA WebService error, getHardToken: ",e);
      throw new EjbcaException(ErrorCode.INTERNAL_ERROR, e.getMessage());
    }


    if(data.getHardToken() instanceof SwedishEIDHardToken){
      SwedishEIDHardToken ht = (SwedishEIDHardToken) data.getHardToken();
      if(includePUK){
        retval.getPinDatas().add(new PinDataWS(HardTokenConstants.PINTYPE_SIGNATURE,ht.getInitialSignaturePIN(),ht.getSignaturePUK()));
        retval.getPinDatas().add(new PinDataWS(HardTokenConstants.PINTYPE_BASIC,ht.getInitialAuthEncPIN(),ht.getAuthEncPUK()));
      }
      retval.setTokenType(HardTokenConstants.TOKENTYPE_SWEDISHEID);
      return retval;
    }
    if(data.getHardToken() instanceof EnhancedEIDHardToken){
      EnhancedEIDHardToken ht = (EnhancedEIDHardToken) data.getHardToken();
      retval.setEncKeyKeyRecoverable(ht.getEncKeyRecoverable());
      if(includePUK){
        retval.getPinDatas().add(new PinDataWS(HardTokenConstants.PINTYPE_SIGNATURE,ht.getInitialSignaturePIN(),ht.getSignaturePUK()));
        retval.getPinDatas().add(new PinDataWS(HardTokenConstants.PINTYPE_BASIC,ht.getInitialAuthPIN(),ht.getAuthPUK()));
      }
      retval.setTokenType(HardTokenConstants.TOKENTYPE_ENHANCEDEID);
      return retval;
    }
    if(data.getHardToken() instanceof TurkishEIDHardToken){
      TurkishEIDHardToken ht = (TurkishEIDHardToken) data.getHardToken();
      if(includePUK){
        retval.getPinDatas().add(new PinDataWS(HardTokenConstants.PINTYPE_BASIC,ht.getInitialPIN(),ht.getPUK()));
      }
      retval.setTokenType(HardTokenConstants.TOKENTYPE_TURKISHEID);
      return retval;
    }
    throw new EjbcaException(ErrorCode.INTERNAL_ERROR,
                             "Error: only SwedishEIDHardToken, EnhancedEIDHardToken, TurkishEIDHardToken supported.");
  }
View Full Code Here


      if(revokePreviousCards){
        List<HardTokenDataWS> htd = getHardTokenDatas(admin,userDataWS.getUsername(), false, true, logger);
        Iterator<HardTokenDataWS> htdIter = htd.iterator();

        while(htdIter.hasNext()) {
          HardTokenDataWS toRevoke = htdIter.next();
          try{
              if(hardTokenDataWS.getLabel().equals(HardTokenConstants.LABEL_TEMPORARYCARD) && toRevoke.getLabel() != null && !toRevoke.getLabel().equals(HardTokenConstants.LABEL_TEMPORARYCARD)){

                // Token have extended key usage MS Logon, don't revoke it
                Iterator<java.security.cert.Certificate> revokeCerts = hardTokenSession.findCertificatesInHardToken(admin, toRevoke.getHardTokenSN()).iterator();

                while(revokeCerts.hasNext()){
                  X509Certificate next = (X509Certificate) revokeCerts.next();              
                  try{
                    if(WebServiceConfiguration.getSuspendAllCertificates() || next.getExtendedKeyUsage() == null || !next.getExtendedKeyUsage().contains(KeyPurposeId.id_kp_smartcardlogon.getId())){
                      userAdminSession.revokeCert(admin,next.getSerialNumber(), CertTools.getIssuerDN(next), RevokedCertInfo.REVOCATION_REASON_CERTIFICATEHOLD);
                    }
                  }catch(CertificateParsingException e){
                    log.error(e);
                  } catch (FinderException e) {
                    log.error(e);
                 
                }
           

            }else{
              revokeToken(admin, toRevoke.getHardTokenSN(), RevokedCertInfo.REVOCATION_REASON_UNSPECIFIED, logger);
            }
          }catch(AlreadyRevokedException e){
            // Do nothing
          }
        }
View Full Code Here

  /**
   * @see org.ejbca.core.protocol.ws.common.IEjbcaWS#getHardTokenData(java.lang.String)
   */
  public HardTokenDataWS getHardTokenData(String hardTokenSN, boolean viewPUKData, boolean onlyValidCertificates)
    throws CADoesntExistsException, AuthorizationDeniedException, HardTokenDoesntExistsException, NotFoundException, ApprovalRequestExpiredException, WaitingForApprovalException, ApprovalRequestExecutionException, EjbcaException {
    HardTokenDataWS retval = null;
    EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession, certificateProfileSession, certificateStoreSession, endEntityProfileSession, hardTokenSession, userAdminSession);
    Admin admin = ejbhelper.getAdmin(true);
    ApprovalRequest ar = null;
    boolean isApprovedStep0 = false;
    boolean isRejectedStep0 = false;
View Full Code Here

TOP

Related Classes of org.ejbca.core.protocol.ws.objects.HardTokenDataWS

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.