當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyUsage.encipherOnly方法代碼示例

本文整理匯總了Java中org.bouncycastle.asn1.x509.KeyUsage.encipherOnly方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyUsage.encipherOnly方法的具體用法?Java KeyUsage.encipherOnly怎麽用?Java KeyUsage.encipherOnly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bouncycastle.asn1.x509.KeyUsage的用法示例。


在下文中一共展示了KeyUsage.encipherOnly方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFailingOnUnexpectedKeyUsageEncypherOnly

import org.bouncycastle.asn1.x509.KeyUsage; //導入方法依賴的package包/類
@Test
public void testFailingOnUnexpectedKeyUsageEncypherOnly() throws Exception {
	// setup
	KeyPair keyPair = PKITestUtils.generateKeyPair();
	DateTime notBefore = new DateTime();
	DateTime notAfter = notBefore.plusMonths(1);
	KeyUsage keyUsage = new KeyUsage(KeyUsage.encipherOnly);
	X509Certificate certificate = PKITestUtils
			.generateSelfSignedCertificate(keyPair, "CN=Test", notBefore,
					notAfter, true, 0, null, keyUsage);

	this.testedInstance.setEncipherOnlyFilter(false);

	// operate
	try {
		this.testedInstance.check(certificate);
		fail();
	} catch (TrustLinkerResultException e) {
		assertEquals(TrustLinkerResultReason.CONSTRAINT_VIOLATION,
				e.getReason());
	}
}
 
開發者ID:e-Contract,項目名稱:jtrust,代碼行數:23,代碼來源:KeyUsageCertificateConstraintTest.java

示例2: buildKeyUsage

import org.bouncycastle.asn1.x509.KeyUsage; //導入方法依賴的package包/類
private KeyUsage buildKeyUsage(CertificateGenerationRequestParameters keyUsageList) {
  if (keyUsageList.getKeyUsage() == null){
    return null;
  }
  int bitmask = 0;
  for (String keyUsage : keyUsageList.getKeyUsage()) {
    switch (keyUsage) {
      case DIGITAL_SIGNATURE:
        bitmask |= KeyUsage.digitalSignature;
        break;
      case NON_REPUDIATION:
        bitmask |= KeyUsage.nonRepudiation;
        break;
      case KEY_ENCIPHERMENT:
        bitmask |= KeyUsage.keyEncipherment;
        break;
      case DATA_ENCIPHERMENT:
        bitmask |= KeyUsage.dataEncipherment;
        break;
      case KEY_AGREEMENT:
        bitmask |= KeyUsage.keyAgreement;
        break;
      case KEY_CERT_SIGN:
        bitmask |= KeyUsage.keyCertSign;
        break;
      case CRL_SIGN:
        bitmask |= KeyUsage.cRLSign;
        break;
      case ENCIPHER_ONLY:
        bitmask |= KeyUsage.encipherOnly;
        break;
      case DECIPHER_ONLY:
        bitmask |= KeyUsage.decipherOnly;
        break;
      default:
        throw new ParameterizedValidationException("error.invalid_key_usage", keyUsage);
    }
  }
  return new KeyUsage(bitmask);
}
 
開發者ID:cloudfoundry-incubator,項目名稱:credhub,代碼行數:41,代碼來源:CertificateGenerationParameters.java

示例3: okPressed

import org.bouncycastle.asn1.x509.KeyUsage; //導入方法依賴的package包/類
private void okPressed() {
	if (!jcbDigitalSignature.isSelected() && !jcbNonRepudiation.isSelected() && !jcbKeyEncipherment.isSelected()
			&& !jcbDataEncipherment.isSelected() && !jcbKeyAgreement.isSelected()
			&& !jcbCertificateSigning.isSelected() && !jcbCrlSign.isSelected() && !jcbEncipherOnly.isSelected()
			&& !jcbDecipherOnly.isSelected()) {
		JOptionPane.showMessageDialog(this, res.getString("DKeyUsage.ValueReq.message"), getTitle(),
				JOptionPane.WARNING_MESSAGE);
		return;
	}

	int keyUsageIntValue = 0;
	keyUsageIntValue |= jcbDigitalSignature.isSelected() ? KeyUsage.digitalSignature : 0;
	keyUsageIntValue |= jcbNonRepudiation.isSelected() ? KeyUsage.nonRepudiation : 0;
	keyUsageIntValue |= jcbKeyEncipherment.isSelected() ? KeyUsage.keyEncipherment : 0;
	keyUsageIntValue |= jcbDataEncipherment.isSelected() ? KeyUsage.dataEncipherment : 0;
	keyUsageIntValue |= jcbKeyAgreement.isSelected() ? KeyUsage.keyAgreement : 0;
	keyUsageIntValue |= jcbCertificateSigning.isSelected() ? KeyUsage.keyCertSign : 0;
	keyUsageIntValue |= jcbCrlSign.isSelected() ? KeyUsage.cRLSign : 0;
	keyUsageIntValue |= jcbEncipherOnly.isSelected() ? KeyUsage.encipherOnly : 0;
	keyUsageIntValue |= jcbDecipherOnly.isSelected() ? KeyUsage.decipherOnly : 0;

	KeyUsage keyUsage = new KeyUsage(keyUsageIntValue);

	try {
		value = keyUsage.getEncoded(ASN1Encoding.DER);
	} catch (IOException ex) {
		DError dError = new DError(this, ex);
		dError.setLocationRelativeTo(this);
		dError.setVisible(true);
		return;
	}

	closeDialog();
}
 
開發者ID:kaikramer,項目名稱:keystore-explorer,代碼行數:35,代碼來源:DKeyUsage.java


注:本文中的org.bouncycastle.asn1.x509.KeyUsage.encipherOnly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。