Java Code Examples for javax.json.JsonObject#containsKey()

The following examples show how to use javax.json.JsonObject#containsKey() . 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: GenerateExtensionsJsonMojo.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private JsonObject mergeObject(JsonObject extObject, JsonObject extOverride) {
    final JsonObjectBuilder mergedObject = Json.createObjectBuilder(extObject);
    for (Map.Entry<String, JsonValue> e : extOverride.entrySet()) {
        JsonValue.ValueType tp = e.getValue().getValueType();
        if (tp == JsonValue.ValueType.OBJECT
                && extObject.containsKey(e.getKey())
                && extObject.get(e.getKey()).getValueType() == JsonValue.ValueType.OBJECT) {
            mergedObject.add(e.getKey(),
                    mergeObject(extObject.get(e.getKey()).asJsonObject(), e.getValue().asJsonObject()));
        } else if (tp == JsonValue.ValueType.ARRAY) {
            final JsonArrayBuilder newArray = Json.createArrayBuilder(e.getValue().asJsonArray());
            mergedObject.add(e.getKey(), newArray.build());
        } else {
            mergedObject.add(e.getKey(), e.getValue());
        }
    }
    return mergedObject.build();
}
 
Example 2
Source File: PsGoogle.java    From takes with MIT License 6 votes vote down vote up
/**
 * Get user name from Google, with the token provided.
 * @param token Google access token
 * @return The user found in Google
 * @throws IOException If fails
 */
private Identity fetch(final String token) throws IOException {
    // @checkstyle LineLength (1 line)
    final String uri = new Href(this.gapi).path("plus").path("v1")
        .path("people")
        .path("me")
        .with(PsGoogle.ACCESS_TOKEN, token)
        .toString();
    final JsonObject json = new JdkRequest(uri).fetch()
        .as(JsonResponse.class).json()
        .readObject();
    if (json.containsKey(PsGoogle.ERROR)) {
        throw new HttpException(
            HttpURLConnection.HTTP_BAD_REQUEST,
            String.format(
                "could not retrieve id from Google, possible cause: %s.",
                json.getJsonObject(PsGoogle.ERROR).get("message")
            )
        );
    }
    return PsGoogle.parse(json);
}
 
Example 3
Source File: MigrationService.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
@Override
public JsonObject removeProperty( MigrationContext context, JsonObject state, String name )
    throws JsonException
{
    JsonObject valueState = state.getJsonObject( JSONKeys.VALUE );
    if( valueState.containsKey( name ) )
    {
        valueState = jsonFactories.cloneBuilderExclude( valueState, name ).build();
        JsonObject migratedState = jsonFactories
            .cloneBuilderExclude( state, JSONKeys.VALUE )
            .add( JSONKeys.VALUE, valueState )
            .build();
        context.markAsChanged();
        for( MigrationEvents migrationEvent : migrationEvents )
        {
            migrationEvent.propertyRemoved( state.getString( JSONKeys.IDENTITY ), name );
        }
        return migratedState;
    }
    else
    {
        context.addFailure( "Remove property " + name );
        return state;
    }
}
 
Example 4
Source File: OpenApiTestCase.java    From quarkus with Apache License 2.0 6 votes vote down vote up
protected static String schemaType(String responseCode, String mediaType, JsonObject responses, JsonObject schemas) {
    JsonObject responseContent = responses.getJsonObject(responseCode).getJsonObject("content");
    if (responseContent == null) {
        return null;
    }
    JsonObject schemaObj = responseContent.getJsonObject(mediaType)
            .getJsonObject("schema");

    if (schemaObj.containsKey("type")) {
        return schemaObj.getString("type");
    } else if (schemaObj.containsKey("$ref")) {
        return schemaTypeFromRef(schemaObj, schemas);
    }

    throw new IllegalArgumentException(
            "Cannot retrieve schema type for response " + responseCode + " and media type " + mediaType);
}
 
