org.bouncycastle.asn1.x509.AccessDescription Java Examples

The following examples show how to use org.bouncycastle.asn1.x509.AccessDescription. 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: BasicCertificate.java    From signer with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
    * Returns the AuthorityInfoAccess extension value on list format.<br>
    * Otherwise, returns <b>list empty</b>.<br>
    * @return List Authority info access list
    */
public List<String> getAuthorityInfoAccess() {
	List<String> address = new ArrayList<String>();
	try {
		byte[] authorityInfoAccess = certificate.getExtensionValue(Extension.authorityInfoAccess.getId());
		if (authorityInfoAccess != null && authorityInfoAccess.length > 0) {
			AuthorityInformationAccess infoAccess = AuthorityInformationAccess.getInstance(
					JcaX509ExtensionUtils.parseExtensionValue(authorityInfoAccess));
			for (AccessDescription desc : infoAccess.getAccessDescriptions())
				if (desc.getAccessLocation().getTagNo() == GeneralName.uniformResourceIdentifier)
					address.add(((DERIA5String) desc.getAccessLocation().getName()).getString());
		}
		return address;
	} catch (Exception error) {
		logger.info(error.getMessage());
		return address;
	}
}
 
Example #2
Source File: Actions.java    From xipki with Apache License 2.0 6 votes vote down vote up
public static List<String> extractOcspUrls(AuthorityInformationAccess aia)
    throws CertificateEncodingException {
  AccessDescription[] accessDescriptions = aia.getAccessDescriptions();
  List<AccessDescription> ocspAccessDescriptions = new LinkedList<>();
  for (AccessDescription accessDescription : accessDescriptions) {
    if (accessDescription.getAccessMethod().equals(X509ObjectIdentifiers.id_ad_ocsp)) {
      ocspAccessDescriptions.add(accessDescription);
    }
  }

  final int n = ocspAccessDescriptions.size();
  List<String> ocspUris = new ArrayList<>(n);
  for (int i = 0; i < n; i++) {
    GeneralName accessLocation = ocspAccessDescriptions.get(i).getAccessLocation();
    if (accessLocation.getTagNo() == GeneralName.uniformResourceIdentifier) {
      String ocspUri = ((ASN1String) accessLocation.getName()).getString();
      ocspUris.add(ocspUri);
    }
  }

  return ocspUris;
}
 
Example #3
Source File: X509Util.java    From xipki with Apache License 2.0 6 votes vote down vote up
private static AccessDescription createAccessDescription(String accessMethodAndLocation)
    throws BadInputException {
  Args.notNull(accessMethodAndLocation, "accessMethodAndLocation");
  ConfPairs pairs;
  try {
    pairs = new ConfPairs(accessMethodAndLocation);
  } catch (IllegalArgumentException ex) {
    throw new BadInputException("invalid accessMethodAndLocation " + accessMethodAndLocation);
  }

  Set<String> oids = pairs.names();
  if (oids == null || oids.size() != 1) {
    throw new BadInputException("invalid accessMethodAndLocation " + accessMethodAndLocation);
  }

  String accessMethodS = oids.iterator().next();
  String taggedValue = pairs.value(accessMethodS);
  ASN1ObjectIdentifier accessMethod = new ASN1ObjectIdentifier(accessMethodS);

  GeneralName location = createGeneralName(taggedValue);
  return new AccessDescription(accessMethod, location);
}
 
Example #4
Source File: DAccessDescriptionChooser.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private void okPressed() {
	ASN1ObjectIdentifier accessMethod = joiAccessMethod.getObjectId();

	if (accessMethod == null) {
		JOptionPane.showMessageDialog(this,
				res.getString("DAccessDescriptionChooser.AccessMethodValueReq.message"), getTitle(),
				JOptionPane.WARNING_MESSAGE);
		return;
	}

	GeneralName accessLocation = jgnAccessLocation.getGeneralName();

	if (accessLocation == null) {
		JOptionPane.showMessageDialog(this,
				res.getString("DAccessDescriptionChooser.AccessLocationValueReq.message"), getTitle(),
				JOptionPane.WARNING_MESSAGE);
		return;
	}

	accessDescription = new AccessDescription(accessMethod, accessLocation);

	closeDialog();
}
 
