How Can I Ensure That Only A Specific Party Issues A State? - corda

I have a flow where only a specific party can be the issuer.
e.g. a bank issuing cash on to the ledger.
The works when the "bank" is issuing, but it also works when someone else runs it too.
How do I make sure that only one specific party can issue a state from this flow?
Is the only way to hard code the CordaX500Name in the flow? - assuming that you know in advance what the correct values for that are going to be in production.

Hardcoding the x500Name could work or just searching for the party when you run the code.
Something like a contract rule to ensure a specific party is the issuer wouldn't be too difficult to do.
I think I'd check my OWN party's name in the contract code and that could be a hardcoded if statement on the string name.

Related

guidance needed for corda Application design

I have a web background majorly with javascript, I have started learning Corda recently for project implementation and need guidance in this regard,
So our application is based on the web, the user signs up with different school name, create question papers, and then want to share either part of it or whole with teachers of some other school in our platform. they can make changes and assign it back to creator and the process goes back and forth, finally signing the paper to be finalized, once finalized it cannot be changed by anyone. I need to store these transactions in Corda application, not sure how to go about it, I did try replicating it using negotiation application in corda/kotlin/sample, but stuck in a bug as I was trying to send a list of objects.
I do have the following questions in mind
Should I use enterprise edition or go with open source as I think I need schema design for this. web db is in postgress
As far as I have seen each node is predefined in the config with username and password,is there a way to create the node while the user signs up.
I have schools and teachers inside the school, do I need a separate node for each school and then create states in each node(not sure if a node can be set up at run time). or do I use the account's library provided for creating the account of each teacher, if yes id there a way to use passwords in it, unable to find password field in it.
how do I send an array of objects to the state, or should I create a separate state for each question, as different questions can be assigned to different teachers, but again multiple questions can be assigned to the same teacher.
These are few questions on my mind any help is much appreciated, as most of the examples gave IOU samples or states with int and string, Please guide me in the right direction.
Alessandro has good advice here, definitely look at the samples repos for inspiration on how to build what you're looking for.
start with open source, it's easier to prototype and you can switch to enterprise later it won't be an issue for you
this depends on design, you wouldn't really want to create a new corda node per-person, you might want to have corda accounts that run on a single node instead. See accounts sdk here: https://github.com/corda/accounts
what you might do is make a corda node for each school and then accounts per teacher like you were already were thinking. That would mean only a couple of nodes based on the number of schools you have.
as long as your state is marked with #CordaSerializable you won't have problems sending arrays of data, I send an array in a state in this sample here: https://github.com/corda/samples-java/blob/master/Advanced/secretsanta-cordapp/contracts/src/main/java/net/corda/samples/secretsanta/states/SantaSessionState.java#L24
https://github.com/corda/samples-java
https://github.com/corda/samples-kotlin

HERE API Calculate Route - avoid anything changes router behavior

Problem
If you choose to use avoidArea, exclueCountries or avoidLinks (and probably some more that I wasn't able to test) in your request router enforces fastest route mode.
Given is route from Poland to Germany.
Official testing client: http://refclient.ext.here.com/
First request (no avoids, no excludes, mode:shortest) was:
https://route.api.here.com/routing/7.2/calculateroute.json?app_code=pxIXqdtgOSwQDXSDfjLQpw&app_id=cgZPrYfgRePXzXC3PbBp&jsonattributes=41&language=en-us&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167
This resulted in a quite straightforward route like below.
If we add now any country exclusion (e.g. GBR, CHE, CZE) the route is now routed via motorways like fastest mode was enforced.
https://route.api.here.com/routing/7.2/calculateroute.json?app_code=pxIXqdtgOSwQDXSDfjLQpw&app_id=cgZPrYfgRePXzXC3PbBp&avoidseasonalclosures=false&excludecountries=CHE,GBR,CZE&jsonattributes=41&language=pl-pl&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh,zo&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167
EDIT 1 BEGIN
I checked out the new routing API and results are similar:
Without avoids:
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey={API_KEY}=41&language=en-us&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167
With avoids:
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey={API_KEY}&avoidseasonalclosures=false&excludecountries=CHE,GBR,CZE&jsonattributes=41&language=pl-pl&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh,zo&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167
On a sidenote, http://refclient.ext.here.com/ doesn't have option to test new API
EDIT 1 END
Question
Why is it happening? Is it designed behavior? If not, when can we expect this to be fixed?
Ok, I've got an answer for you from engineering. I'm rewording a bit so any mistakes/confusion blame me, not him. :)
So yes, the API here is ignoring your request to use shortest.
Quote from developer: Specifically in this case, when using "shortest" mode and requesting additional "avoids", routes more than 300km or so are not "good". It does not fall back to "fastest" mode but another mode where "fastest" route shape has more of an influence.
You mentioned wanting to avoid tolls, be aware that you can ask for that option when calling the API, so that may be a solution for you.
I hope this helps a bit, and thank you for being patient.