Example 5
Source File: JcQueryResult.java    From jcypher with Apache License 2.0 6 votes vote down vote up
/**
 * @return a list of database errors
 * <br/>(the database was successfully accessed, but the query produced error(s)).
 */
public List<JcError> getDBErrors() {
	if (this.dbErrors == null) {
		this.dbErrors = new ArrayList<JcError>();
		JsonObject obj = getJsonResult();
		if (obj != null) {
			JsonArray errs = obj.getJsonArray("errors");
			int size = errs.size();
			for (int i = 0; i < size; i++) {
				JsonObject err = errs.getJsonObject(i);
				String info = null;
				if (err.containsKey("info"))
					info = err.getString("info");
				this.dbErrors.add(new JcError(err.getString("code"),
						err.getString("message"), info));
			}
		}
	}
	return this.dbErrors;
}
 
Example 6
Source File: Json2Xml.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<JsonValue> getNodeChildrenByName(JsonValue node, XSElementDeclaration childElementDeclaration) throws SAXException {
	String name=childElementDeclaration.getName();
	if (log.isTraceEnabled()) log.trace("getChildrenByName() childname ["+name+"] isParentOfSingleMultipleOccurringChildElement ["+isParentOfSingleMultipleOccurringChildElement()+"] isMultipleOccuringChildElement ["+isMultipleOccurringChildElement(name)+"] node ["+node+"]");
	try {
		if (!(node instanceof JsonObject)) {
			if (log.isTraceEnabled()) log.trace("getChildrenByName() parent node is not a JsonObject, but a ["+node.getClass().getName()+"]");
			return null;
		} 
		JsonObject o = (JsonObject)node;
		if (!o.containsKey(name)) {
			if (log.isTraceEnabled()) log.trace("getChildrenByName() no children named ["+name+"] node ["+node+"]");
			return null;
		} 
		JsonValue child = o.get(name);
		List<JsonValue> result = new LinkedList<JsonValue>(); 
		if (child instanceof JsonArray) {
			if (log.isTraceEnabled()) log.trace("getChildrenByName() child named ["+name+"] is a JsonArray, current node insertElementContainerElements ["+insertElementContainerElements+"]");
			// if it could be necessary to insert elementContainers, we cannot return them as a list of individual elements now, because then the containing element would be duplicated
			// we also cannot use the isSingleMultipleOccurringChildElement, because it is not valid yet
			if (!isMultipleOccurringChildElement(name)) {
				if (insertElementContainerElements || !strictSyntax) { 
					result.add(child);
					if (log.isTraceEnabled()) log.trace("getChildrenByName() singleMultipleOccurringChildElement ["+name+"] returning array node (insertElementContainerElements=true)");
				} else {
					throw new SAXException(MSG_EXPECTED_SINGLE_ELEMENT+" ["+name+"]");
				}
			} else {
				if (log.isTraceEnabled()) log.trace("getChildrenByName() childname ["+name+"] returning elements of array node (insertElementContainerElements=false or not singleMultipleOccurringChildElement)");
				result.addAll((JsonArray)child);
			}
			return result;
		}
		result.add(child);
		if (log.isTraceEnabled()) log.trace("getChildrenByName() name ["+name+"] returning ["+child+"]");
		return result;
	} catch (JsonException e) {
		throw new SAXException(e);
	}
}
 
Example 7
Source File: JsonFormatterTest.java    From jboss-logmanager-ext with Apache License 2.0 5 votes vote down vote up
private static long getLong(final JsonObject json, final Key key) {
    final String name = getKey(key);
    if (json.containsKey(name) && !json.isNull(name)) {
        return json.getJsonNumber(name).longValue();
    }
    return 0L;
}
 
Example 8
Source File: SystemInputJson.java    From tcases with MIT License 5 votes vote down vote up
/**
 * Returns the AnyOf condition represented by the given JSON object or an empty
 * value if no such condition is found.
 */
