Java Code Examples for org.bouncycastle.asn1.x509.KeyUsage#keyAgreement()

The following examples show how to use org.bouncycastle.asn1.x509.KeyUsage#keyAgreement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CertificateSignRequest.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
private Extension getKeyUsageExtension() throws IOException {
  int keyUsageFlag = KeyUsage.keyAgreement;
  if(digitalEncryption){
    keyUsageFlag |= KeyUsage.keyEncipherment | KeyUsage.dataEncipherment;
  }
  if(digitalSignature) {
    keyUsageFlag |= KeyUsage.digitalSignature;
  }

  if (ca) {
    keyUsageFlag |= KeyUsage.keyCertSign | KeyUsage.cRLSign;
  }
  KeyUsage keyUsage = new KeyUsage(keyUsageFlag);
  return new Extension(Extension.keyUsage, true,
      new DEROctetString(keyUsage));
}
 
Example 2
Source File: DKeyUsage.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
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 e) {
		DError.displayError(this, e);
		return;
	}

	closeDialog();
}
 
Example 3
Source File: DefaultProfile.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public KeyUsage getKeyUsage() {
  return new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment
      | KeyUsage.dataEncipherment | KeyUsage.keyAgreement);
}
 
Example 4
Source File: SM2X509CertMaker.java    From gmhelper with Apache License 2.0 3 votes vote down vote up
/**
 * 生成用户证书
 * 
 * @param csr CSR
 * @param extendedKeyUsages 扩展指数用途。
 * @return 新的证书
 * @throws Exception 如果错误发生
 */
public X509Certificate makeEndEntityCert(byte[] csr,
      KeyPurposeId[] extendedKeyUsages) 
        throws Exception {
    KeyUsage usage = new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyAgreement
                        | KeyUsage.dataEncipherment | KeyUsage.keyEncipherment);
    return makeCertificate(CertLevel.SubCA, null, csr, usage, extendedKeyUsages);
}