本文整理匯總了Java中java.security.cert.X509CRLEntry.hasExtensions方法的典型用法代碼示例。如果您正苦於以下問題:Java X509CRLEntry.hasExtensions方法的具體用法?Java X509CRLEntry.hasExtensions怎麽用?Java X509CRLEntry.hasExtensions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.cert.X509CRLEntry
的用法示例。
在下文中一共展示了X509CRLEntry.hasExtensions方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: crlEntrySelection
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
private void crlEntrySelection() {
int row = jtRevokedCerts.getSelectedRow();
if (row != -1) {
BigInteger serialNumber = (BigInteger) jtRevokedCerts.getValueAt(row, 0);
Set<?> revokedCertsSet = crl.getRevokedCertificates();
X509CRLEntry x509CrlEntry = null;
for (Iterator<?> itr = revokedCertsSet.iterator(); itr.hasNext();) {
X509CRLEntry entry = (X509CRLEntry) itr.next();
if (serialNumber.equals(entry.getSerialNumber())) {
x509CrlEntry = entry;
break;
}
}
if (x509CrlEntry.hasExtensions()) {
jbCrlEntryExtensions.setEnabled(true);
return;
}
}
jbCrlEntryExtensions.setEnabled(false);
}
示例2: displayCrlEntryExtensions
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
private void displayCrlEntryExtensions() {
int row = jtRevokedCerts.getSelectedRow();
if (row != -1) {
BigInteger serialNumber = (BigInteger) jtRevokedCerts.getValueAt(row, 0);
Set<?> revokedCertsSet = crl.getRevokedCertificates();
X509CRLEntry x509CrlEntry = null;
for (Iterator<?> itr = revokedCertsSet.iterator(); itr.hasNext();) {
X509CRLEntry entry = (X509CRLEntry) itr.next();
if (serialNumber.equals(entry.getSerialNumber())) {
x509CrlEntry = entry;
break;
}
}
if (x509CrlEntry.hasExtensions()) {
DViewExtensions dViewExtensions = new DViewExtensions(this,
res.getString("DViewCrl.EntryExtensions.Title"), x509CrlEntry);
dViewExtensions.setLocationRelativeTo(this);
dViewExtensions.setVisible(true);
}
}
}
示例3: getReasonFromX509Entry
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
/**
* Get reason from the x509 entry.
* @param entry the entry
* @return reason or null
*/
private static Reason getReasonFromX509Entry(final X509CRLEntry entry) {
if (entry.hasExtensions()) {
try {
final int code = Integer.parseInt(
new String(entry.getExtensionValue(CRL_REASON_OID), "ASCII"));
if (code < Reason.values().length) {
return Reason.fromCode(code);
}
} catch (final Exception e) {
LOGGER.trace("An exception occurred when resolving extension value: {}", e.getMessage());
}
}
return null;
}
示例4: getReasonFromX509Entry
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
/**
* Get reason from the x509 entry.
* @param entry the entry
* @return reason or null
*/
private static Reason getReasonFromX509Entry(final X509CRLEntry entry) {
if (entry.hasExtensions()) {
try {
final int code = Integer.parseInt(
new String(entry.getExtensionValue(CRL_REASON_OID), "ASCII"));
if (code < Reason.values().length) {
return Reason.fromCode(code);
}
} catch (final Exception e) {
LOGGER.trace("An exception occurred when resolving extension value: [{}]", e.getMessage());
}
}
return null;
}
示例5: RevokedCertificateException
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
public RevokedCertificateException(final X509CRLEntry entry) {
this.revocationDate = entry.getRevocationDate();
this.serial = entry.getSerialNumber();
if (entry.hasExtensions()) {
try {
final int code = Integer.parseInt(
new String(entry.getExtensionValue(CRL_REASON_OID), "ASCII"));
if (code < Reason.values().length) {
this.reason = Reason.fromCode(code);
}
} catch (final Exception e) {
logger.trace("An exception occurred when resolving extension value: {}", e.getMessage());
}
}
}
示例6: crlEntrySelection
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
/**
* CRL entry selected or deselected. Enable/disable the "CRL Extensions" button accordingly (i.e. enable it if only
* one extension is selected and it has extensions.
*/
private void crlEntrySelection()
{
ListSelectionModel listSelectionModel = m_jtRevokedCerts.getSelectionModel();
if (!listSelectionModel.isSelectionEmpty()) // Entry must be selected
{
// Only one entry though
// TODO: probably no longer necessary?
if (listSelectionModel.getMinSelectionIndex() == listSelectionModel.getMaxSelectionIndex())
{
// Get serial number of entry
int iRow = listSelectionModel.getMinSelectionIndex();
BigInteger serialNumber = (BigInteger) m_jtRevokedCerts.getValueAt(iRow, 0);
// Find CRL entry using serial number
Set<? extends X509CRLEntry> revokedCertsSet = m_crl.getRevokedCertificates();
X509CRLEntry x509CrlEntry = null;
for (X509CRLEntry entry : revokedCertsSet)
{
if (serialNumber.equals(entry.getSerialNumber()))
{
x509CrlEntry = entry;
break;
}
}
if (x509CrlEntry != null && x509CrlEntry.hasExtensions())
{
m_jbCrlEntryExtensions.setEnabled(true);
return;
}
}
}
// Disable "CRL Extensions" button
m_jbCrlEntryExtensions.setEnabled(false);
}
示例7: crlEntryExtensionsPressed
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
/**
* CRL entry extensions button pressed or otherwise activated. Show the extensions of the selected CRL entry.
*/
private void crlEntryExtensionsPressed()
{
ListSelectionModel listSelectionModel = m_jtRevokedCerts.getSelectionModel();
if (!listSelectionModel.isSelectionEmpty()) // Entry must be selected
{
// Only one entry though
// TODO: probably no longer necessary?
if (listSelectionModel.getMinSelectionIndex() == listSelectionModel.getMaxSelectionIndex())
{
// Get serial number of entry
int iRow = listSelectionModel.getMinSelectionIndex();
BigInteger serialNumber = (BigInteger) m_jtRevokedCerts.getValueAt(iRow, 0);
// Find CRL entry using serial number
Set<? extends X509CRLEntry> revokedCertsSet = m_crl.getRevokedCertificates();
X509CRLEntry x509CrlEntry = null;
for (X509CRLEntry entry : revokedCertsSet)
{
if (serialNumber.equals(entry.getSerialNumber()))
{
x509CrlEntry = entry;
break;
}
}
if (x509CrlEntry != null && x509CrlEntry.hasExtensions())
{
DViewExtensions dViewExtensions =
new DViewExtensions(this, RB.getString("DViewCRL.EntryExtensions.Title"), true, x509CrlEntry);
dViewExtensions.setLocationRelativeTo(this);
SwingHelper.showAndWait(dViewExtensions);
}
}
}
}
示例8: checkCRLCreation1
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
public void checkCRLCreation1()
throws Exception
{
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", "BC");
X509V2CRLGenerator crlGen = new X509V2CRLGenerator();
Date now = new Date();
KeyPair pair = kpGen.generateKeyPair();
crlGen.setIssuerDN(new X500Principal("CN=Test CA"));
crlGen.setThisUpdate(now);
crlGen.setNextUpdate(new Date(now.getTime() + 100000));
crlGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
crlGen.addCRLEntry(BigInteger.ONE, now, CRLReason.privilegeWithdrawn);
crlGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(pair.getPublic()));
X509CRL crl = crlGen.generate(pair.getPrivate(), "BC");
if (!crl.getIssuerX500Principal().equals(new X500Principal("CN=Test CA")))
{
fail("failed CRL issuer test");
}
byte[] authExt = crl.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
if (authExt == null)
{
fail("failed to find CRL extension");
}
AuthorityKeyIdentifier authId = new AuthorityKeyIdentifierStructure(authExt);
X509CRLEntry entry = crl.getRevokedCertificate(BigInteger.ONE);
if (entry == null)
{
fail("failed to find CRL entry");
}
if (!entry.getSerialNumber().equals(BigInteger.ONE))
{
fail("CRL cert serial number does not match");
}
if (!entry.hasExtensions())
{
fail("CRL entry extension not found");
}
byte[] ext = entry.getExtensionValue(X509Extensions.ReasonCode.getId());
if (ext != null)
{
DEREnumerated reasonCode = (DEREnumerated)X509ExtensionUtil.fromExtensionValue(ext);
if (reasonCode.getValue().intValue() != CRLReason.privilegeWithdrawn)
{
fail("CRL entry reasonCode wrong");
}
}
else
{
fail("CRL entry reasonCode not found");
}
}
示例9: checkCRLCreation1
import java.security.cert.X509CRLEntry; //導入方法依賴的package包/類
public void checkCRLCreation1()
throws Exception
{
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", "BC");
X509V2CRLGenerator crlGen = new X509V2CRLGenerator();
Date now = new Date();
KeyPair pair = kpGen.generateKeyPair();
crlGen.setIssuerDN(new X509Principal("CN=Test CA"));
crlGen.setThisUpdate(now);
crlGen.setNextUpdate(new Date(now.getTime() + 100000));
crlGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
crlGen.addCRLEntry(BigInteger.ONE, now, CRLReason.privilegeWithdrawn);
crlGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(pair.getPublic()));
X509CRL crl = crlGen.generate(pair.getPrivate(), "BC");
if (!crl.getIssuerDN().equals(new X509Principal("CN=Test CA")))
{
fail("failed CRL issuer test");
}
byte[] authExt = crl.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
if (authExt == null)
{
fail("failed to find CRL extension");
}
AuthorityKeyIdentifier authId = new AuthorityKeyIdentifierStructure(authExt);
X509CRLEntry entry = crl.getRevokedCertificate(BigInteger.ONE);
if (entry == null)
{
fail("failed to find CRL entry");
}
if (!entry.getSerialNumber().equals(BigInteger.ONE))
{
fail("CRL cert serial number does not match");
}
if (!entry.hasExtensions())
{
fail("CRL entry extension not found");
}
byte[] ext = entry.getExtensionValue(X509Extensions.ReasonCode.getId());
if (ext != null)
{
DEREnumerated reasonCode = (DEREnumerated)X509ExtensionUtil.fromExtensionValue(ext);
if (reasonCode.getValue().intValue() != CRLReason.privilegeWithdrawn)
{
fail("CRL entry reasonCode wrong");
}
}
else
{
fail("CRL entry reasonCode not found");
}
}