private static Optional<ICondition> asAnyOf( JsonObject json)
  {
  return
    json.containsKey( ANY_OF_KEY)
    ? Optional.of( new AnyOf( toConditions( json.getJsonArray( ANY_OF_KEY))))
    : Optional.empty();
  }
 
Example 9
Source File: BattleResultDto.java    From logbook with MIT License 5 votes vote down vote up
/**
 * コンストラクター
 *
 * @param object JSON Object
 * @param mapCellNo マップ上のマス
 * @param mapBossCellNo ボスマス
 * @param eventId EventId
 * @param isStart 出撃
 * @param battle 戦闘
 */
public BattleResultDto(JsonObject object, int mapCellNo, int mapBossCellNo, int eventId, boolean isStart,
        BattleDto battle) {

    this.battleDate = Calendar.getInstance().getTime();
    this.questName = object.getString("api_quest_name");
    this.rank = object.getString("api_win_rank");
    this.mapCellNo = mapCellNo;
    this.start = isStart;
    this.boss = (mapCellNo == mapBossCellNo) || (eventId == 5);
    this.enemyName = object.getJsonObject("api_enemy_info").getString("api_deck_name");
    this.dropShip = object.containsKey("api_get_ship");
    this.dropItem = object.containsKey("api_get_useitem");
    if (this.dropShip || this.dropItem) {
        if (this.dropShip) {
            this.dropType = object.getJsonObject("api_get_ship").getString("api_ship_type");
            this.dropName = object.getJsonObject("api_get_ship").getString("api_ship_name");
        } else {
            String name = UseItem.get(object.getJsonObject("api_get_useitem").getInt("api_useitem_id"));
            this.dropType = "アイテム";
            this.dropName = StringUtils.defaultString(name);
        }
    } else {
        this.dropType = "";
        this.dropName = "";
    }

    this.battle = battle;
}
 
Example 10
Source File: CodeGenerator.java    From FHIR with Apache License 2.0 5 votes vote down vote up
private boolean hasRequiredBinding(JsonObject elementDefinition) {
    JsonObject binding = getBinding(elementDefinition);
    if (binding != null && binding.containsKey("valueSet") && binding.containsKey("strength")) {
        String valueSet = binding.getString("valueSet");
        String[] tokens = valueSet.split("\\|");
        valueSet = tokens[0];
        return "required".equals(binding.getString("strength")) && hasConcepts(valueSet);
    }
    return false;
}
 
Example 11
Source File: SystemInputJson.java    From tcases with MIT License 5 votes vote down vote up
/**
 * Returns the ContainsAll condition represented by the given JSON object or an empty
 * value if no such condition is found.
 */
private static Optional<ICondition> asContainsAll( JsonObject json)
  {
  return
    json.containsKey( HAS_ALL_KEY)
    ? Optional.of( new ContainsAll( toIdentifiers( json.getJsonArray( HAS_ALL_KEY))))
    : Optional.empty();
  }
 
Example 12
Source File: MessageResolver.java    From vicinity-gateway-api with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Resolves the message that arrived from the network. A valid network message will contain a JSON that
 * can be decoded as one of the {@link NetworkMessage NetworkMessage} types. 
 *  
 * @param String Message body.
 * @return Some extension of a {@link NetworkMessage NetworkMessage} class, or null if the received message did not
 * contain a valid or suitable JSON.
 */