Example #5
Source File: DAuthorityInformationAccess.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private void okPressed() {
	List<AccessDescription> accessDescriptions = jadAccessDescriptions.getAccessDescriptions();

	if (accessDescriptions.isEmpty()) {
		JOptionPane.showMessageDialog(this, res.getString("DAuthorityInformationAccess.ValueReq.message"),
				getTitle(), JOptionPane.WARNING_MESSAGE);
		return;
	}

	ASN1EncodableVector vec = new ASN1EncodableVector();
	for (AccessDescription accessDescription : accessDescriptions) {
		vec.add(accessDescription);
	}
	AuthorityInformationAccess authorityInformationAccess =
			AuthorityInformationAccess.getInstance(new DERSequence(vec));

	try {
		value = authorityInformationAccess.getEncoded(ASN1Encoding.DER);
	} catch (IOException e) {
		DError.displayError(this, e);
		return;
	}

	closeDialog();
}
 
Example #6
Source File: DSubjectInformationAccess.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private void okPressed() {
	List<AccessDescription> accessDescriptions = jadAccessDescriptions.getAccessDescriptions();

	if (accessDescriptions.size() == 0) {
		JOptionPane.showMessageDialog(this, res.getString("DSubjectInformationAccess.ValueReq.message"),
				getTitle(), JOptionPane.WARNING_MESSAGE);
		return;
	}

	SubjectInfoAccess subjectInformationAccess = new SubjectInfoAccess(accessDescriptions);

	try {
		value = subjectInformationAccess.getEncoded(ASN1Encoding.DER);
	} catch (IOException e) {
		DError.displayError(this, e);
		return;
	}

	closeDialog();
}
 
Example #7
Source File: AccessDescriptionsTableCellRend.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the rendered cell.
 *
 * @param jtAccessDescriptions
 *            The JTable
 * @param value
 *            The value to assign to the cell
 * @param isSelected
 *            True if cell is selected
 * @param row
 *            The row of the cell to render
 * @param col
 *            The column of the cell to render
 * @param hasFocus
 *            If true, render cell appropriately
 * @return The renderered cell
 */
@Override
public Component getTableCellRendererComponent(JTable jtAccessDescriptions, Object value, boolean isSelected,
		boolean hasFocus, int row, int col) {
	JLabel cell = (JLabel) super.getTableCellRendererComponent(jtAccessDescriptions, value, isSelected, hasFocus,
			row, col);

	AccessDescription accessDescription = (AccessDescription) value;

	if (col == 0) {
		cell.setText(accessDescription.getAccessMethod().getId());
	} else {
		cell.setText(GeneralNameUtil.safeToString(accessDescription.getAccessLocation(), false));
	}

	cell.setHorizontalAlignment(LEFT);
	cell.setBorder(new EmptyBorder(0, 5, 0, 5));

	return cell;
}
 
Example #8
Source File: AccessDescriptionsTableModel.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Load the AccessDescriptionsTableModel with access descriptions.
 *
 * @param accessDescriptions
 *            The access descriptions
 */
public void load(List<AccessDescription> accessDescriptions) {
	AccessDescription[] accessDescriptionsArray = accessDescriptions
			.toArray(new AccessDescription[accessDescriptions.size()]);
	Arrays.sort(accessDescriptionsArray, new AccessDescriptionMethodComparator());

	data = new Object[accessDescriptionsArray.length][2];

	int i = 0;
	for (AccessDescription accessDescription : accessDescriptionsArray) {
		data[i][0] = accessDescription;
		data[i][1] = accessDescription;
		i++;
	}

	fireTableDataChanged();
}
 
