Java Code Examples for javax.json.JsonArray#size()

The following examples show how to use javax.json.JsonArray#size() . 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: WeiboStatus.java    From albert with MIT License 6 votes vote down vote up
public static StatusWapper constructWapperStatus(JsonObject res) throws WeiboException {
	// JsonObject jsonStatus = res.asJsonObject(); // asJsonArray();
	JsonObject jsonStatus = res;
	JsonArray statuses = null;
	try {
		if (!jsonStatus.isNull("statuses")) {
			statuses = jsonStatus.getJsonArray("statuses");
		}
		int size = statuses.size();
		List<WeiboStatus> status = new ArrayList<WeiboStatus>(size);
		for (int i = 0; i < size; i++) {
			status.add(new WeiboStatus(statuses.getJsonObject(i)));
		}
		long previousCursor = jsonStatus.getJsonNumber("previous_cursor").longValue();
		long nextCursor = jsonStatus.getJsonNumber("next_cursor").longValue();
		long totalNumber = jsonStatus.getJsonNumber("total_number").longValue();
		String hasvisible = String.valueOf(jsonStatus.getBoolean("hasvisible"));
		return new StatusWapper(status, previousCursor, nextCursor, totalNumber, hasvisible);
	} catch (JsonException jsone) {
		throw new WeiboException(jsone);
	}
}
 
Example 2
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 3
Source File: GeoJsonReader.java    From geojson with Apache License 2.0 6 votes vote down vote up
private void parsePolygon(final JsonObject feature, final JsonArray coordinates) {
    if (coordinates.size() == 1) {
        createWay(coordinates.getJsonArray(0), true)
            .ifPresent(way -> fillTagsFromFeature(feature, way));
    } else if (coordinates.size() > 1) {
        // create multipolygon
        final Relation multipolygon = new Relation();
        multipolygon.put(TYPE, "multipolygon");
        createWay(coordinates.getJsonArray(0), true)
            .ifPresent(way -> multipolygon.addMember(new RelationMember("outer", way)));

        for (JsonValue interiorRing : coordinates.subList(1, coordinates.size())) {
            createWay(interiorRing.asJsonArray(), true)
                .ifPresent(way -> multipolygon.addMember(new RelationMember("inner", way)));
        }

        fillTagsFromFeature(feature, multipolygon);
        getDataSet().addPrimitive(multipolygon);
    }
}
 
Example 4
Source File: TestConfig.java    From KITE with Apache License 2.0 6 votes vote down vote up
private void initRoomManagerFromPayload() {
  JsonObject payload = readJsonString(this.payload);
  String url = payload.getString("url", null);
  int maxUsersPerRoom = payload.getInt("usersPerRoom", this.tupleSize);
  if (maxUsersPerRoom > 0) {
    roomManager = new RoomManager(url, maxUsersPerRoom);
    List<String> rooms;
    if (payload.getJsonArray("rooms") != null) {
      JsonArray roomArr = payload.getJsonArray("rooms");
      rooms = new ArrayList<>();
      for (int i = 0; i < roomArr.size(); i++) {
        rooms.add(roomArr.getString(i));
      }
      roomManager.setPreconfiguredRooms(rooms);
    }
  }
}
 
Example 5
Source File: GlobalContext.java    From logbook with MIT License 6 votes vote down vote up
/**
 * 保有艦娘を更新します
 *
 * @param data
 */
private static void doShip2(Data data) {
    try {
        JsonArray apidata = data.getJsonObject().getJsonArray("api_data");
        // 情報を破棄
        ShipContext.get().clear();
        for (int i = 0; i < apidata.size(); i++) {
            ShipDto ship = new ShipDto((JsonObject) apidata.get(i));
            ShipContext.get().put(Long.valueOf(ship.getId()), ship);
        }
        // 艦隊を設定
        doDeck(data.getJsonObject().getJsonArray("api_data_deck"));

        addConsole("保有艦娘情報を更新しました");
    } catch (Exception e) {
        LoggerHolder.LOG.warn("保有艦娘を更新しますに失敗しました", e);
        LoggerHolder.LOG.warn(data);
    }
}
 