public NetworkMessage resolveNetworkMessage(String message){
	
	JsonObject json = readJsonObject(message);
	
	if (json == null){
		
		// it is not a JSON...
		return null;
	}
	
	if (!json.containsKey(NetworkMessage.ATTR_MESSAGETYPE)){
		// it is JSON but is malformed
		return null;
	}
	
	// ok seems legit
	switch (json.getInt(NetworkMessage.ATTR_MESSAGETYPE)){
	
	case NetworkMessageRequest.MESSAGE_TYPE:
		// check for message duplication
		//if (checkForDuplicates(json.getInt(NetworkMessage.ATTR_REQUESTID))) {
		//	return null;
		//}
		
		return new NetworkMessageRequest(json, config, logger);
		
	case NetworkMessageResponse.MESSAGE_TYPE:
		// check for message duplication
		//if (checkForDuplicates(json.getInt(NetworkMessage.ATTR_REQUESTID))) {
		//	return null;
		//}
		
		return new NetworkMessageResponse(json, config, logger);
		
	case NetworkMessageEvent.MESSAGE_TYPE:
		
		// no duplication checking for events! there is no request ID
		
		return new NetworkMessageEvent(json, config, logger);
		
		default:
			
			return null;
	}
}
 
Example 13
Source File: SKFSServlet.java    From fido2 with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Step-1 for fido authenticator registration. This methods generates a
 * challenge and returns the same to the caller, which typically is a
 * Relying Party (RP) application.
 *
 * @param input
 * @return - A Json in String format. The Json will have 3 key-value pairs;
 * 1. 'Challenge' : 'U2F Reg Challenge parameters; a json again' 2.
 * 'Message' : String, with a list of messages that explain the process. 3.
 * 'Error' : String, with error message incase something went wrong. Will be
 * empty if successful.
 */
@POST
@Path("/preregister")
@Consumes({"application/json"})
@Produces({"application/json"})
public Response preregister(String input) {

    ServiceInfo svcinfoObj;

    JsonObject inputJson =  skfsCommon.getJsonObjectFromString(input);
    if (inputJson == null) {
        return Response.status(Response.Status.BAD_REQUEST).entity(skfsCommon.getMessageProperty("FIDO-ERR-0014") + " input").build();
    }
    PreregistrationRequest pregreq = new PreregistrationRequest();
    JsonObject svcinfo = inputJson.getJsonObject("svcinfo");
    svcinfoObj = skfsCommon.checkSvcInfo("REST", svcinfo.toString());
    Response svcres = checksvcinfoerror(svcinfoObj);
    if(svcres !=null){
        return svcres;
    }
    JsonObject preregpayload = inputJson.getJsonObject("payload");

    if (preregpayload.containsKey("username")) {
        pregreq.setUsername(preregpayload.getString("username"));
    }

    if (preregpayload.containsKey("displayname")) {
        pregreq.setDisplayname(preregpayload.getString("displayname"));
    }

    if (preregpayload.containsKey("options")) {
        pregreq.setOptions(preregpayload.getString("options"));
    }

    if (preregpayload.containsKey("extensions")) {
        pregreq.setExtensions(preregpayload.getString("extensions"));
    }

    boolean isAuthorized;
    if (svcinfoObj.getAuthtype().equalsIgnoreCase("password")) {
        try {
            isAuthorized = authorizebean.execute(svcinfoObj.getDid(), svcinfoObj.getSvcusername(), svcinfoObj.getSvcpassword(), skfsConstants.LDAP_ROLE_FIDO);
        } catch (Exception ex) {
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, skfsCommon.getMessageProperty("FIDO-ERR-0003"), ex.getMessage());
            return Response.status(Response.Status.BAD_REQUEST).entity(skfsCommon.getMessageProperty("FIDO-ERR-0003") + ex.getMessage()).build();
        }
        if (!isAuthorized) {
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0033", "");
            return Response.status(Response.Status.UNAUTHORIZED).build();
        }
    } else {
        if (!authRest.execute(svcinfoObj.getDid(), request, pregreq)) {
            return Response.status(Response.Status.UNAUTHORIZED).build();
        }
    }

    pregreq.setProtocol(svcinfoObj.getProtocol());
    return u2fHelperBean.preregister(svcinfoObj.getDid(), pregreq);
}
 
Example 14
Source File: OslcException.java    From maximorestclient with Apache License 2.0 4 votes vote down vote up
public OslcException(JsonObject jo) {
	super(jo.containsKey("Error") ? jo.getJsonObject("Error").getString(
			"message") : (jo.containsKey("oslc:Error")?jo.getJsonObject("oslc:Error").getString(
			"oslc:message"):""));
}
 
