use of com.helger.json.JsonObject in project phoss-smp by phax.
the class AjaxExecutorPublicLogin method mainHandleRequest.
@Override
protected void mainHandleRequest(@Nonnull final LayoutExecutionContext aLEC, @Nonnull final PhotonUnifiedResponse aAjaxResponse) throws Exception {
final String sLoginName = aLEC.params().getAsString(CLogin.REQUEST_ATTR_USERID);
final String sPassword = aLEC.params().getAsString(CLogin.REQUEST_ATTR_PASSWORD);
// Main login
final ELoginResult eLoginResult = LoggedInUserManager.getInstance().loginUser(sLoginName, sPassword, CSMP.REQUIRED_ROLE_IDS_WRITABLERESTAPI);
if (eLoginResult.isSuccess()) {
aAjaxResponse.json(new JsonObject().add(JSON_LOGGEDIN, true));
return;
}
// Get the rendered content of the menu area
if (GlobalDebug.isDebugMode())
if (LOGGER.isWarnEnabled())
LOGGER.warn("Login of '" + sLoginName + "' failed because " + eLoginResult);
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IHCNode aRoot = error(EPhotonCoreText.LOGIN_ERROR_MSG.getDisplayText(aDisplayLocale) + " " + eLoginResult.getDisplayText(aDisplayLocale));
// Set as result property
aAjaxResponse.json(new JsonObject().add(JSON_LOGGEDIN, false).add(JSON_HTML, HCRenderer.getAsHTMLStringWithoutNamespaces(aRoot)));
}
use of com.helger.json.JsonObject in project phoss-smp by phax.
the class ImportSummary method appendTo.
public void appendTo(@Nonnull final IJsonObject aJson) {
ValueEnforcer.notNull(aJson, "JsonObject");
final IJsonArray aActions = new JsonArray();
for (final Map.Entry<EImportSummaryAction, ImportSummaryItem> eItem : m_aMap.entrySet()) aActions.add(new JsonObject().add("id", eItem.getKey().getID()).add("success", eItem.getValue().getSuccessCount()).add("error", eItem.getValue().getErrorCount()));
aJson.addJson("actions", aActions);
}
use of com.helger.json.JsonObject in project phase4 by phax.
the class PModeLegSecurityJsonConverter method convertToJson.
/**
* Convert the provided {@link PModeLegSecurity} object to a JSON object. The
* conversion from JSON Object back to a domain object happens via
* {@link #convertToNative(IJsonObject)}.
*
* @param aValue
* The value to be converted. May not be <code>null</code>.
* @return The non-<code>null</code> JSON object filled with the necessary
* values.
*/
@Nonnull
public static IJsonObject convertToJson(@Nonnull final PModeLegSecurity aValue) {
final IJsonObject ret = new JsonObject();
if (aValue.hasWSSVersion())
ret.add(ATTR_WSS_VERSION, aValue.getWSSVersionAsString());
if (aValue.x509SignElements().isNotEmpty())
ret.addJson(ELEMENT_X509_SIGN_ELEMENT, new JsonArray().addAll(aValue.x509SignElements()));
if (aValue.x509SignAttachments().isNotEmpty())
ret.addJson(ELEMENT_X509_SIGN_ATTACHMENT, new JsonArray().addAll(aValue.x509SignAttachments()));
if (aValue.hasX509SignatureCertificate())
ret.add(ELEMENT_X509_SIGNATURE_CERTIFICATE, aValue.getX509SignatureCertificate());
if (aValue.hasX509SignatureHashFunction())
ret.add(ATTR_X509_SIGNATURE_HASH_FUNCTION, aValue.getX509SignatureHashFunctionID());
if (aValue.hasX509SignatureAlgorithm())
ret.add(ATTR_X509_SIGNATURE_ALGORITHM, aValue.getX509SignatureAlgorithmID());
if (aValue.x509EncryptionEncryptElements().isNotEmpty())
ret.addJson(ELEMENT_X509_ENCRYPTION_ENCRYPT_ELEMENT, new JsonArray().addAll(aValue.x509EncryptionEncryptElements()));
if (aValue.x509EncryptionEncryptAttachments().isNotEmpty())
ret.addJson(ELEMENT_X509_ENCRYPTION_ENCRYPT_ATTACHMENT, new JsonArray().addAll(aValue.x509EncryptionEncryptAttachments()));
if (aValue.hasX509EncryptionCertificate())
ret.add(ELEMENT_X509_ENCRYPTION_CERTIFICATE, aValue.getX509EncryptionCertificate());
ret.add(ATTR_X509_ENCRYPTION_ALGORITHM, aValue.getX509EncryptionAlgorithmID());
if (aValue.hasX509EncryptionMinimumStrength())
ret.add(ATTR_X509_ENCRYPTION_MINIMUM_STRENGTH, aValue.getX509EncryptionMinimumStrength().intValue());
if (aValue.hasUsernameTokenUsername())
ret.add(ATTR_USERNAME_TOKEN_USERNAME, aValue.getUsernameTokenUsername());
if (aValue.hasUsernameTokenPassword())
ret.add(ATTR_USERNAME_TOKEN_PASSWORD, aValue.getUsernameTokenPassword());
if (aValue.isUsernameTokenDigestDefined())
ret.add(ATTR_USERNAME_TOKEN_DIGEST, aValue.isUsernameTokenDigest());
if (aValue.isUsernameTokenNonceDefined())
ret.add(ATTR_USERNAME_TOKEN_NONCE, aValue.isUsernameTokenNonce());
if (aValue.isUsernameTokenCreatedDefined())
ret.add(ATTR_USERNAME_TOKEN_CREATED, aValue.isUsernameTokenCreated());
if (aValue.isPModeAuthorizeDefined())
ret.add(ATTR_PMODE_AUTHORIZE, aValue.isPModeAuthorize());
if (aValue.isSendReceiptDefined())
ret.add(ATTR_SEND_RECEIPT, aValue.isSendReceipt());
if (aValue.hasSendReceiptReplyPattern())
ret.add(ATTR_SEND_RECEIPT_REPLY_PATTERN, aValue.getSendReceiptReplyPatternID());
if (aValue.isSendReceiptNonRepudiationDefined())
ret.add(ATTR_SEND_RECEIPT_NON_REPUDIATION, aValue.isSendReceiptNonRepudiation());
return ret;
}
use of com.helger.json.JsonObject in project phase4 by phax.
the class PModePayloadProfileJsonConverter method convertToJson.
@Nonnull
public static IJsonObject convertToJson(@Nonnull final PModePayloadProfile aValue) {
final IJsonObject ret = new JsonObject();
ret.add(NAME, aValue.getName());
ret.add(MIME_TYPE, aValue.getMimeType().getAsString());
if (aValue.hasXSDFilename())
ret.add(XSD_FILENAME, aValue.getXSDFilename());
if (aValue.hasMaxSizeKB())
ret.add(MAX_SIZE_KB, aValue.getMaxSizeKB().intValue());
ret.add(MANDATORY, aValue.isMandatory());
return ret;
}
use of com.helger.json.JsonObject in project phase4 by phax.
the class PModeLegProtocolJsonConverter method convertToJson.
@Nonnull
public static IJsonObject convertToJson(@Nonnull final PModeLegProtocol aValue) {
final IJsonObject ret = new JsonObject();
if (aValue.hasAddress())
ret.add(ADDRESS, aValue.getAddress());
ret.add(SOAP_VERSION, aValue.getSoapVersion().getVersion());
return ret;
}
Aggregations