Example 6
Source File: NvdParser.java    From dependency-track with Apache License 2.0 6 votes vote down vote up
private List<VulnerableSoftware> parseCpes(final QueryManager qm, final JsonObject node, final Vulnerability vulnerability) {
    final List<VulnerableSoftware> vsList = new ArrayList<>();
    if (node.containsKey("cpe_match")) {
        final JsonArray cpeMatches = node.getJsonArray("cpe_match");
        for (int k = 0; k < cpeMatches.size(); k++) {
            final JsonObject cpeMatch = cpeMatches.getJsonObject(k);
            if (cpeMatch.getBoolean("vulnerable", true)) { // only parse the CPEs marked as vulnerable
                final VulnerableSoftware vs = generateVulnerableSoftware(qm, cpeMatch, vulnerability);
                if (vs != null) {
                    vsList.add(vs);
                }
            }
        }
    }
    return vsList;
}
 
Example 7
Source File: JsonArrays.java    From diirt with MIT License 5 votes vote down vote up
/**
 * Converts the given numeric JSON array to a ListInt.
 *
 * @param array an array of numbers
 * @return a new ListInt
 */
public static ListInt toListInt(JsonArray array) {
    int[] values = new int[array.size()];
    for (int i = 0; i < values.length; i++) {
        values[i] = (int) array.getJsonNumber(i).intValue();
    }
    return new ArrayInt(values);
}
 
Example 8
Source File: JSONContentHandler.java    From jcypher with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getColumns() {
	if (this.columns == null) {
		List<String> colmns = new ArrayList<String>();
		JsonArray cols = ((JsonObject)this.jsonResult.getJsonArray("results").get(
				this.queryIndex)).getJsonArray("columns");
		int sz = cols.size();
		for (int i = 0;i < sz; i++) {
			colmns.add(cols.getString(i));
		}
		this.columns = colmns;
	}
	return this.columns;
}
 
Example 9
Source File: HFCAAffiliation.java    From fabric-sdk-java with Apache License 2.0 5 votes vote down vote up
private void generateResponse(JsonObject result) {
    if (result.containsKey("name")) {
        this.name = result.getString("name");
    }
    if (result.containsKey("affiliations")) {
        JsonArray affiliations = result.getJsonArray("affiliations");
        if (affiliations != null && !affiliations.isEmpty()) {
            for (int i = 0; i < affiliations.size(); i++) {
                JsonObject aff = affiliations.getJsonObject(i);
                this.childHFCAAffiliations.add(new HFCAAffiliation(aff));
            }
        }
    }
    if (result.containsKey("identities")) {
          JsonArray ids = result.getJsonArray("identities");
          if (ids != null && !ids.isEmpty()) {
              for (int i = 0; i < ids.size(); i++) {
                  JsonObject id = ids.getJsonObject(i);
                  HFCAIdentity hfcaID = new HFCAIdentity(id);
                  this.identities.add(hfcaID);
              }
          }
    }
}
 