Example 15
Source File: JobParameter.java    From FHIR with Apache License 2.0 4 votes vote down vote up
public static void parse(Builder builder, JsonObject obj) throws FHIROperationException, IOException {
    if (obj.containsKey("fhir.resourcetype")) {
        String fhirResourceType = obj.getString("fhir.resourcetype");
        builder.fhirResourceType(fhirResourceType);
    }

    if (obj.containsKey("fhir.search.fromdate")) {
        String fhirSearchFromdate = obj.getString("fhir.search.fromdate");
        builder.fhirSearchFromDate(fhirSearchFromdate);
    }

    if (obj.containsKey("cos.bucket.name")) {
        String cosBucketName = obj.getString("cos.bucket.name");
        builder.cosBucketName(cosBucketName);
    }

    if (obj.containsKey("cos.operationoutcomes.bucket.name")) {
        String cosBucketNameOperationOutcome = obj.getString("cos.operationoutcomes.bucket.name");
        builder.cosBucketNameOperationOutcome(cosBucketNameOperationOutcome);
    }

    if (obj.containsKey("cos.location")) {
        String cosLocation = obj.getString("cos.location");
        builder.cosLocation(cosLocation);
    }

    if (obj.containsKey("cos.endpointurl")) {
        String cosEndpointUrl = obj.getString("cos.endpointurl");
        builder.cosEndpointUrl(cosEndpointUrl);
    }

    if (obj.containsKey("cos.credential.ibm")) {
        String cosCredentialIbm = obj.getString("cos.credential.ibm");
        builder.cosCredentialIbm(cosCredentialIbm);
    }

    if (obj.containsKey("cos.api.key")) {
        String cosApiKey = obj.getString("cos.api.key");
        builder.cosApiKey(cosApiKey);
    }

    if (obj.containsKey("cos.srvinst.id")) {
        String cosSrvinstId = obj.getString("cos.srvinst.id");
        builder.cosSrvInstId(cosSrvinstId);
    }

    if (obj.containsKey("fhir.tenant")) {
        String fhirTenant = obj.getString("fhir.tenant");
        builder.fhirTenant(fhirTenant);
    }

    if (obj.containsKey("fhir.datastoreid")) {
        String fhirDataStoreId = obj.getString("fhir.datastoreid");
        builder.fhirDataStoreId(fhirDataStoreId);
    }

    if (obj.containsKey("cos.bucket.pathprefix")) {
        String cosBucketPathPrefix = obj.getString("cos.bucket.pathprefix");
        builder.cosBucketPathPrefix(cosBucketPathPrefix);
    }

    if (obj.containsKey("fhir.typeFilters")) {
        String fhirTypeFilters = obj.getString("fhir.typeFilters");
        builder.fhirTypeFilters(fhirTypeFilters);
    }

    if (obj.containsKey("fhir.search.patientgroupid")) {
        String fhirPatientGroupId = obj.getString("fhir.search.patientgroupid");
        builder.fhirPatientGroupId(fhirPatientGroupId);
    }

    if (obj.containsKey("fhir.dataSourcesInfo")) {
        String dataSourcesInfo = obj.getString("fhir.dataSourcesInfo");
        // Base64 at this point, and we just dump it into an intermediate value until it's needed.
        builder.fhirDataSourcesInfo(parseInputsFromString(dataSourcesInfo));
    }

    if (obj.containsKey("import.fhir.storagetype")) {
        String storageType = obj.getString("import.fhir.storagetype");
        builder.fhirStorageType(new StorageDetail(storageType, Collections.emptyList()));
    }
}
 
Example 16
Source File: HFCAAffiliation.java    From fabric-sdk-java with Apache License 2.0 4 votes vote down vote up
HFCAAffiliationResp getResponse(JsonObject result) {
    if (result.containsKey("name")) {
        this.name = result.getString("name");
    }
    return new HFCAAffiliationResp(result);
}
 
