Examples of RecoverResultType


Examples of org.apache.cxf.xkms.model.xkms.RecoverResultType

        }
    }

    @Override
    public RecoverResultType recover(RecoverRequestType request) {
        RecoverResultType response = XKMSResponseFactory.createResponse(request, new RecoverResultType());
        try {
            assertXKRSSAllowed();
            validateRequest(request);
            for (Register handler : keyRegisterHandlers) {
                if (handler.canProcess(request)) {
View Full Code Here

Examples of org.apache.cxf.xkms.model.xkms.RecoverResultType

    @Override
    public RecoverResultType recover(RecoverRequestType request) {
        try {
            assertXKRSSAllowed();
            validateRequest(request);
            RecoverResultType response = XKMSResponseFactory.createResponse(request, new RecoverResultType());
            try {
                for (Register handler : keyRegisterHandlers) {
                    if (handler.canProcess(request)) {
                        return handler.recover(request, response);
                    }
                }
                throw new UnsupportedOperationException("Service was unable to handle your request");
            } catch (Exception e) {
                LOG.log(Level.SEVERE, "Error during recover: " + e.getMessage(), e);
                return ExceptionMapper.toResponse(e, response);
            }
        } catch (Exception e) {
            return ExceptionMapper.toResponse(e, XKMSResponseFactory.createResponse(request, new RecoverResultType()));
        }
    }
View Full Code Here

Examples of org.w3._2002._03.xkms_.RecoverResultType

            keyBindingType.setId(keyBindingId);
            recoverRequestType.setRecoverKeyBinding(keyBindingType)
           
          
           
            RecoverResultType recoverResultType = getXKMSInvoker().recover(recoverRequestType, clientCert, privateKey, password,  keyBindingId);

           
            if(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS) &&
               recoverResultType.getResultMinor() == null){
           
                if(recoverResultType.getKeyBinding().size() >0){
                  KeyBindingType keyBinding = recoverResultType.getKeyBinding().get(0);                 
                  List certs = getCertsFromKeyBinding(keyBinding);
                   
                  X509Certificate userCert = getUserCert(certs);                 
                  certs.remove(userCert);
                 
                  if(recoverResultType.getPrivateKey() != null){
                    PrivateKey serverKey = XKMSUtil.getPrivateKeyFromEncryptedXML(recoverResultType.getPrivateKey(), password);
                    createKeyStore(userCert, certs, serverKey,password,encoding,outputPath);
                  }else{
                  getPrintStream().println("Error: Response didn't contain any private key");                     
                    System.exit(-1); // NOPMD, this is not a JEE app
                  }
View Full Code Here

Examples of org.w3._2002._03.xkms_.RecoverResultType

 
  /**
   * Returns a register response
   */
  public RecoverResultType getResponse(boolean requestVerifies){
    RecoverResultType result = xkmsFactory.createRecoverResultType();   
    super.populateResponse(result, requestVerifies);   
    RecoverRequestType req = (RecoverRequestType) this.req;
   

    if(resultMajor == null){    
      if(!checkValidRespondWithRequest(req.getRespondWith(),false)){
        resultMajor = XKMSConstants.RESULTMAJOR_SENDER;
        resultMinor = XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED;
      }

      if(resultMajor == null){        
        if(resultMajor == null){
          X509Certificate cert = (X509Certificate) getPublicKeyInfo(req, false);         
         
          UserDataVO userData = findUserData(cert);
          if(userData != null){
            String password = ""
            boolean encryptedPassword = isPasswordEncrypted(req);
            if(encryptedPassword){
              password = getEncryptedPassword(requestDoc, userData.getPassword());
            }else{
              password = getClearPassword(req, userData.getPassword());
            }

            if(password != null ){
              X509Certificate newCert = registerReissueOrRecover(true,false, result, userData,password,  cert.getPublicKey(), null);
              if(newCert != null){
                KeyBindingAbstractType keyBinding = getResponseValues(req.getRecoverKeyBinding(), newCert, false, true);
                result.getKeyBinding().add((KeyBindingType) keyBinding);
              }
            }
          }

        }
View Full Code Here

Examples of org.w3._2002._03.xkms_.RecoverResultType

        notBoundAuthenticationType.setProtocol("NOTUSED");
        notBoundAuthenticationType.setValue("RerecoverPassword".getBytes());
        authenticationType.setNotBoundAuthentication(notBoundAuthenticationType);
        recoverRequestType.setAuthentication(authenticationType);

        RecoverResultType recoverResultType = xKMSInvoker.recover(recoverRequestType, null, null, null, keyBindingType.getId());

        assertTrue(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS));
        assertTrue(recoverResultType.getResultMinor() == null);

        assertTrue(recoverResultType.getKeyBinding().size() == 1);
        keyBindingType = recoverResultType.getKeyBinding().get(0);
        assertTrue(keyBindingType.getStatus().getValidReason().size() == 4);

        JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyBindingType.getKeyInfo().getContent().get(0);
        assertTrue(jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().size() == 2);
        Iterator<Object> iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();

        while (iter2.hasNext()) {
            JAXBElement next = (JAXBElement) iter2.next();
            assertTrue(next.getName().getLocalPart().equals("X509Certificate"));
            byte[] encoded = (byte[]) next.getValue();
            Certificate nextCert = CertTools.getCertfromByteArray(encoded);

            if (CertTools.getSubjectDN(nextCert).equals(CertTools.stringToBCDNString(dn2))) {
                cert2 = nextCert;

            }
        }

        assertTrue(recoverResultType.getPrivateKey() != null);
        PrivateKey privateKey = XKMSUtil.getPrivateKeyFromEncryptedXML(recoverResultType.getPrivateKey(), "RerecoverPassword");

        X509Certificate testCert = CertTools.genSelfCert("CN=sdf", 12, null, privateKey, cert2.getPublicKey(), "SHA1WithRSA", false);
        testCert.verify(cert2.getPublicKey());

    }
View Full Code Here

Examples of org.w3._2002._03.xkms_.RecoverResultType

        notBoundAuthenticationType.setProtocol("NOTUSED");
        notBoundAuthenticationType.setValue("Wrong".getBytes());
        authenticationType.setNotBoundAuthentication(notBoundAuthenticationType);
        recoverRequestType.setAuthentication(authenticationType);

        RecoverResultType recoverResultType = xKMSInvoker.recover(recoverRequestType, null, null, null, keyBindingType.getId());

        assertTrue(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SENDER));
        assertTrue(recoverResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_NOAUTHENTICATION));

    }
View Full Code Here

Examples of org.w3._2002._03.xkms_.RecoverResultType

        notBoundAuthenticationType.setProtocol("NOTUSED");
        notBoundAuthenticationType.setValue("RerecoverPassword".getBytes());
        authenticationType.setNotBoundAuthentication(notBoundAuthenticationType);
        recoverRequestType.setAuthentication(authenticationType);

        RecoverResultType recoverResultType = xKMSInvoker.recover(recoverRequestType, null, null, null, keyBindingType.getId());

        assertTrue(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SENDER));
        assertTrue(recoverResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_REFUSED));

    }
View Full Code Here

Examples of org.w3._2002._03.xkms_.RecoverResultType

        notBoundAuthenticationType.setProtocol("NOTUSED");
        notBoundAuthenticationType.setValue("RerecoverPassword".getBytes());
        authenticationType.setNotBoundAuthentication(notBoundAuthenticationType);
        recoverRequestType.setAuthentication(authenticationType);

        RecoverResultType recoverResultType = xKMSInvoker.recover(recoverRequestType, null, null, null, keyBindingType.getId());

        assertTrue(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SENDER));
        assertTrue(recoverResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_NOMATCH));

    }
View Full Code Here

Examples of org.w3._2002._03.xkms_.RecoverResultType

        notBoundAuthenticationType.setProtocol("NOTUSED");
        notBoundAuthenticationType.setValue("RerecoverPassword".getBytes());
        authenticationType.setNotBoundAuthentication(notBoundAuthenticationType);
        recoverRequestType.setAuthentication(authenticationType);

        RecoverResultType recoverResultType = xKMSInvoker.recover(recoverRequestType, null, null, null, keyBindingType.getId());

        assertTrue(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SENDER));
        assertTrue(recoverResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_REFUSED));

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.