Example 10
Source File: WebauthnService.java    From fido2 with GNU Lesser General Public License v2.1 5 votes vote down vote up
@POST
@Path("/" + Constants.RP_PATH_DELETEACCOUNT)
@Produces({MediaType.APPLICATION_JSON})
public Response deleteAccount() {
    try {
        HttpSession session = request.getSession(false);
        if (session == null) {
            POCLogger.logp(Level.SEVERE, CLASSNAME, "deleteAccount", "POC-WS-ERR-1003", "");
            return generateResponse(Response.Status.FORBIDDEN, POCLogger.getMessageProperty("POC-WS-ERR-1003"));
        }

        String username = (String) session.getAttribute(Constants.SESSION_USERNAME);
        Boolean isAuthenticated = (Boolean) session.getAttribute(Constants.SESSION_ISAUTHENTICATED);
        if (isAuthenticated) {
            userdatabase.deleteUser(username);
            String SKFSResponse = SKFSClient.getKeys(username);
            JsonArray keyIds = getKeyIdsFromSKFSResponse(SKFSResponse);
            System.out.println(keyIds);
            for (int keyIndex = 0; keyIndex < keyIds.size(); keyIndex++) {
                SKFSClient.deregisterKey(keyIds.getJsonObject(keyIndex).getString(Constants.SKFS_RESPONSE_JSON_KEY_RANDOMID));
            }
            session.invalidate();
            return generateResponse(Response.Status.OK, "Success");
        } else {
            POCLogger.logp(Level.SEVERE, CLASSNAME, "deleteAccount", "POC-WS-ERR-1002", username);
            return generateResponse(Response.Status.CONFLICT, POCLogger.getMessageProperty("POC-WS-ERR-1002"));
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        POCLogger.logp(Level.SEVERE, CLASSNAME, "deleteAccount", "POC-WS-ERR-1000", ex.getLocalizedMessage());
        return generateResponse(Response.Status.INTERNAL_SERVER_ERROR,
                POCLogger.getMessageProperty("POC-WS-ERR-1000"));
    }
}
 
Example 11
Source File: UserDefinedMetrics.java    From mysql_perf_analyzer with Apache License 2.0 5 votes vote down vote up
public static UserDefinedMetrics createFromJson(java.io.InputStream in)
{
	JsonReader jsonReader = null;
	UserDefinedMetrics udm = null;
	try
	{
		jsonReader = javax.json.Json.createReader(in);
		JsonObject jsonObject = jsonReader.readObject();
		jsonReader.close();
		udm = new UserDefinedMetrics(jsonObject.getString("groupName"));
		udm.setAuto("y".equalsIgnoreCase(jsonObject.getString("auto", null)));
		udm.setStoreInCommonTable("y".equalsIgnoreCase(jsonObject.getString("storeInCommonTable", null)));
		udm.setSource(jsonObject.getString("source"));
		udm.setUdmType(jsonObject.getString("type"));
		udm.setNameCol(jsonObject.getString("nameColumn", null));
		udm.setValueCol(jsonObject.getString("valueColumn", null));
		udm.setKeyCol(jsonObject.getString("keyColumn", null));
		udm.setSql(jsonObject.getString("sql", null));
		
		JsonArray metrics = jsonObject.getJsonArray("metrics");
		if(metrics != null )
		{
			int mlen = metrics.size();
			for(int i=0; i<mlen; i++)
			{
				JsonObject mobj = metrics.getJsonObject(i);
				udm.addmetric(mobj.getString("name"), 
						mobj.getString("sourceName"), 
						"y".equalsIgnoreCase(mobj.getString("inc")),
						Metric.strToMetricDataType(mobj.getString("dataType")));
			}
		}
	}catch(Exception ex)
	{
		logger.log(Level.WARNING, "Error to parse UDM", ex);
		//TODO
	}
	return udm;
}
 
Example 12
Source File: JsonArrays.java    From diirt with MIT License 5 votes vote down vote up
/**
 * Converts the given numeric JSON array to a ListShort.
 *
 * @param array an array of numbers
 * @return a new ListShort
 */
public static ListShort toListShort(JsonArray array) {
    short[] values = new short[array.size()];
    for (int i = 0; i < values.length; i++) {
        values[i] = (short) array.getJsonNumber(i).intValue();
    }
    return new ArrayShort(values);
}
 
Example 13
Source File: CadfReporterStep.java    From FHIR with Apache License 2.0 5 votes vote down vote up
public static CadfReporterStep parse(JsonObject jsonObject)
        throws FHIRException, IOException, ClassNotFoundException {
    CadfReporterStep.Builder builder =
            CadfReporterStep.builder();

    if (jsonObject.get("reporter") != null) {
        JsonObject reporter = jsonObject.getJsonObject("reporter");
        CadfResource resource = CadfResource.Parser.parse(reporter);
        builder.reporter(resource);
    }

    if (jsonObject.get("reporterId") != null) {
        String reporterId = jsonObject.getString("reporterId");
        builder.reporterId(reporterId);
    }

    if (jsonObject.get("reporterTime") != null) {
        String rTime = jsonObject.getString("reporterTime");
        TemporalAccessor reporterTime = DATE_TIME_PARSER_FORMATTER.parse(rTime);
        builder.reporterTime(ZonedDateTime.from(reporterTime));
    }

    if (jsonObject.get("role") != null) {
        String role = jsonObject.getString("role");
        builder.role(ReporterRole.valueOf(role));
    }

    if (jsonObject.get("attachments") != null) {
        JsonArray annotations = jsonObject.getJsonArray("attachments");
        for (int i = 0; i < annotations.size(); i++) {
            JsonObject obj = (JsonObject) annotations.get(0);
            CadfAttachment item = CadfAttachment.Parser.parse(obj);
            builder.attachment(item);
        }
    }

    return builder.build();
}
 
Example 14
Source File: PhmmerJob.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
public PhmmerResults runJob() throws IOException {
  JsonObject response = client.getResults(database, sequence);
  JsonObject results = response.getJsonObject("results");
  JsonArray hits = results.getJsonArray("hits");

  PhmmerResults phmmer = new PhmmerResults(hits.size());
  for (int i = 0; i < hits.size(); ++i) {
    Alignment a = new Alignment(hits.getJsonObject(i));
    phmmer.addAlignment(a);
  }
  return phmmer;
}
 
Example 15
Source File: JSONManyAssociationState.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
private int indexOfReference( String entityIdentityAsString )
{
    JsonArray references = getReferences();
    for( int idx = 0; idx < references.size(); idx++ )
    {
        if( entityIdentityAsString.equals( references.getString( idx, null ) ) )
        {
            return idx;
        }
    }
    return -1;
}
 
Example 16
Source File: EmployeeJSONReader.java    From journaldev with MIT License 4 votes vote down vote up
public static void main(String[] args) throws IOException {
	InputStream fis = new FileInputStream(JSON_FILE);
	
	//create JsonReader object
	JsonReader jsonReader = Json.createReader(fis);
	
	/**
	 * We can create JsonReader from Factory also
	JsonReaderFactory factory = Json.createReaderFactory(null);
	jsonReader = factory.createReader(fis);
	*/
	
	//get JsonObject from JsonReader
	JsonObject jsonObject = jsonReader.readObject();
	
	//we can close IO resource and JsonReader now
	jsonReader.close();
	fis.close();
	
	//Retrieve data from JsonObject and create Employee bean
	Employee emp = new Employee();
	
	emp.setId(jsonObject.getInt("id"));
	emp.setName(jsonObject.getString("name"));
	emp.setPermanent(jsonObject.getBoolean("permanent"));
	emp.setRole(jsonObject.getString("role"));
	
	//reading arrays from json
	JsonArray jsonArray = jsonObject.getJsonArray("phoneNumbers");
	long[] numbers = new long[jsonArray.size()];
	int index = 0;
	for(JsonValue value : jsonArray){
		numbers[index++] = Long.parseLong(value.toString());
	}
	emp.setPhoneNumbers(numbers);
	
	//reading inner object from json object
	JsonObject innerJsonObject = jsonObject.getJsonObject("address");
	Address address = new Address();
	address.setStreet(innerJsonObject.getString("street"));
	address.setCity(innerJsonObject.getString("city"));
	address.setZipcode(innerJsonObject.getInt("zipcode"));
	emp.setAddress(address);
	
	//print employee bean information
	System.out.println(emp);
	
}
 
Example 17
Source File: DataHandler.java    From javametrics with Apache License 2.0 4 votes vote down vote up
@Override
public void processData(List<String> jsonData) {
    for (Iterator<String> iterator = jsonData.iterator(); iterator.hasNext();) {
        String jsonStr = iterator.next();
        JsonReader jsonReader = Json.createReader(new StringReader(jsonStr));
        try {
            JsonObject jsonObject = jsonReader.readObject();
            String topicName = jsonObject.getString("topic", null);
            JsonObject payload;
            if (topicName != null) {
                switch (topicName) {
                  case "http":
                     payload = jsonObject.getJsonObject("payload");
                     long requestTime = payload.getJsonNumber("time").longValue();
                     long requestDuration = payload.getJsonNumber("duration").longValue();
                     String requestUrl = payload.getString("url", "");
                     String requestMethod = payload.getString("method", "");

                     synchronized (aggregateHttpData) {
                         aggregateHttpData.aggregate(requestTime, requestDuration, requestUrl, requestMethod);
                     }
                     break;
                  case "cpu":
                     payload = jsonObject.getJsonObject("payload");
                     latestCPUEventProcess = payload.getJsonNumber("process").doubleValue();
                     latestCPUEventSystem = payload.getJsonNumber("system").doubleValue();
                     latestCPUEventProcessMean = payload.getJsonNumber("processMean").doubleValue();
                     latestCPUEventSystemMean = payload.getJsonNumber("systemMean").doubleValue();
                     break;
                  case "memoryPools":
                     payload = jsonObject.getJsonObject("payload");
                     latestMemEventUsedHeapAfterGC =  payload.getJsonNumber("usedHeapAfterGC").longValue();
                     latestMemEventUsedHeapAfterGCMax =  payload.getJsonNumber("usedHeapAfterGCMax").longValue();
                     latestMemEventUsedHeap =  payload.getJsonNumber("usedHeap").longValue();
                     latestMemEventUsedNative =  payload.getJsonNumber("usedNative").longValue();
                     latestMemEventUsedNativeMax =  payload.getJsonNumber("usedNativeMax").longValue();
                     break;
                  case "gc":
                     payload = jsonObject.getJsonObject("payload");
                     latestGCEventGCTime = payload.getJsonNumber("gcTime").doubleValue();
                     break;
                  case "env":
                     JsonArray envPayload = jsonObject.getJsonArray("payload");
                     for (int i=0; i < envPayload.size(); i++) {
                         JsonObject envar = envPayload.getJsonObject(i);
                         String param = envar.getJsonString("Parameter").getString();
                         String value = envar.getJsonString("Value").getString();
                         latestEnvMap.put(param, value);
                     }
                     break;
                  default:
                    // ignore and move on
                }
            }
        } catch (JsonException je) {
            // Skip this object, log the exception and keep trying with
            // the rest of the list
            je.printStackTrace();
        }
    }
}
 
Example 18
Source File: GlobalContext.java    From logbook with MIT License 4 votes vote down vote up
/**
 * 建造(入手)情報を更新します
 * @param data
 */
private static void doGetship(Data data) {
    try {
        JsonObject apidata = data.getJsonObject().getJsonObject("api_data");
        String dock = data.getField("api_kdock_id");

        // 艦娘の装備を追加します
        if (!apidata.isNull("api_slotitem")) {
            JsonArray slotitem = apidata.getJsonArray("api_slotitem");
            for (int i = 0; i < slotitem.size(); i++) {
                JsonObject object = (JsonObject) slotitem.get(i);
                int typeid = object.getJsonNumber("api_slotitem_id").intValue();
                Long id = object.getJsonNumber("api_id").longValue();
                ItemDto item = Item.get(typeid);
                if (item != null) {
                    ItemContext.get().put(id, item);
                }
            }
        }
        // 艦娘を追加します
        JsonObject apiShip = apidata.getJsonObject("api_ship");
        ShipDto ship = new ShipDto(apiShip);
        ShipContext.get().put(Long.valueOf(ship.getId()), ship);
        // 投入資源を取得する
        ResourceDto resource = getShipResource.get(dock);
        if (resource == null) {
            resource = KdockConfig.load(dock);
        }
        GetShipDto dto = new GetShipDto(ship, resource);
        getShipList.add(dto);
        CreateReportLogic.storeCreateShipReport(dto);
        // 投入資源を除去する
        getShipResource.remove(dock);
        KdockConfig.remove(dock);

        addConsole("建造(入手)情報を更新しました");
    } catch (Exception e) {
        LoggerHolder.LOG.warn("建造(入手)情報を更新しますに失敗しました", e);
        LoggerHolder.LOG.warn(data);
    }
}
 
Example 19
Source File: Alignment.java    From BioSolr with Apache License 2.0 4 votes vote down vote up
public Alignment(JsonObject hit) {
  target = hit.getString("acc");
  species = hit.getString("species");
  description = hit.getString("desc");
  score = Double.parseDouble(hit.getString("score"));
  eValue = Double.parseDouble(hit.getString("evalue"));

  JsonArray domains = hit.getJsonArray("domains");
  for (int i = 0; i < domains.size(); ++i) {
    JsonObject domain = domains.getJsonObject(i);
    
    // skip insignificant matches (by ind. eValue)
    eValueInd = Double.parseDouble(domain.getString("ievalue"));
    if (eValueInd >= SIGNIFICANCE_THRESHOLD) continue;
    
    eValueCond = Double.parseDouble(domain.getString("cevalue"));
    
    querySequence = domain.getString("alimodel");
    querySequenceStart = domain.getInt("alihmmfrom");
    querySequenceEnd = domain.getInt("alihmmto");
    
    match = domain.getString("alimline");
    
    targetSequence = domain.getString("aliaseq");
    targetSequenceStart = domain.getInt("alisqfrom");
    targetSequenceEnd = domain.getInt("alisqto");
    
    targetEnvelopeStart = domain.getInt("ienv");
    targetEnvelopeEnd = domain.getInt("jenv");
    
    posteriorProbability = domain.getString("alippline");
    
    bias = Double.parseDouble(domain.getString("bias"));
    accuracy = Double.parseDouble(domain.getString("oasc"));
    bitScore = domain.getJsonNumber("bitscore").doubleValue();
    
    identityPercent = 100 * domain.getJsonNumber("aliId").doubleValue();
    identityCount = domain.getInt("aliIdCount");
    
    similarityPercent = 100 * domain.getJsonNumber("aliSim").doubleValue();
    similarityCount = domain.getInt("aliSimCount");
    
    // we consider only the first significant match
    break;
  }
}
 
Example 20
Source File: AndroidSafetynetAttestationStatement.java    From fido2 with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Boolean verifySignature(String browserDataBase64, FIDO2AuthenticatorData authData) {
    try {
        //Verify JWT timestamp is valid
        JsonNumber timestampMs = jwt.getBody().getJsonNumber("timestampMs");
        Date now = new Date();
        if (timestampMs == null //timestampMS is missing
                || timestampMs.longValue() > now.getTime() + (30 * 1000)        //timestampMS is in the future (some hardcoded buffer)  (TODO fix hardcode)
                || timestampMs.longValue() < now.getTime() - (60 * 1000)) {     //timestampMS is older than 1 minute
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0015",
                    "JWT time stamp = " + timestampMs.longValue() + ", current time = " + now.getTime());
            throw new IllegalArgumentException("JWT has invalid timestampMs");
        }

        //Verify JWT certificate chain
        JsonArray x5c = jwt.getHeader().getJsonArray("x5c");
        if (x5c == null || x5c.isEmpty()) {
            throw new IllegalArgumentException("JWT missing x5c information");
        }
        if (x5c.size() < 2) {
            throw new IllegalArgumentException("JWT missing certificate chain");
        }
        CertificateFactory certFactory = CertificateFactory.getInstance("X.509", "BCFIPS");
        Base64.Decoder decoder = Base64.getDecoder();
        List<X509Certificate> certchain = new ArrayList<>();
        X509Certificate rootCert = null;
        for (int i = 0; i < x5c.size(); i++) {
            byte[] certBytes = decoder.decode(x5c.getString(i, null));
            ByteArrayInputStream instr = new ByteArrayInputStream(certBytes);
            X509Certificate certificate = (X509Certificate) certFactory.generateCertificate(instr);
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.FINE, "FIDO-MSG-2001",
                "certificate number " + i + " = " + certificate);
            if(i == x5c.size() - 1){
                rootCert = certificate;
            }
            else{
                certchain.add(certificate);
            }
        }
        if(rootCert == null){
            throw new IllegalArgumentException("JWT missing certificate chain root");
        }
        Set<TrustAnchor> trustAnchor = new HashSet<>();
        trustAnchor.add(new TrustAnchor(rootCert, null));
        CertPath certPath = CertificateFactory.getInstance("X.509", "BCFIPS").generateCertPath(certchain);
        if(!PKIXChainValidation.pkixvalidate(certPath, trustAnchor, false, false)){     //TODO check CRLs if they exist, otherwise don't
            throw new IllegalArgumentException("JWT failed PKIX validation");
        }

        //Verify JWT signature
        if (!jwt.verifySignature(certchain.get(0).getPublicKey())) {
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0015",
                    "JWT Signature verification failed!");
            return false;
        }

        //Verify that response is a valid SafetyNet response of version ver.
        if(version == null || version.isEmpty()){
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0015",
                    "AndroidSafetynet missing version information");
            return false;
        }

        //Verify that the nonce in the response is identical to the SHA-256 hash of the concatenation of authenticatorData and clientDataHash.
        String nonce = jwt.getBody().getString("nonce", null);
        if(nonce == null || !Arrays.equals(decoder.decode(nonce), skfsCommon.getDigestBytes(concatenateArrays(authData.getAuthDataDecoded(),
                skfsCommon.getDigestBytes(Base64.getDecoder().decode(browserDataBase64), "SHA256")), "SHA256"))){
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0015",
                    "JWT has incorrect nonce");
            return false;
        }

        //Verify that the attestation certificate is issued to the hostname "attest.android.com" (see SafetyNet online documentation).
        String cn = getFirstCN(certchain.get(0).getSubjectDN().getName());
        if(cn == null || !cn.equals("attest.android.com")){
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0015",
                    "JWT attestation certificate does not match the specification");
            return false;
        }

        //Verify that the ctsProfileMatch attribute in the payload of response is true.
        if(!jwt.getBody().getBoolean("ctsProfileMatch", false)){
            skfsLogger.log(skfsConstants.SKFE_LOGGER, Level.SEVERE, "FIDO-ERR-0015",
                    "JWT attestation ctsProfileMatch does not match the specification");
            return false;
        }

        return true;
    } catch (UnsupportedEncodingException | CertificateException | NoSuchAlgorithmException | NoSuchProviderException ex) {
        Logger.getLogger(AndroidSafetynetAttestationStatement.class.getName()).log(Level.SEVERE, null, ex);
    }

    return Boolean.FALSE;
}