Example 17
Source File: ExecutionDynamicTest.java    From microprofile-graphql with Apache License 2.0 4 votes vote down vote up
private JsonPatchBuilder remove(JsonPatchBuilder emptyJsonErrorPatchBuilder,JsonObject errorJsonObject, String key){
    if(errorJsonObject.containsKey(key)){
        emptyJsonErrorPatchBuilder = emptyJsonErrorPatchBuilder.remove("/" + key);
    }
    return emptyJsonErrorPatchBuilder;
}
 
Example 18
Source File: applianceCommon.java    From fido2 with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Given a JSON string and a search-key, this method looks up the 'key' in
 * the JSON and if found, returns the associated value. Returns NULL in all
 * error conditions.
 *
 * @param jsonstr String containing JSON
 * @param key String containing the search-key
 * @param datatype String containing the data-type of the value-object
 * @return Object containing the value for the specified key if valid; null
 * in all error cases.
 */
public static Object getJsonValue(String jsonstr, String key, String datatype) {
    if (jsonstr == null || jsonstr.isEmpty()) {
        if (key == null || key.isEmpty()) {
            if (datatype == null || datatype.isEmpty()) {
                return null;
            }
        }
    }

    try (JsonReader jsonreader = Json.createReader(new StringReader(jsonstr))) {
        JsonObject json = jsonreader.readObject();

        if (!json.containsKey(key)) {
            strongkeyLogger.log(applianceConstants.APPLIANCE_LOGGER, Level.FINE, "APPL-ERR-1003", "'" + key + "' does not exist in the json");
            return null;
        }

        switch (datatype) {
            case "Boolean":
                return json.getBoolean(key);
            case "Int":
                return json.getInt(key);
            case "Long":
                return json.getJsonNumber(key).longValueExact();
            case "JsonArray":
                return json.getJsonArray(key);
            case "JsonNumber":
                return json.getJsonNumber(key);
            case "JsonObject":
                return json.getJsonObject(key);
            case "JsonString":
                return json.getJsonString(key);
            case "String":
                return json.getString(key);
            default:
                return null;
        }
    } catch (Exception ex) {
        strongkeyLogger.log(applianceConstants.APPLIANCE_LOGGER, Level.WARNING, "APPL-ERR-1000", ex.getLocalizedMessage());
        return null;
    }
}
 
Example 19
Source File: CollaborativeRoomTest.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@Test
public void shouldSaveCommands() {
    //Given
    String msg = "{  \n" +
            "   \"broadcastMessage\":{  \n" +
            "      \"cameraInfos\":{  \n" +
            "         \"target\":{  \n" +
            "            \"x\":0,\n" +
            "            \"y\":0,\n" +
            "            \"z\":0\n" +
            "         },\n" +
            "         \"camPos\":{  \n" +
            "            \"x\":2283.8555345202267,\n" +
            "            \"y\":1742.2368392950543,\n" +
            "            \"z\":306.5925754554133\n" +
            "         },\n" +
            "         \"camOrientation\":{  \n" +
            "            \"x\":-0.16153026619659236,\n" +
            "            \"y\":0.9837903505522302,\n" +
            "            \"z\":0.07787502335635015\n" +
            "         },\n" +
            "         \"layers\":\"create layer\",\n" +
            "         \"colourEditedObjects\":true,\n" +
            "         \"clipping\":\"1\",\n" +
            "         \"explode\":\"3\",\n" +
            "         \"smartPath\":[  \n" +
            "            \"9447-9445-9441\",\n" +
            "            \"9447-9445-9443\",\n" +
            "            \"9447-9445-9444\",\n" +
            "            \"9446\"\n" +
            "         ]\n" +
            "      }\n" +
            "   }\n" +
            "}";


    JsonObject jsObj = Json.createReader(new StringReader(msg)).readObject();
    JsonObject broadcastMessage = jsObj.containsKey("broadcastMessage") ? jsObj.getJsonObject("broadcastMessage") : null;

    JsonObjectBuilder b = Json.createObjectBuilder()
            .add("type", "COLLABORATIVE_COMMANDS")
            .add("key", "key-12545695-7859-458")
            .add("broadcastMessage", broadcastMessage)
            .add("remoteUser", "slave1");


    WebSocketMessage collaborativeMessage = Mockito.spy(new WebSocketMessage(b.build()));

    CollaborativeRoom room = Mockito.spy(new CollaborativeRoom(master));
    //When
    room.addSlave(slave1);
    room.addSlave(slave2);

    JsonObject commands = collaborativeMessage.getJsonObject("broadcastMessage");
    room.saveCommand(commands);
    Assert.assertTrue(room.getCommands().entrySet().size() == 1);
}
 