Example #9
Source File: JAccessDescriptions.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private void addPressed() {
	Container container = getTopLevelAncestor();

	DAccessDescriptionChooser dAccessDescriptionChooser = null;

	if (container instanceof JDialog) {
		dAccessDescriptionChooser = new DAccessDescriptionChooser((JDialog) container, title, null);
	} else {
		dAccessDescriptionChooser = new DAccessDescriptionChooser((JFrame) container, title, null);
	}
	dAccessDescriptionChooser.setLocationRelativeTo(container);
	dAccessDescriptionChooser.setVisible(true);

	AccessDescription newAccessDescription = dAccessDescriptionChooser.getAccessDescription();

	if (newAccessDescription == null) {
		return;
	}

	accessDescriptions.add(newAccessDescription);

	populate();
	selectAccessDescriptionInTable(newAccessDescription);
}
 
Example #10
Source File: IdentifiedCertprofile.java    From xipki with Apache License 2.0 5 votes vote down vote up
private static ASN1Sequence createSubjectInfoAccess(
    Map<ASN1ObjectIdentifier, Extension> requestedExtensions,
    Map<ASN1ObjectIdentifier, Set<GeneralNameMode>> modes) throws BadCertTemplateException {
  if (modes == null) {
    return null;
  }

  Extension extn = requestedExtensions.get(Extension.subjectInfoAccess);
  if (extn == null) {
    return null;
  }

  ASN1Encodable extValue = extn.getParsedValue();
  if (extValue == null) {
    return null;
  }

  ASN1Sequence reqSeq = ASN1Sequence.getInstance(extValue);
  int size = reqSeq.size();

  ASN1EncodableVector vec = new ASN1EncodableVector();
  for (int i = 0; i < size; i++) {
    AccessDescription ad = AccessDescription.getInstance(reqSeq.getObjectAt(i));
    ASN1ObjectIdentifier accessMethod = ad.getAccessMethod();
    Set<GeneralNameMode> generalNameModes = modes.get(accessMethod);

    if (generalNameModes == null) {
      throw new BadCertTemplateException("subjectInfoAccess.accessMethod "
          + accessMethod.getId() + " is not allowed");
    }

    GeneralName accessLocation = BaseCertprofile.createGeneralName(
        ad.getAccessLocation(), generalNameModes);
    vec.add(new AccessDescription(accessMethod, accessLocation));
  } // end for

  return vec.size() > 0 ? new DERSequence(vec) : null;
}
 
Example #11
Source File: X509Ext.java    From portecle with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get Authority Information Access (1.3.6.1.5.5.7.1.1) or Subject Information Access (1.3.6.1.5.5.7.1.11) extension
 * value as a string.
 *
 * @param bValue The octet string value
 * @return Extension value as a string
 * @throws IOException If an I/O problem occurs
 */
private String getInformationAccessStringValue(byte[] bValue)
    throws IOException
{
	AuthorityInformationAccess access = AuthorityInformationAccess.getInstance(bValue);

	StringBuilder sb = new StringBuilder();

	AccessDescription[] accDescs = access.getAccessDescriptions();
	for (AccessDescription accDesc : accDescs)
	{
		if (sb.length() != 0)
		{
			sb.append("<br>");
		}

		String accOid = accDesc.getAccessMethod().toString();
		String accMeth = getRes(accOid, "UnrecognisedAccessMethod");

		LinkClass linkClass = LinkClass.BROWSER;
		if (accOid.equals(AccessDescription.id_ad_ocsp.getId()))
		{
			linkClass = LinkClass.OCSP;
		}
		else if (accOid.equals(AccessDescription.id_ad_caIssuers.getId()))
		{
			linkClass = LinkClass.CERTIFICATE;
		}

		sb.append("<ul><li>");
		sb.append(MessageFormat.format(accMeth, accOid));
		sb.append(": <ul><li>");
		sb.append(getGeneralNameString(accDesc.getAccessLocation(), linkClass));
		sb.append("</li></ul></li></ul>");
	}

	return sb.toString();
}
 
