Search in sources :

Example 36 with JsonObject

use of com.helger.json.JsonObject in project peppol-commons by phax.

the class SMPJsonResponse method convertEndpoint.

@Nonnull
public static IJsonObject convertEndpoint(@Nonnull final com.helger.xsds.bdxr.smp1.EndpointType aEndpoint) {
    final IJsonObject aJsonEP = new JsonObject().add(JSON_TRANSPORT_PROFILE, aEndpoint.getTransportProfile()).add(JSON_ENDPOINT_REFERENCE, aEndpoint.getEndpointURI()).add(JSON_REQUIRE_BUSINESS_LEVEL_SIGNATURE, aEndpoint.isRequireBusinessLevelSignature()).add(JSON_MINIMUM_AUTHENTICATION_LEVEL, aEndpoint.getMinimumAuthenticationLevel());
    aJsonEP.addIfNotNull(JSON_SERVICE_ACTIVATION_DATE, getLDT(aEndpoint.getServiceActivationDate()));
    aJsonEP.addIfNotNull(JSON_SERVICE_EXPIRATION_DATE, getLDT(aEndpoint.getServiceExpirationDate()));
    convertCertificate(aJsonEP, Base64.encodeBytes(aEndpoint.getCertificate()));
    aJsonEP.add(JSON_SERVICE_DESCRIPTION, aEndpoint.getServiceDescription()).add(JSON_TECHNICAL_CONTACT_URL, aEndpoint.getTechnicalContactUrl()).add(JSON_TECHNICAL_INFORMATION_URL, aEndpoint.getTechnicalInformationUrl()).addIfNotNull(JSON_EXTENSION, BDXR1ExtensionConverter.convertToJson(aEndpoint.getExtension()));
    return aJsonEP;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Example 37 with JsonObject

use of com.helger.json.JsonObject in project peppol-commons by phax.

the class SMPJsonResponse method convertEndpoint.

@Nonnull
public static IJsonObject convertEndpoint(@Nonnull final com.helger.xsds.peppol.smp1.EndpointType aEndpoint) {
    final String sEndpointRef = aEndpoint.getEndpointReference() == null ? null : W3CEndpointReferenceHelper.getAddress(aEndpoint.getEndpointReference());
    final IJsonObject aJsonEP = new JsonObject().add(JSON_TRANSPORT_PROFILE, aEndpoint.getTransportProfile()).add(JSON_ENDPOINT_REFERENCE, sEndpointRef).add(JSON_REQUIRE_BUSINESS_LEVEL_SIGNATURE, aEndpoint.isRequireBusinessLevelSignature()).add(JSON_MINIMUM_AUTHENTICATION_LEVEL, aEndpoint.getMinimumAuthenticationLevel());
    aJsonEP.addIfNotNull(JSON_SERVICE_ACTIVATION_DATE, getLDT(aEndpoint.getServiceActivationDate()));
    aJsonEP.addIfNotNull(JSON_SERVICE_EXPIRATION_DATE, getLDT(aEndpoint.getServiceExpirationDate()));
    convertCertificate(aJsonEP, aEndpoint.getCertificate());
    aJsonEP.add(JSON_SERVICE_DESCRIPTION, aEndpoint.getServiceDescription()).add(JSON_TECHNICAL_CONTACT_URL, aEndpoint.getTechnicalContactUrl()).add(JSON_TECHNICAL_INFORMATION_URL, aEndpoint.getTechnicalInformationUrl()).add(JSON_EXTENSION, SMPExtensionConverter.convertToString(aEndpoint.getExtension()));
    return aJsonEP;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Example 38 with JsonObject

use of com.helger.json.JsonObject in project peppol-commons by phax.

the class SMPJsonResponse method getJsonPrincipal.

@Nonnull
public static IJsonObject getJsonPrincipal(@Nonnull final X500Principal aPrincipal) {
    ValueEnforcer.notNull(aPrincipal, "Principal");
    final IJsonObject ret = new JsonObject();
    ret.add("name", aPrincipal.getName());
    try {
        for (final Rdn aRdn : new LdapName(aPrincipal.getName()).getRdns()) ret.add(aRdn.getType(), aRdn.getValue());
    } catch (final InvalidNameException ex) {
    // shit happens
    }
    return ret;
}
Also used : InvalidNameException(javax.naming.InvalidNameException) IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Rdn(javax.naming.ldap.Rdn) LdapName(javax.naming.ldap.LdapName) Nonnull(javax.annotation.Nonnull)

Example 39 with JsonObject

use of com.helger.json.JsonObject in project ph-web by phax.

the class LoggingRequest method getAsJson.

@Nonnull
public IJsonObject getAsJson() {
    final JsonObject ret = new JsonObject();
    if (m_sSender != null)
        ret.add("sender", m_sSender);
    if (m_sMethod != null)
        ret.add("method", m_sMethod);
    if (m_sPath != null)
        ret.add("path", m_sPath);
    if (m_aParams != null)
        ret.addJson("params", new JsonObject().addAll(m_aParams));
    if (m_aHeaders != null) {
        final IJsonObject aHeaders = new JsonObject();
        m_aHeaders.forEachSingleHeader(aHeaders::add, true);
        ret.addJson("headers", aHeaders);
    }
    if (m_sBody != null)
        ret.add("body", m_sBody);
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Example 40 with JsonObject

use of com.helger.json.JsonObject in project ph-web by phax.

the class LoggingResponse method getAsJson.

@Nonnull
public IJsonObject getAsJson() {
    final JsonObject ret = new JsonObject();
    if (m_nStatus != 0)
        ret.add("status", m_nStatus);
    if (m_aHeaders != null) {
        final IJsonObject aHeaders = new JsonObject();
        m_aHeaders.forEachSingleHeader(aHeaders::add, true);
        ret.addJson("headers", aHeaders);
    }
    if (m_sBody != null)
        ret.add("body", m_sBody);
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Aggregations

JsonObject (com.helger.json.JsonObject)40 IJsonObject (com.helger.json.IJsonObject)38 Nonnull (javax.annotation.Nonnull)27 JsonArray (com.helger.json.JsonArray)16 IJsonArray (com.helger.json.IJsonArray)13 Map (java.util.Map)5 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)3 ICommonsList (com.helger.commons.collection.impl.ICommonsList)3 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)3 StopWatch (com.helger.commons.timing.StopWatch)3 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)3 ZonedDateTime (java.time.ZonedDateTime)3 Locale (java.util.Locale)3 Nonempty (com.helger.commons.annotation.Nonempty)2 CommonsTreeMap (com.helger.commons.collection.impl.CommonsTreeMap)2 IError (com.helger.commons.error.IError)2 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)2 IHCNode (com.helger.html.hc.IHCNode)2 JsonWriter (com.helger.json.serialize.JsonWriter)2