Search in sources :

Example 61 with Attribute

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()));
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 62 with Attribute

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;
}
Also used : OGCConstants(org.n52.shetland.ogc.OGCConstants) DateTimeZone(org.joda.time.DateTimeZone) AbstractObservationResponse(org.n52.shetland.ogc.sos.response.AbstractObservationResponse) CodedException(org.n52.shetland.ogc.ows.exception.CodedException) AbstractSensorDataset(org.n52.sos.netcdf.data.dataset.AbstractSensorDataset) SosConstants(org.n52.shetland.ogc.sos.SosConstants) Time(org.n52.shetland.ogc.gml.time.Time) ArrayFloat(ucar.ma2.ArrayFloat) OwsServiceProvider(org.n52.shetland.ogc.ows.OwsServiceProvider) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Map(java.util.Map) ObservationStream(org.n52.shetland.ogc.om.ObservationStream) DescribeSensorResponse(org.n52.shetland.ogc.sos.response.DescribeSensorResponse) SensorML(org.n52.shetland.ogc.sensorML.SensorML) EncodingException(org.n52.svalbard.encode.exception.EncodingException) Set(java.util.Set) OwsServiceMetadataRepository(org.n52.iceland.ogc.ows.OwsServiceMetadataRepository) Attribute(ucar.nc2.Attribute) SmlClassifier(org.n52.shetland.ogc.sensorML.elements.SmlClassifier) NetcdfFileWriter(ucar.nc2.NetcdfFileWriter) OwsAddress(org.n52.shetland.ogc.ows.OwsAddress) Joiner(com.google.common.base.Joiner) Iterables(com.google.common.collect.Iterables) SmlClassifierPredicates(org.n52.shetland.ogc.sensorML.elements.SmlClassifierPredicates) MediaType(org.n52.janmayen.http.MediaType) DateTimeHelper(org.n52.shetland.util.DateTimeHelper) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) Version(ucar.nc2.NetcdfFileWriter.Version) LinkedHashSet(java.util.LinkedHashSet) ArrayDouble(ucar.ma2.ArrayDouble) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) OwsOnlineResource(org.n52.shetland.ogc.ows.OwsOnlineResource) IOException(java.io.IOException) NetCDFObservation(org.n52.sos.netcdf.om.NetCDFObservation) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) ACDDConstants(com.axiomalaska.cf4j.constants.ACDDConstants) Array(ucar.ma2.Array) File(java.io.File) SosProcedureDescriptionUnknownType(org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType) Nc4Iosp(ucar.nc2.jni.netcdf.Nc4Iosp) InvalidRangeException(ucar.ma2.InvalidRangeException) CFStandardNames(com.axiomalaska.cf4j.CFStandardNames) Index(ucar.ma2.Index) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) Dimension(ucar.nc2.Dimension) ProcedureDescriptionFormatRepository(org.n52.sos.coding.encode.ProcedureDescriptionFormatRepository) NetcdfConstants(org.n52.sos.netcdf.NetcdfConstants) Value(org.n52.shetland.ogc.om.values.Value) SensorML20Constants(org.n52.shetland.ogc.sensorML.SensorML20Constants) ObservationEncoder(org.n52.svalbard.encode.ObservationEncoder) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) AbstractDescribeSensorHandler(org.n52.sos.ds.AbstractDescribeSensorHandler) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) SmlContact(org.n52.shetland.ogc.sensorML.SmlContact) EncodingContext(org.n52.svalbard.encode.EncodingContext) Locale(java.util.Locale) NetcdfHelper(org.n52.sos.netcdf.NetcdfHelper) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) URI(java.net.URI) ImmutableSet(com.google.common.collect.ImmutableSet) OperationHandler(org.n52.iceland.request.handler.OperationHandler) Collection(java.util.Collection) DataType(ucar.ma2.DataType) CiRoleCodes(org.n52.shetland.iso.CodeList.CiRoleCodes) UUID(java.util.UUID) Sets(com.google.common.collect.Sets) CDM(ucar.nc2.constants.CDM) List(java.util.List) DescribeSensorRequest(org.n52.shetland.ogc.sos.request.DescribeSensorRequest) ProfileSubSensor(org.n52.sos.netcdf.data.subsensor.ProfileSubSensor) GeometryHandler(org.n52.sos.util.GeometryHandler) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Entry(java.util.Map.Entry) Optional(java.util.Optional) SupportedType(org.n52.shetland.ogc.SupportedType) OperationHandlerRepository(org.n52.iceland.request.handler.OperationHandlerRepository) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) SubSensor(org.n52.sos.netcdf.data.subsensor.SubSensor) CFConstants(com.axiomalaska.cf4j.constants.CFConstants) OmConstants(org.n52.shetland.ogc.om.OmConstants) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) CF(ucar.nc2.constants.CF) SensorMLConstants(org.n52.shetland.ogc.sensorML.SensorMLConstants) Inject(javax.inject.Inject) SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier) CDMNode(ucar.nc2.CDMNode) BinaryAttachmentResponse(org.n52.shetland.ogc.sos.response.BinaryAttachmentResponse) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) Variable(ucar.nc2.Variable) NetCDFUtil(org.n52.sos.netcdf.NetCDFUtil) NODCConstants(com.axiomalaska.cf4j.constants.NODCConstants) Nc4ForceTimeChunkingStategy(org.n52.sos.netcdf.Nc4ForceTimeChunkingStategy) StaticLocationDataset(org.n52.sos.netcdf.data.dataset.StaticLocationDataset) IndexIterator(ucar.ma2.IndexIterator) DateTime(org.joda.time.DateTime) BinProfileSubSensor(org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor) Maps(com.google.common.collect.Maps) SmlIdentifierPredicates(org.n52.shetland.ogc.sensorML.elements.SmlIdentifierPredicates) OwsContact(org.n52.shetland.ogc.ows.OwsContact) Collections(java.util.Collections) OwsOnlineResource(org.n52.shetland.ogc.ows.OwsOnlineResource) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) Attribute(ucar.nc2.Attribute) OwsAddress(org.n52.shetland.ogc.ows.OwsAddress)