Example #12
Source File: OCSPCertificateVerifier.java    From oxAuth with MIT License 5 votes vote down vote up
@SuppressWarnings({ "deprecation", "resource" })
private String getOCSPUrl(X509Certificate certificate) throws IOException {
	ASN1Primitive obj;
	try {
		obj = getExtensionValue(certificate, Extension.authorityInfoAccess.getId());
	} catch (IOException ex) {
		log.error("Failed to get OCSP URL", ex);
		return null;
	}

	if (obj == null) {
		return null;
	}

	AuthorityInformationAccess authorityInformationAccess = AuthorityInformationAccess.getInstance(obj);

	AccessDescription[] accessDescriptions = authorityInformationAccess.getAccessDescriptions();
	for (AccessDescription accessDescription : accessDescriptions) {
		boolean correctAccessMethod = accessDescription.getAccessMethod().equals(X509ObjectIdentifiers.ocspAccessMethod);
		if (!correctAccessMethod) {
			continue;
		}

		GeneralName name = accessDescription.getAccessLocation();
		if (name.getTagNo() != GeneralName.uniformResourceIdentifier) {
			continue;
		}

		DERIA5String derStr = DERIA5String.getInstance((ASN1TaggedObject) name.toASN1Primitive(), false);
		return derStr.getString();
	}

	return null;

}
 
Example #13
Source File: DSSASN1Utils.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static List<String> getAccessLocations(final CertificateToken certificate, ASN1ObjectIdentifier aiaType) {
	List<String> locationsUrls = new ArrayList<>();
	final byte[] authInfoAccessExtensionValue = certificate.getCertificate().getExtensionValue(Extension.authorityInfoAccess.getId());
	if (null == authInfoAccessExtensionValue) {
		return locationsUrls;
	}

	try {
		ASN1Sequence asn1Sequence = DSSASN1Utils.getAsn1SequenceFromDerOctetString(authInfoAccessExtensionValue);
		if (asn1Sequence == null || asn1Sequence.size() == 0) {
			LOG.warn("Empty ASN1Sequence for AuthorityInformationAccess");
			return locationsUrls;
		}
		AuthorityInformationAccess authorityInformationAccess = AuthorityInformationAccess.getInstance(asn1Sequence);
		AccessDescription[] accessDescriptions = authorityInformationAccess.getAccessDescriptions();
		for (AccessDescription accessDescription : accessDescriptions) {
			if (aiaType.equals(accessDescription.getAccessMethod())) {
				GeneralName gn = accessDescription.getAccessLocation();
				String location = parseGn(gn);
				if (location != null) {
					locationsUrls.add(location);
				}
			}
		}
	} catch (Exception e) {
		LOG.error("Unable to parse authorityInfoAccess", e);
	}
	return locationsUrls;
}
 
Example #14
Source File: X509Utils.java    From acme-client with Apache License 2.0 5 votes vote down vote up
public static String getCACertificateURL(X509Certificate certificate) throws IOException {
	byte[] bOctets = ((ASN1OctetString) ASN1Primitive.fromByteArray(certificate.getExtensionValue(Extension.authorityInfoAccess.getId()))).getOctets();
	AuthorityInformationAccess access = AuthorityInformationAccess.getInstance(ASN1Sequence.fromByteArray(bOctets));
	for (AccessDescription ad:access.getAccessDescriptions()){
		if (ad.getAccessMethod().equals(X509ObjectIdentifiers.id_ad_caIssuers)){
			return ad.getAccessLocation().getName().toString();
		}
	}
	return null;
}
 
Example #15
Source File: JAccessDescriptions.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private void selectAccessDescriptionInTable(AccessDescription accessDescription) {
	for (int i = 0; i < jtAccessDescriptions.getRowCount(); i++) {
		if (accessDescription.equals(jtAccessDescriptions.getValueAt(i, 0))) {
			jtAccessDescriptions.changeSelection(i, 0, false, false);
			return;
		}
	}
}
 
Example #16
Source File: JAccessDescriptions.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private void editSelectedAccessDescription() {
	int selectedRow = jtAccessDescriptions.getSelectedRow();

	if (selectedRow != -1) {
		AccessDescription accessDescription = (AccessDescription) jtAccessDescriptions.getValueAt(selectedRow, 0);

		Container container = getTopLevelAncestor();

		DAccessDescriptionChooser dAccessDescriptionChooser = null;

		if (container instanceof JDialog) {
			dAccessDescriptionChooser = new DAccessDescriptionChooser((JDialog) container, title, accessDescription);
		} else {
			dAccessDescriptionChooser = new DAccessDescriptionChooser((JFrame) container, title, accessDescription);
		}
		dAccessDescriptionChooser.setLocationRelativeTo(container);
		dAccessDescriptionChooser.setVisible(true);

		AccessDescription newAccessDescription = dAccessDescriptionChooser.getAccessDescription();

		if (newAccessDescription == null) {
			return;
		}

		accessDescriptions.remove(accessDescription);
		accessDescriptions.add(newAccessDescription);

		populate();
		selectAccessDescriptionInTable(newAccessDescription);
	}
}
 
