use of com.github.zhenwei.core.asn1.x509.Attribute in project n2o-framework by i-novus-llc.
the class IOProcessorImpl method childAttributeEnum.
@Override
public <T extends Enum<T>> void childAttributeEnum(Element element, String childName, String name, Supplier<T> getter, Consumer<T> setter, Class<T> enumClass) {
if (r) {
Element child = element.getChild(childName, element.getNamespace());
if (child == null)
return;
Attribute attribute = child.getAttribute(name);
if (attribute != null) {
setter.accept(stringToEnum(process(attribute.getValue()), enumClass));
}
} else {
if (getter.get() == null)
return;
Element childElement = element.getChild(childName, element.getNamespace());
if (childElement == null) {
childElement = new Element(childName, element.getNamespace());
childElement.setAttribute(new Attribute(name, getter.get().toString()));
element.addContent(childElement);
} else {
childElement.setAttribute(new Attribute(name, getter.get().toString()));
}
}
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project SOS by 52North.
the class AbstractNetcdfEncoder method addPublisher.
protected boolean addPublisher(AbstractSensorML sml, String contactRole, NetcdfFileWriter writer) {
SmlResponsibleParty responsibleParty = getResponsibleParty(sml, contactRole);
if (responsibleParty != null) {
if (responsibleParty.isSetOrganizationName()) {
writer.addGroupAttribute(null, new Attribute(ACDDConstants.PUBLISHER_NAME, responsibleParty.getOrganizationName()));
}
if (responsibleParty.isSetEmail()) {
writer.addGroupAttribute(null, new Attribute(ACDDConstants.PUBLISHER_EMAIL, responsibleParty.getEmail()));
}
if (responsibleParty.isSetOnlineResources()) {
writer.addGroupAttribute(null, new Attribute(ACDDConstants.PUBLISHER_URL, responsibleParty.getOnlineResources().get(0)));
}
} else {
String mail = getServiceProvider().getServiceContact().getContactInfo().flatMap(OwsContact::getAddress).map(OwsAddress::getElectronicMailAddress).map(l -> Iterables.getFirst(l, null)).orElse(null);
String name = getServiceProvider().getProviderName();
String url = getServiceProvider().getProviderSite().flatMap(OwsOnlineResource::getHref).map(URI::toString).orElse(null);
writer.addGroupAttribute(null, new Attribute(ACDDConstants.PUBLISHER_NAME, name));
writer.addGroupAttribute(null, new Attribute(ACDDConstants.PUBLISHER_EMAIL, mail));
writer.addGroupAttribute(null, new Attribute(ACDDConstants.PUBLISHER_URL, url));
}
return true;
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project SOS by 52North.
the class AbstractNetcdfEncoder method addVariableLongitude.
protected Variable addVariableLongitude(NetcdfFileWriter writer, List<Dimension> dims) {
Variable v = writer.addVariable(null, getVariableDimensionCaseName(CFStandardNames.LONGITUDE.getName()), getDataType(), dims);
v.addAttribute(new Attribute(CFConstants.STANDARD_NAME, CFStandardNames.LONGITUDE.getName()));
v.addAttribute(new Attribute(CFConstants.LONG_NAME, getLongName(CFStandardNames.LONGITUDE.getName())));
v.addAttribute(new Attribute(CFConstants.UNITS, CFConstants.UNITS_DEGREES_EAST));
v.addAttribute(new Attribute(CFConstants.AXIS, CFConstants.AXIS_X));
v.addAttribute(new Attribute(CFConstants.FILL_VALUE, getNetcdfHelper().getFillValue()));
return v;
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project SOS by 52North.
the class AbstractOceanSITESEncoder method addVariableHeight.
@Override
protected Variable addVariableHeight(NetcdfFileWriter writer, List<Dimension> dims) {
Variable variable = super.addVariableHeight(writer, dims);
variable.addAttribute(new Attribute(OceanSITESConstants.REFERENCE, OceanSITESConstants.HEIGHT_DEPTH_REFERENCE_DEFAULT));
variable.addAttribute(new Attribute(OceanSITESConstants.COORDINATE_REFERENCE_FRAME, OceanSITESConstants.EPSG_5829));
variable.addAttribute(getDefaultQcIndicatorAttribute());
return variable;
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project ca3sCore by kuehne-trustable-de.
the class CaCmpConnector method buildCertRequest.
/**
* @param certReqId
* @param csr
* @param hmacSecret
* @return PKIMessage
* @throws GeneralSecurityException
*/
public PKIMessage buildCertRequest(long certReqId, final CSR csr, final String hmacSecret) throws GeneralSecurityException {
// read the pem csr and verify the signature
PKCS10CertificationRequest p10Req;
try {
p10Req = cryptoUtil.parseCertificateRequest(csr.getCsrBase64()).getP10Req();
} catch (IOException e) {
LOGGER.error("parsing csr", e);
throw new GeneralSecurityException(e.getMessage());
}
List<RDN> rdnList = new ArrayList<>();
for (de.trustable.ca3s.core.domain.RDN rdnDao : csr.getRdns()) {
LOGGER.debug("rdnDao : " + rdnDao.getRdnAttributes());
List<AttributeTypeAndValue> attrTVList = new ArrayList<AttributeTypeAndValue>();
if (rdnDao != null && rdnDao.getRdnAttributes() != null) {
for (RDNAttribute rdnAttr : rdnDao.getRdnAttributes()) {
ASN1ObjectIdentifier aoi = new ASN1ObjectIdentifier(rdnAttr.getAttributeType());
ASN1Encodable ae = new DERUTF8String(rdnAttr.getAttributeValue());
AttributeTypeAndValue attrTV = new AttributeTypeAndValue(aoi, ae);
attrTVList.add(attrTV);
}
}
RDN rdn = new RDN(attrTVList.toArray(new AttributeTypeAndValue[attrTVList.size()]));
LOGGER.debug("rdn : " + rdn.size() + " elements");
rdnList.add(rdn);
}
X500Name subjectDN = new X500Name(rdnList.toArray(new RDN[rdnList.size()]));
LOGGER.debug("subjectDN : " + subjectDN);
Collection<Extension> certExtList = new ArrayList<>();
// copy CSR attributes to Extension list
for (Attribute attribute : p10Req.getAttributes()) {
for (ASN1Encodable asn1Encodable : attribute.getAttributeValues()) {
if (asn1Encodable != null) {
try {
Extensions extensions = Extensions.getInstance(asn1Encodable);
for (ASN1ObjectIdentifier oid : extensions.getExtensionOIDs()) {
LOGGER.debug("copying oid '" + oid.toString() + "' from csr to PKIMessage");
certExtList.add(extensions.getExtension(oid));
}
} catch (IllegalArgumentException iae) {
LOGGER.debug("processing asn1 value '" + asn1Encodable + "' caused exception", iae);
}
}
}
}
final SubjectPublicKeyInfo keyInfo = p10Req.getSubjectPublicKeyInfo();
return cryptoUtil.buildCertRequest(certReqId, subjectDN, certExtList, keyInfo, hmacSecret);
}
Aggregations