Example 20
Source File: SKFSServlet.java    From fido2 with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Step-2 or last step of fido authenticator registration process. This
 * method receives the u2f registration response parameters which is
 * processed and the registration result is notified back to the caller.
 *
 * Both preregister and register methods are time linked. Meaning, register
 * should happen with in a certain time limit after the preregister is
 * finished; otherwise, the user session would be invalidated.
 *
 * @param svcinfo
 * @param registration - String The full body for auth purposes
 * @param did - Long value of the domain to service this request

 * @return - A Json in String format. The Json will have 3 key-value pairs;
 * 1. 'Response' : String, with a simple message telling if the process was
 * successful or not. 2. 'Message' : String, with a list of messages that
 * explain the process. 3. 'Error' : String, with error message incase
 * something went wrong. Will be empty if successful.
 */
@POST
@Path("/register")
@Consumes({"application/json"})
@Produces({"application/json"})
public Response register(String input) {

    ServiceInfo svcinfoObj;

    JsonObject inputJson =  skfsCommon.getJsonObjectFromString(input);
    if (inputJson == null) {
        return Response.status(Response.Status.BAD_REQUEST).entity(skfsCommon.getMessageProperty("FIDO-ERR-0014") + " input").build();
    }

    //convert payload to pre reg object
    RegistrationRequest registration = new RegistrationRequest();
    JsonObject svcinfo = inputJson.getJsonObject("svcinfo");
    svcinfoObj = skfsCommon.checkSvcInfo("REST", svcinfo.toString());
    Response svcres = checksvcinfoerror(svcinfoObj);
    if(svcres !=null){
        return svcres;
    }
    JsonObject regpayload = inputJson.getJsonObject("payload");

    if (regpayload.containsKey("metadata")) {
        registration.setMetadata(regpayload.getString("metadata"));
    }

    if (regpayload.containsKey("response")) {
        registration.setResponse(regpayload.getString("response"));
    }

    boolean isAuthorized;
    if (svcinfoObj.getAuthtype().equalsIgnoreCase("password")) {
        try {
            isAuthorized = authorizebean.execute(svcinfoObj.getDid(), svcinfoObj.getSvcusername(), svcinfoObj.getSvcpassword(), skfsConstants.LDAP_ROLE_FIDO);
        } catch (Exception ex) {
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, skfsCommon.getMessageProperty("FIDO-ERR-0003"), ex.getMessage());
            return Response.status(Response.Status.BAD_REQUEST).entity(skfsCommon.getMessageProperty("FIDO-ERR-0003") + ex.getMessage()).build();
        }
        if (!isAuthorized) {
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0033", "");
            return Response.status(Response.Status.UNAUTHORIZED).build();
        }
    } else {
        if (!authRest.execute(svcinfoObj.getDid(), request, registration)) {
            return Response.status(Response.Status.UNAUTHORIZED).build();
        }
    }

    registration.setProtocol(svcinfoObj.getProtocol());
    return u2fHelperBean.register(svcinfoObj.getDid(), registration);
}