Example #17
Source File: SubjectInfoAccess.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private SubjectInfoAccess(ASN1Sequence seq) {
	accessDescriptions = new Vector<>();

	for (int i = 0; i != seq.size(); i++) {
		accessDescriptions.add(AccessDescription.getInstance(seq.getObjectAt(i)));
	}
}
 
Example #18
Source File: JAccessDescriptions.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private void removeSelectedAccessDescription() {
	int selectedRow = jtAccessDescriptions.getSelectedRow();

	if (selectedRow != -1) {
		AccessDescription accessDescription = (AccessDescription) jtAccessDescriptions.getValueAt(selectedRow, 0);

		accessDescriptions.remove(accessDescription);

		reloadAccessDescriptionsTable();
		selectFirstAccessDescriptionInTable();
		updateButtonControls();
	}
}
 
Example #19
Source File: DAuthorityInformationAccess.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	AuthorityInformationAccess authorityInformationAccess = AuthorityInformationAccess.getInstance(value);

	List<AccessDescription> accessDescriptionList =
			new ArrayList<>(Arrays.asList(authorityInformationAccess.getAccessDescriptions()));

	jadAccessDescriptions.setAccessDescriptions(accessDescriptionList);
}
 
Example #20
Source File: SubjectInfoAccess.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ASN1Primitive toASN1Primitive() {
	ASN1EncodableVector vec = new ASN1EncodableVector();
	Iterator<AccessDescription> it = accessDescriptions.iterator();
	while (it.hasNext()) {
		vec.add(it.next().toASN1Primitive());
	}

	return new DERSequence(vec);
}
 
Example #21
Source File: SubjectInfoAccess.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new instance with the given list of accessDescription.
 */
public SubjectInfoAccess(List<AccessDescription> accessDescriptions) {
	this.accessDescriptions = accessDescriptions;
}
 
Example #22
Source File: ExtensionsChecker.java    From xipki with Apache License 2.0 4 votes vote down vote up
private static void checkAia(StringBuilder failureMsg, AuthorityInformationAccess aia,
    ASN1ObjectIdentifier accessMethod, Set<String> expectedUris) {
  String typeDesc;
  if (X509ObjectIdentifiers.id_ad_ocsp.equals(accessMethod)) {
    typeDesc = "OCSP";
  } else if (X509ObjectIdentifiers.id_ad_caIssuers.equals(accessMethod)) {
    typeDesc = "caIssuer";
  } else {
    typeDesc = accessMethod.getId();
  }

  List<AccessDescription> isAccessDescriptions = new LinkedList<>();
  for (AccessDescription accessDescription : aia.getAccessDescriptions()) {
    if (accessMethod.equals(accessDescription.getAccessMethod())) {
      isAccessDescriptions.add(accessDescription);
    }
  }

  int size = isAccessDescriptions.size();
  if (size != expectedUris.size()) {
    addViolation(failureMsg, "number of AIA " + typeDesc + " URIs", size, expectedUris.size());
    return;
  }

  Set<String> isUris = new HashSet<>();
  for (int i = 0; i < size; i++) {
    GeneralName isAccessLocation = isAccessDescriptions.get(i).getAccessLocation();
    if (isAccessLocation.getTagNo() != GeneralName.uniformResourceIdentifier) {
      addViolation(failureMsg, "tag of accessLocation of AIA ",
          isAccessLocation.getTagNo(), GeneralName.uniformResourceIdentifier);
    } else {
      String isOcspUri = ((ASN1String) isAccessLocation.getName()).getString();
      isUris.add(isOcspUri);
    }
  }

  Set<String> diffs = strInBnotInA(expectedUris, isUris);
  if (CollectionUtil.isNotEmpty(diffs)) {
    failureMsg.append(typeDesc).append(" URIs ").append(diffs);
    failureMsg.append(" are present but not expected; ");
  }

  diffs = strInBnotInA(isUris, expectedUris);
  if (CollectionUtil.isNotEmpty(diffs)) {
    failureMsg.append(typeDesc).append(" URIs ").append(diffs);
    failureMsg.append(" are absent but are required; ");
  }
}
 