Acting on multiple status changes with Nifi Expression Language

I have an "UpdateAttribute" processor that evaluates information in a JSON file. Originally, this would just check if a client had been updated and the statement looked something like this:
${literal(${allAttributes("client_attribute1", "client_attribute2"):equals("UPDATED")}):ifElse("UPDATED","UNCHANGED")}
However, the specifics of the client's status change now needs to be tracked - such that if the client goes from OFFLINE to ONLINE, then their status is "1". If they go from ONLINE to OFFLINE, then their status is "3". This would ideally be done in a single statement. I'm not sure exactly how this would work, any suggestions?
I think it would be better to use UpdateAttribute processor Advanced usage for this case.
Add all your rules you need to check then add the attribute which satisfied your rule.
Refer to this and this links for more details regards to UpdateAttribute Advanced usage.

How does one expose constants in a java google app engine Endpoints API?

Simple question -- how do you expose constants in a java google app engine Endpoints API?
e.g
public static final int CODE_FOO = 3845;
I'd like the client of the Endpoints to be able to match on CODE_FOO rather than on 3845. I'll end up doing enum wrappers (which probably is better anyway) but I'm just starting to be curious if this is even doable? Thx
Note that this isn't a full answer but here is a workaround: in Android Studio, create a very light-weight "common" java project and shove anything you want to keep in sync there such as constants as well as common types that you want exposed (e.g. an enum representing all possible return / error codes, etc).
This way you should get pretty decent compiler-time safety and keep these guys in sync.
Please feel free to comment if anyone has better suggestions.
This is unfortunately a Law of Information (ahem). If you have a message protocol you defined, both sides of the interaction need to be aware of the messages that could be passed. There's no other way for the client to be aware of what it needs to respond to. Ajax libraries hard-code the number "200" to be able to detect a successful request, as one example.
Yes, just use a switch statement on strings inside your client code. Or, you could use a dictionary of strings pointing to functions and just call the function after de-referencing the dictionary given the string you got.

Filtering Data in ASP.NET Web Services

I've been using this site for quite a while, usually being able to sort out my questions by browsing through the questions and following tags. However, I've recently come across a question that is rather hard to lookup amongst the great number of questions asked - a question I hope some of you might be able to share your opinion on.
As my problem is a bit hard to fit into a single line, going in the title, I'll try to give a bit more details on the problem I've encountered. So, as the title says I need to filter, or limit, some of the response data my standard ASP.NET Soap-based Web service returns on invoking various web methods. The web service is used to return data used by other systems (a data repository more or less), where the client today is able to specify a few parameters on how the data should be filtered and in return a full-set of data back.
Well, easy enough I thought, just put additional filtering options on the existing web methods which needs a bit more filtered applied, make adjustments on the server-side and we are all set to go - well, unfortunately it turned out to be a bit more tricky then this.
The problem I am facing is that I'm working on a web service running in a production environment, which needs to be extended in such that additional filters can be applied to existing web method being invoked w/o affecting the calls already being made by other systems used by the customer using their client stubs. This is where I am a bit troubled, since I can't seem to find a "right solution" on extending the current web service.
Today, the filter is send as a custom data structure which holds information on which data should filtered, but I am not sure if I can simply just add more information to this data structure w/o breaking code at the clients? One of my co-workers suggested that I could implement a solution where I would extend the web.config on the server-side to hold a section with details on which data should be excluded (filtered out), but I don't find this to be a viable solution long-sighted - and I don't trust customers with such an option since this is likely to go wrong at some point. So the solution I am looking for is a way that I can apply a "second filter" to the data I am requesting from the client so instead of getting a full-set of data back it should only give a fraction, it implemented in such that the filter can be easily modified and it must not affect the current client calls.
Any suggestions on how I should approach this problem?
Thanks!
Kind regards,
E.
A pretty common practice is to create another instance of the application OR use part of the url to signify the version of the endpoint they are connecting to, perhaps the virtual directory is the date. That way old calls will go to the old API and new calls will come in on the new API.
http://api.example.com/dostuff
vs
http://api.example.com/6-7-2011/dostuff

Resources