public DIDDocument resolveUntrustedDid(DID did, boolean force)
			throws DIDResolveException {
		log.debug("Resolving untrusted DID {}...", did.toString());
		if (resolveHandle != null) {
			DIDDocument doc = resolveHandle.resolve(did);
			if (doc != null)
				return doc;
		}
		DIDBiography bio = resolveDidBiography(did, false, force);
		DIDTransaction tx = null;
		switch (bio.getStatus()) {
		case VALID:
			tx = bio.getTransaction(0);
			break;
		case DEACTIVATED:
			if (bio.size() != 2)
				throw new DIDResolveException("Invalid DID biography, wrong transaction count.");
			tx = bio.getTransaction(0);
			if (tx.getRequest().getOperation() != IDChainRequest.Operation.DEACTIVATE)
				throw new DIDResolveException("Invalid DID biography, wrong status.");
			DIDDocument doc = bio.getTransaction(1).getRequest().getDocument();
			if (doc == null)
				throw new DIDResolveException("Invalid DID biography, invalid trancations.");
			tx = bio.getTransaction(1);
			break;
		case NOT_FOUND:
			return null;
		}
		if (tx.getRequest().getOperation() != IDChainRequest.Operation.CREATE &&
				tx.getRequest().getOperation() != IDChainRequest.Operation.UPDATE &&
				tx.getRequest().getOperation() != IDChainRequest.Operation.TRANSFER)
			throw new DIDResolveException("Invalid ID transaction, unknown operation.");
		// NOTICE: Make a copy from DIDBackend cache.
		// 		   Avoid share same DIDDocument instance between DIDBackend
		//         cache and DIDStore cache.
		DIDDocument doc = tx.getRequest().getDocument().clone();
		DIDMetadata metadata = doc.getMetadata();
		metadata.setTransactionId(tx.getTransactionId());
		metadata.setSignature(doc.getProof().getSignature());
		metadata.setPublishTime(tx.getTimestamp());
		if (bio.getStatus() == DIDBiography.Status.DEACTIVATED)
			metadata.setDeactivated(true);
		return doc;
	}
public DIDDocument resolveUntrustedDid(DID did, boolean force)
			throws DIDResolveException {
		log.debug("Resolving untrusted DID {}...", did.toString());
		if (resolveHandle != null) {
			DIDDocument doc = resolveHandle.resolve(did);
			if (doc != null)
				return doc;
		}
		DIDBiography bio = resolveDidBiography(did, false, force);
		DIDTransaction tx = null;
		switch (bio.getStatus()) {
		case VALID:
			tx = bio.getTransaction(0);
			break;
		case DEACTIVATED:
			if (bio.size() != 2)
				throw new DIDResolveException("Invalid DID biography, wrong transaction count.");
			tx = bio.getTransaction(0);
			if (tx.getRequest().getOperation() != IDChainRequest.Operation.DEACTIVATE)
				throw new DIDResolveException("Invalid DID biography, wrong status.");
			DIDDocument doc = bio.getTransaction(1).getRequest().getDocument();
			if (doc == null)
				throw new DIDResolveException("Invalid DID biography, invalid trancations.");
			tx = bio.getTransaction(1);
			break;
		case NOT_FOUND:
			return null;
		}
		if (tx.getRequest().getOperation() != IDChainRequest.Operation.CREATE &&
				tx.getRequest().getOperation() != IDChainRequest.Operation.UPDATE &&
				tx.getRequest().getOperation() != IDChainRequest.Operation.TRANSFER)
			throw new DIDResolveException("Invalid ID transaction, unknown operation.");
	
	
	
		DIDDocument doc = tx.getRequest().getDocument().clone();
		DIDMetadata metadata = doc.getMetadata();
		metadata.setTransactionId(tx.getTransactionId());
		metadata.setSignature(doc.getProof().getSignature());
		metadata.setPublishTime(tx.getTimestamp());
		if (bio.getStatus() == DIDBiography.Status.DEACTIVATED)
			metadata.setDeactivated(true);
		return doc;
	}
public diddocument resolveuntrusteddid(did did, boolean force) throws didresolveexception { log.debug("resolving untrusted did {}...", did.tostring()); if (resolvehandle != null) { diddocument doc = resolvehandle.resolve(did); if (doc != null) return doc; } didbiography bio = resolvedidbiography(did, false, force); didtransaction tx = null; switch (bio.getstatus()) { case valid: tx = bio.gettransaction(0); break; case deactivated: if (bio.size() != 2) throw new didresolveexception("invalid did biography, wrong transaction count."); tx = bio.gettransaction(0); if (tx.getrequest().getoperation() != idchainrequest.operation.deactivate) throw new didresolveexception("invalid did biography, wrong status."); diddocument doc = bio.gettransaction(1).getrequest().getdocument(); if (doc == null) throw new didresolveexception("invalid did biography, invalid trancations."); tx = bio.gettransaction(1); break; case not_found: return null; } if (tx.getrequest().getoperation() != idchainrequest.operation.create && tx.getrequest().getoperation() != idchainrequest.operation.update && tx.getrequest().getoperation() != idchainrequest.operation.transfer) throw new didresolveexception("invalid id transaction, unknown operation."); diddocument doc = tx.getrequest().getdocument().clone(); didmetadata metadata = doc.getmetadata(); metadata.settransactionid(tx.gettransactionid()); metadata.setsignature(doc.getproof().getsignature()); metadata.setpublishtime(tx.gettimestamp()); if (bio.getstatus() == didbiography.status.deactivated) metadata.setdeactivated(true); return doc; }