Example #23
Source File: ExtensionsChecker.java    From xipki with Apache License 2.0 4 votes vote down vote up
private void checkExtnSubjectInfoAccess(StringBuilder failureMsg, byte[] extensionValue,
    Extensions requestedExtns, ExtensionControl extControl) {
  Map<ASN1ObjectIdentifier, Set<GeneralNameMode>> conf =
      certprofile.getSubjectInfoAccessModes();
  if (conf == null) {
    failureMsg.append("extension is present but not expected; ");
    return;
  }

  ASN1Encodable requestExtValue = null;
  if (requestedExtns != null) {
    requestExtValue = requestedExtns.getExtensionParsedValue(Extension.subjectInfoAccess);
  }
  if (requestExtValue == null) {
    failureMsg.append("extension is present but not expected; ");
    return;
  }

  ASN1Sequence requestSeq = ASN1Sequence.getInstance(requestExtValue);
  ASN1Sequence certSeq = ASN1Sequence.getInstance(extensionValue);

  int size = requestSeq.size();

  if (certSeq.size() != size) {
    addViolation(failureMsg, "size of GeneralNames", certSeq.size(), size);
    return;
  }

  for (int i = 0; i < size; i++) {
    AccessDescription ad = AccessDescription.getInstance(requestSeq.getObjectAt(i));
    ASN1ObjectIdentifier accessMethod = ad.getAccessMethod();
    Set<GeneralNameMode> generalNameModes = conf.get(accessMethod);

    if (generalNameModes == null) {
      failureMsg.append("accessMethod in requestedExtension ")
        .append(accessMethod.getId()).append(" is not allowed; ");
      continue;
    }

    AccessDescription certAccessDesc = AccessDescription.getInstance(
        certSeq.getObjectAt(i));
    ASN1ObjectIdentifier certAccessMethod = certAccessDesc.getAccessMethod();

    boolean bo = (accessMethod == null) ? (certAccessMethod == null)
        : accessMethod.equals(certAccessMethod);

    if (!bo) {
      addViolation(failureMsg, "accessMethod",
          (certAccessMethod == null) ? "null" : certAccessMethod.getId(),
          (accessMethod == null) ? "null" : accessMethod.getId());
      continue;
    }

    GeneralName accessLocation;
    try {
      accessLocation = createGeneralName(ad.getAccessLocation(), generalNameModes);
    } catch (BadCertTemplateException ex) {
      failureMsg.append("invalid requestedExtension: ").append(ex.getMessage()).append("; ");
      continue;
    }

    GeneralName certAccessLocation = certAccessDesc.getAccessLocation();
    if (!certAccessLocation.equals(accessLocation)) {
      failureMsg.append("accessLocation does not match the requested one; ");
    }
  }
}
 
Example #24
Source File: AccessDescriptionsTableModel.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int compare(AccessDescription description1, AccessDescription description2) {
	return objectIdComparator.compare(description1.getAccessMethod(), description2.getAccessMethod());
}
 
Example #25
Source File: AccessDescriptionsTableModel.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int compare(AccessDescription description1, AccessDescription description2) {
	return GeneralNameUtil.safeToString(description1.getAccessLocation(), false).compareToIgnoreCase(
			GeneralNameUtil.safeToString(description2.getAccessLocation(), false));
}
 
Example #26
Source File: SubjectInfoAccess.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns a list with the AccessDescription objects.
 */
public List<AccessDescription> getAccessDescriptionList() {
	return accessDescriptions;
}
 
