当前位置: 首页>>代码示例>>Java>>正文


Java DigiDocException类代码示例

本文整理汇总了Java中ee.sk.digidoc.DigiDocException的典型用法代码示例。如果您正苦于以下问题:Java DigiDocException类的具体用法?Java DigiDocException怎么用?Java DigiDocException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DigiDocException类属于ee.sk.digidoc包,在下文中一共展示了DigiDocException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeDataFile

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
private void removeDataFile(File file) {
  logger.info("Removing data file: " + file.getName());
  int index = -1;
  ArrayList ddocDataFiles = ddoc.getDataFiles();
  for (int i = 0; i < ddocDataFiles.size(); i++) {
    ee.sk.digidoc.DataFile dataFile = (ee.sk.digidoc.DataFile) ddocDataFiles.get(i);
    if (dataFile.getFileName().equalsIgnoreCase(file.getName())) index = i;
  }
  if (index == -1) {
    DigiDoc4JException exception = new DigiDoc4JException("File not found");
    logger.error(exception.toString());
    throw exception;
  }

  try {
    ddoc.removeDataFile(index);
  } catch (DigiDocException e) {
    logger.error(e.getMessage());
    throw new DigiDoc4JException(e.getNestedException());
  }
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:22,代码来源:DDocFacade.java

示例2: signRaw

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
public Signature signRaw(byte[] rawSignature) {
  logger.info("Finalizing DDoc signature");
  try {
    ddocSignature.setSignatureValue(rawSignature);
    DDocSignature signature = new DDocSignature(ddocSignature);
    if (signatureProfile == SignatureProfile.LT_TM) {
      ddocSignature.getConfirmation();
    }
    signature.setIndexInArray(getSignatureIndexInArray());
    logger.info("Signing DDoc successfully completed");
    return signature;
  } catch (DigiDocException e) {
    logger.error(e.getMessage());
    throw new DigiDoc4JException(e.getNestedException());
  }
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:17,代码来源:DDocFacade.java

示例3: generateReport

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
private void generateReport(DigiDocException exception, boolean isError) {
  Element childElement;
  String warningOrError;
  String message = exception.getMessage();
  int code = exception.getCode();
  if(!isError){
    warningOrError = "warning";
  }else{
    DigiDoc4JException digiDoc4JException = new DigiDoc4JException(code, message);
    errors.add(digiDoc4JException);
    warningOrError = "error";
  }
  logger.debug("Validation " + warningOrError + "."+ " Code: " + code + ", message: " + message);
  childElement = report.createElement(warningOrError);
  childElement.setAttribute("Code", Integer.toString(code));
  childElement.setAttribute("Message", message);
  rootElement.appendChild(childElement);
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:19,代码来源:ValidationResultForDDoc.java

示例4: testReport

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
@Test
public void testReport() throws IOException, SAXException {
  ArrayList<DigiDocException> exceptions = new ArrayList<DigiDocException>();
  exceptions.add(new DigiDocException(DigiDocException.ERR_UNSUPPORTED, "test", new Throwable("exception1")));
  exceptions.add(new DigiDocException(DigiDocException.ERR_CALCULATE_DIGEST, "test2", new Throwable("exception2")));

  exceptions.add(new DigiDocException(DigiDocException.ERR_OLD_VER, "test", new Throwable("exception1")));
  exceptions.add(new DigiDocException(DigiDocException.WARN_WEAK_DIGEST, "test2", new Throwable("exception2")));

  ValidationResultForDDoc result = new ValidationResultForDDoc(exceptions);
  assertXMLEqual("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" +
          "<!--DDoc verification result-->" +
          "<root>" +
          "<error Code=\"15\" Message=\"15test; nested exception is: &#10;&#9;java.lang.Throwable: exception1\"/>" +
          "<error Code=\"54\" Message=\"54test2; nested exception is: &#10;&#9;java.lang.Throwable: " +
          "exception2\"/><error " +
          "Code=\"177\" Message=\"177test; nested exception is: &#10;&#9;java.lang.Throwable: " +
          "exception1\"/><error " +
          "Code=\"129\" Message=\"129test2; nested exception is: &#10;&#9;java.lang.Throwable: exception2\"/></root>",
      result.getReport());
  System.out.println();
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:23,代码来源:ValidationResultForDDocTest.java

示例5: removeDataFileThrowsException

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
@Test(expected = DigiDoc4JException.class)
public void removeDataFileThrowsException() throws Exception {
  SignedDoc ddoc = mock(SignedDoc.class);

  ArrayList<ee.sk.digidoc.DataFile> mockedDataFiles = new ArrayList<>();
  DataFile dataFile = mock(DataFile.class);
  when(dataFile.getFileName()).thenReturn("test.txt");
  mockedDataFiles.add(dataFile);
  doReturn(mockedDataFiles).when(ddoc).getDataFiles();

  doThrow(new DigiDocException(100, "testException", new Throwable("test Exception"))).
      when(ddoc).removeDataFile(anyInt());

  DDocFacade container = new DDocFacade(ddoc);
  container.addDataFile("testFiles/helper-files/test.txt", "text/plain");
  container.removeDataFile("test.txt");
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:18,代码来源:DDocFacadeTest.java

示例6: findAlias

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
private String findAlias(KeyStore store) throws DigiDocException {
 	try {
  	java.util.Enumeration en = store.aliases();
  	// find the key alias
while(en.hasMoreElements()) {
  		String  n = (String)en.nextElement();
  		if (store.isKeyEntry(n)) {
      		return n;
  		}
}
return null;
     } catch(Exception ex) {
         DigiDocException.handleException(ex, DigiDocException.ERR_NOT_FAC_INIT);
         return null;
     }
 }
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:17,代码来源:DigidocOCSPSignatureContainer.java

示例7: finalizeSignature

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
public void finalizeSignature(IdSignSession signSession, String signatureValue, String userId, String fileId, Credential credential) throws IOException {
		
//		SignatureContainerDescription description = signatureContainerDescriptionRepository.get(userId);
		SignatureContainerDescription description = signatureContainerDescriptionRepository.get("master");
		
		DigidocOCSPSignatureContainer digidocOCSPSignatureContainer = new DigidocOCSPSignatureContainer(
				signatureContainerDescriptionRepository.getContent(description), 
				description);
		
		digiDocService.finalizeSignature(
				signSession.getSignedDoc(), 
				signSession.getId(), 
				signatureValue, 
				digidocOCSPSignatureContainer);
		
		try {
			File file = gDriveService.getFile(fileId, credential);
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			signSession.getSignedDoc().writeToStream(out);
			gDriveService.updateContent(file, out.toByteArray(), credential);
		} catch (DigiDocException e) {
			throw new RuntimeException(e);
		}
	}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:25,代码来源:ContainerService.java

示例8: parseSignedDoc

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
/**
 * @throws IllegalArgumentException if content is not DDoc
 * @param content
 * @return
 * @throws IOException 
 */
public ValidatedSignedDoc parseSignedDoc(String fileName,  String id,  InputStream content) throws IOException  {
	
	ArrayList<DigiDocException> warnings = new ArrayList<DigiDocException>();

	try {
		DigiDocFactory factory = ConfigManager.instance().getDigiDocFactory();
		SignedDoc doc = factory.readSignedDocFromStreamOfType(content, factory.isBdocExtension(fileName), warnings);
		
		if (doc == null) {
			throw new IllegalArgumentException("content is not a ddoc/bdoc: " + warnings);
		}
		
		return new ValidatedSignedDoc(doc, warnings);
		
	} catch (DigiDocException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:25,代码来源:DigiDocService.java

示例9: requestMobileIdSignature

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
public SignSession requestMobileIdSignature(
		SignedDoc doc, String personalId, String phoneNumber) {
	
	try {
		StringBuffer challenge = new StringBuffer();
		String sessionId = mobileIdService.startSigningSession(
				doc, 
				personalId,
				phoneNumber,
				"ENG", 
				"Drive DigiDoc",
				"", 
				"", 
				"", 
				"", 
				"EE",
				challenge);
		
		return new SignSession(sessionId, challenge.toString());
	} catch (DigiDocException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:24,代码来源:DigiDocService.java

示例10: createContainer

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
public SignedDoc createContainer(String fileName, String mimeType, InputStream content) {

		try {
			SignedDoc signedDoc = DigiDocGenFactory.createSignedDoc(
					SignedDoc.FORMAT_DIGIDOC_XML, null, null);
			
			DataFile dataFile = new DataFile(
					signedDoc.getNewDataFileId(), 
					DataFile.CONTENT_EMBEDDED_BASE64, 
					fileName, 
					mimeType, 
					signedDoc);
			
			byte[] contentBytes = IOUtils.toByteArray(content);
			dataFile.setBase64Body(contentBytes);
			dataFile.calcHashes(new ByteArrayInputStream(contentBytes));//hack to make DigiDoc save file content
			signedDoc.addDataFile(dataFile);
			return signedDoc;

		} catch (DigiDocException | IOException e) {
			throw new RuntimeException(e);
		}
	}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:24,代码来源:DigiDocService.java

示例11: isBdocFile

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
/**
 * Checks if this stream could be a bdoc input stream
 * @param is input stream, must support mark() and reset() operations!
 * @return true if bdoc
 */
private boolean isBdocFile(InputStream is)
	throws DigiDocException
{
	try {
		if(is.markSupported())
		  is.mark(10);
		byte[] tdata = new byte[10];
		int n = is.read(tdata);
		if(is.markSupported())
			is.reset();
		if(n >= 2 && tdata[0] == (byte)'P' && tdata[1] == (byte)'K')
				return true; // probably a zip file
		if(n >= 5 && tdata[0] == (byte)'<' && tdata[1] == (byte)'?' &&
				tdata[2] == (byte)'x' && tdata[3] == (byte)'m' &&
				tdata[4] == (byte)'l')
				return false; // an xml file - probably ddoc format?
	} catch(Exception ex) {
		m_logger.error("Error determining file type: " + ex);
	}
	return false;
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:27,代码来源:DigiDocFactoryWithoutCaches.java

示例12: verifyRespStatus

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
/**
 * Helper method to verify response status
 * @param resp OCSP response
 * @throws DigiDocException if the response status is not ok
 */
private void verifyRespStatus(OCSPResp resp) 
	throws DigiDocException 
{
	int status = resp.getStatus();
		switch (status) {
			case OCSPRespStatus.INTERNAL_ERROR: m_logger.error("An internal error occured in the OCSP Server!"); break;
			case OCSPRespStatus.MALFORMED_REQUEST: m_logger.error("Your request did not fit the RFC 2560 syntax!"); break;
			case OCSPRespStatus.SIGREQUIRED: m_logger.error("Your request was not signed!"); break;
			case OCSPRespStatus.TRY_LATER: m_logger.error("The server was too busy to answer you!"); break;
			case OCSPRespStatus.UNAUTHORIZED: m_logger.error("The server could not authenticate you!"); break;
			case OCSPRespStatus.SUCCESSFUL: break;
			default: m_logger.error("Unknown OCSPResponse status code! "+status);
		}
	if(resp == null || resp.getStatus() != OCSPRespStatus.SUCCESSFUL)
	    throw new DigiDocException(DigiDocException.ERR_OCSP_UNSUCCESSFULL,
	        "OCSP response unsuccessfull! ", null);
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:23,代码来源:FlexibleBouncyCastleNotaryFactory.java

示例13: init

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
/**l
 * initializes the implementation class
 */
public void init()
    throws DigiDocException 
{
    try {
        String proxyHost = ConfigManager.instance().
            getProperty("DIGIDOC_PROXY_HOST");
        String proxyPort = ConfigManager.instance().
            getProperty("DIGIDOC_PROXY_PORT");
        if(proxyHost != null && proxyPort != null) {
            System.setProperty("http.proxyHost", proxyHost);
            System.setProperty("http.proxyPort", proxyPort);
        }
        String sigFlag = ConfigManager.instance().getProperty("SIGN_OCSP_REQUESTS");
    	m_bSignRequests = (sigFlag != null && sigFlag.equals("true"));
    	// only need this if we must sign the requests
        Provider prv = (Provider)Class.forName(ConfigManager.
            instance().getProperty("DIGIDOC_SECURITY_PROVIDER")).newInstance();
        //System.out.println("Provider");
        //prv.list(System.out);
        Security.addProvider(prv);
                 
    } catch(Exception ex) {
        DigiDocException.handleException(ex, DigiDocException.ERR_NOT_FAC_INIT);
    }
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:29,代码来源:FlexibleBouncyCastleNotaryFactory.java

示例14: isWarning

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
/**
 * Checks is DigiDoc4JException predefined as warning for DDOC
 *
 * @param documentFormat format SignedDoc
 * @param exception      error to check
 * @return is this exception warning for DDOC utility program
 * @see SignedDoc
 */
public static boolean isWarning(String documentFormat, DigiDoc4JException exception) {
  int errorCode = exception.getErrorCode();
  return (errorCode == DigiDocException.ERR_DF_INV_HASH_GOOD_ALT_HASH
      || errorCode == DigiDocException.ERR_OLD_VER
      || errorCode == DigiDocException.ERR_TEST_SIGNATURE
      || errorCode == DigiDocException.WARN_WEAK_DIGEST
      || (errorCode == DigiDocException.ERR_ISSUER_XMLNS && !documentFormat.equals(SignedDoc.FORMAT_SK_XML)));
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:17,代码来源:DigiDoc4J.java

示例15: isWarning

import ee.sk.digidoc.DigiDocException; //导入依赖的package包/类
private boolean isWarning(String documentFormat, DigiDoc4JException exception) {
  int errorCode = exception.getErrorCode();
  return (errorCode == DigiDocException.ERR_DF_INV_HASH_GOOD_ALT_HASH
      || errorCode == DigiDocException.ERR_OLD_VER
      || errorCode == DigiDocException.ERR_TEST_SIGNATURE
      || errorCode == DigiDocException.WARN_WEAK_DIGEST
      || (errorCode == DigiDocException.ERR_ISSUER_XMLNS && !documentFormat.equals(SignedDoc.FORMAT_SK_XML)));
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:9,代码来源:ContainerVerifier.java


注:本文中的ee.sk.digidoc.DigiDocException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。