Example 63 with Attribute

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;
}
Also used : Variable(ucar.nc2.Variable) Attribute(ucar.nc2.Attribute)

Example 64 with Attribute

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;
}
Also used : Variable(ucar.nc2.Variable) Attribute(ucar.nc2.Attribute)

Example 65 with Attribute

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);
}
Also used : PKCS10CertificationRequest(org.bouncycastle.pkcs.PKCS10CertificationRequest) RDNAttribute(de.trustable.ca3s.core.domain.RDNAttribute) DERUTF8String(org.bouncycastle.asn1.DERUTF8String) RDNAttribute(de.trustable.ca3s.core.domain.RDNAttribute) CsrAttribute(de.trustable.ca3s.core.domain.CsrAttribute) Attribute(org.bouncycastle.asn1.pkcs.Attribute) GeneralSecurityException(java.security.GeneralSecurityException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) X500Name(org.bouncycastle.asn1.x500.X500Name) Extensions(org.bouncycastle.asn1.x509.Extensions) SubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo) AttributeTypeAndValue(org.bouncycastle.asn1.x500.AttributeTypeAndValue) Extension(org.bouncycastle.asn1.x509.Extension) ASN1Encodable(org.bouncycastle.asn1.ASN1Encodable) RDN(org.bouncycastle.asn1.x500.RDN) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

Attribute (org.jdom2.Attribute)316 Element (org.jdom2.Element)210 IOException (java.io.IOException)98 ArrayList (java.util.ArrayList)75 Attribute (ucar.nc2.Attribute)65 List (java.util.List)46 Document (org.jdom2.Document)43 Variable (ucar.nc2.Variable)39 HashMap (java.util.HashMap)26 Extensions (org.bouncycastle.asn1.x509.Extensions)26 X509Certificate (java.security.cert.X509Certificate)24 Namespace (org.jdom2.Namespace)24 File (java.io.File)23 Attribute (org.bouncycastle.asn1.pkcs.Attribute)21 GeneralName (org.bouncycastle.asn1.x509.GeneralName)21 Array (ucar.ma2.Array)21 Test (org.junit.Test)20 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)19 Dimension (ucar.nc2.Dimension)19 Map (java.util.Map)17