Example #27
Source File: DAccessDescriptionChooser.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void populate(AccessDescription accessDescription) {
	if (accessDescription != null) {
		joiAccessMethod.setObjectId(accessDescription.getAccessMethod());
		jgnAccessLocation.setGeneralName(accessDescription.getAccessLocation());
	}
}
 
Example #28
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getSubjectInformationAccessStringValue(byte[] value) throws IOException {
	// @formatter:off

	/*
	 * SubjectInfoAccessSyntax ::= ASN1Sequence SIZE (1..MAX) OF
	 * AccessDescription
	 *
	 * AccessDescription ::= ASN1Sequence { accessMethod OBJECT IDENTIFIER,
	 * accessLocation GeneralName }
	 */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	SubjectInfoAccess subjectInfoAccess = SubjectInfoAccess.getInstance(value);

	int accessDesc = 0;

	for (AccessDescription accessDescription : subjectInfoAccess.getAccessDescriptionList()) {
		accessDesc++;

		// Convert OID to access method
		ASN1ObjectIdentifier accessMethod = accessDescription.getAccessMethod();

		AccessMethodType accessMethodType = AccessMethodType.resolveOid(accessMethod.getId());

		String accessMethodStr = null;

		if (accessMethodType != null) {
			accessMethodStr = accessMethodType.friendly();
		} else {
			// Unrecognised Access Method OID
			accessMethodStr = ObjectIdUtil.toString(accessMethod);
		}

		GeneralName accessLocation = accessDescription.getAccessLocation();

		String accessLocationStr = GeneralNameUtil.toString(accessLocation);

		sb.append(MessageFormat.format(res.getString("SubjectInformationAccess"), accessDesc));
		sb.append(NEWLINE);
		sb.append(INDENT);
		sb.append(MessageFormat.format(res.getString("AccessMethod"), accessMethodStr));
		sb.append(NEWLINE);
		sb.append(INDENT);
		sb.append(res.getString("AccessLocation"));
		sb.append(NEWLINE);
		sb.append(INDENT);
		sb.append(INDENT);
		sb.append(accessLocationStr);
		sb.append(NEWLINE);
	}

	return sb.toString();
}
 
Example #29
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getAuthorityInformationAccessStringValue(byte[] value) throws IOException {
	// @formatter:off

	/*
	 * AuthorityInfoAccessSyntax ::= ASN1Sequence SIZE (1..MAX) OF
	 * AccessDescription
	 *
	 * AccessDescription ::= ASN1Sequence { accessMethod OBJECT IDENTIFIER,
	 * accessLocation GeneralName }
	 */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	AuthorityInformationAccess authorityInfoAccess = AuthorityInformationAccess.getInstance(value);

	int accessDesc = 0;

	for (AccessDescription accessDescription : authorityInfoAccess.getAccessDescriptions()) {
		accessDesc++;

		// Convert OID to access method
		ASN1ObjectIdentifier accessMethod = accessDescription.getAccessMethod();

		AccessMethodType accessMethodType = AccessMethodType.resolveOid(accessMethod.getId());

		String accessMethodStr = null;

		if (accessMethodType != null) {
			accessMethodStr = accessMethodType.friendly();
		} else {
			// Unrecognised Access Method OID
			accessMethodStr = ObjectIdUtil.toString(accessMethod);
		}

		GeneralName accessLocation = accessDescription.getAccessLocation();

		String accessLocationStr = GeneralNameUtil.toString(accessLocation);

		sb.append(MessageFormat.format(res.getString("AuthorityInformationAccess"), accessDesc));
		sb.append(NEWLINE);
		sb.append(INDENT);
		sb.append(MessageFormat.format(res.getString("AccessMethod"), accessMethodStr));
		sb.append(NEWLINE);
		sb.append(INDENT);
		sb.append(res.getString("AccessLocation"));
		sb.append(NEWLINE);
		sb.append(INDENT.toString(2));
		sb.append(accessLocationStr);
		sb.append(NEWLINE);
	}

	return sb.toString();
}
 
Example #30
Source File: DAccessDescriptionChooser.java    From keystore-explorer with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get selected access description.
 *
 * @return Access description, or null if none
 */
public AccessDescription getAccessDescription() {
	return accessDescription;
}