Exporting GSSCredential to byte array and vice versa - gssapi

I am implementing S4U protocol using GSS in java. Since java 7 does not support this protocol, I plan to write a JNI wrapper over the gss api methods in C that do not have equivalent in java.
As part of this I am writing a JNI over gss_acquire_cred_impersonate_name as described in
http://k5wiki.kerberos.org/wiki/Projects/Services4User#gss_acquire_cred_impersonate_name .
This method takes an previously populated input credential handle (gss_cred_id_t) and populates an output credential handle. In my java code I have a GSSCredential created which I need to pass to C function in form of gss_cred_id_t and convert the output credential handle from gss_cred_id_t back to GSSCredential for further use.
How can I export GSSCredential object to byte array and vice versa in order to communicate with the C function ?
Thanks

You should rather Java 8 code, it has built-in support.
Export cred us a custom extension for GSS-API and therefore not available. The Globus JGSS implementation support this extension.

When I had a similar problem I used https://github.com/cconlon/kerberos-java-gssapi and did all my GSS-API work though the wrapper. (But that was only a temporary stage before discarding Java altogether.)

Related

How to integrate gRPC with karate [duplicate]

We have a requirement where we need to send .avro file as an input request to our API's. Really stuck at this point. If any detail example provided would be more appreciated.
Just use Java interop: https://github.com/intuit/karate#calling-java
You need to write a helper (start with a static method) to convert JSON to Avro and vice versa. I know teams using this for gRPC. Read this thread for tips: https://github.com/intuit/karate/issues/412
Also there is even a "karate-grpc" project: https://github.com/pecker-io/karate-grpc
Also see:
https://twitter.com/KarateDSL/status/1128170638223364097
https://twitter.com/KarateDSL/status/1417023536082812935

Mock real gRPC server responses

We have a microservice that needs to be integration tested (real calls, but no network communication with anything outside of the test namespace in kubernetes) in our pipeline. It also relies on an external gRPC server which we have no control over.
Above is a picture of what we'd like to have happen. The white box on the left is code that provides the Microservice Boundary with 'external' data. It then keeps calling the Code via REST until it gets back the proper number of records or it times out. The Code pulls records from an internal database, as well as data associated to those records from a gRPC call. Since we do not own the gRPC service, but are doing integration tests, we need a few pre-defined responses to the two gRPC services we call (blue box).
Since our integration tests are self-contained right now, and we don't want to write an entirely new actual gRPC server implementation just to mimick calls, is there a way to stand up a real gRPC server and configure it to return responses? The request is pretty much like a mock setup, except with an actual server.
We need to be able to:
give the server multiple proto files to interpret and have it expose those as endpoints. Proto files must be able to have different package names
using files we can store in source control, configure the responses to each call
able to run in a linux docker container (no windows)
I did find gripmock which seemed almost exactly what we need, but it only serves one proto file per container. It supposedly can serve more than one, but I can't get it to work and their example that serves two files implies each proto file must have the same package name which will likely never happen with our scenarios. In the meantime we are using it, but if we have 10 gRPC call dependencies, we now have to run 10 gripmock servers.
Wikipedia contains a list of API mocking tools. Looking at that list today there is a commercial tool that supports gRPC called Traffic Parrot which allows you to create gRPC mocks based on your Proto files. You can give it multiple proto files, store the mocks in Git and run the tool in Docker.
There are also open-source tools like GripMock but it does not generate stubs based on Proto files, you have to create them manually. Also, the project up to today was not keeping up to date with Proto and gRPC developments i.e. the package name issue you have discovered yourself above (works only if the package names in different proto files are the same). There are a few other open-source tools like grpc-wiremock, grpc-mock or bloomrpc-mock but they still lack widespread adoption and hence might be risky to adopt for an important enterprise project.
Keep in mind, the mock generated will be only a test double, it will not replicate the full behaviour of the system the Proto file corresponds to. If you wanted to also replicate partially the semantics of the messages consider doing a recording of the gRPC messages to create the mocks, that way you can see the sample data as well.
Take a look at this JS library which hopefully does what you need:
https://github.com/alenon/grpc-mock-server
Usage example:
private static readonly PROTO_PATH: string = __dirname + "example.proto";
private static readonly PKG_NAME: string = "com.alenon.example";
private static readonly SERVICE_NAME: string = "ExampleService";
...
const implementations = {
ex1: (call: any, callback: any) => {
const response: any =
new this.proto.ExampleResponse.constructor({msg: "the response message"});
callback(null, response);
},
};
this.server.addService(PROTO_PATH, PKG_NAME, SERVICE_NAME, implementations);
this.server.start();

How to connect Adobe Captivate XApi course with YetAnalytics or LRS (Learning record system)?

I am trying to connect my Adobe Captivate XApi course to the LRS (YetAnalytics). I have very less information as to what should i add in this code of tc-onfig.js in the course files:
// Pre-configured LRSes that should receive data, added to what is included
// in the URL and/or passed to the constructor function.
//
// An array of objects where each object may have the following properties:
//
// endpoint: (including trailing slash '/')
// auth:
// allowFail: (boolean, default true)
// version: (string, defaults to high version supported by TinCanJS)
//
TC_RECORD_STORES = [
{
endpoint : "",
auth : "",
allowFail: ,
version: "",
}
];
Generally you should avoid using that functionality. That code is leveraged by an underlying library in Captivate (Rustici Driver) for packages with a tincan.xml file. That package will be launched with an LRS endpoint and authentication credential which is where it will send the statements that it generates. Generally it is a much better idea to send all statements to that configured LRS and then figure out a way to get those statements either forwarded from or pulled from that LRS into your additional LRS(s).
This is for two main reasons. First by using this functionality you have to hard code a credential into the package which makes it insecure and indistinguishable during requests, this is generally just bad. Second, there is little to no error handling around calls that leverage this functionality, so if you set allowFail to false exceptions will go uncaptured and the content will likely behave in strange ways (or break completely), if you set allowFail to true then you will have no recourse when a call fails and you potentially will not know that you've lost data.
(Unfortunately, I know this because I implemented the functionality originally a very long time ago before fully understanding all of the ramifications.)
But just so I've answered your actual question, if you wish to not heed my advice, then the values that should go there will be passed through to the constructor for a TinCan.LRS object which is documented here: http://rusticisoftware.github.io/TinCanJS/doc/api/latest/classes/TinCan.LRS.html
The auth being the most tricky, it should be a value that is a full Authorization header value as needed to connect to the LRS, very often a Basic Auth header.

Is there a way to get GraphML representation of an in-memory TinkerGraph without writing to file?

I have an in-memory TinkerGraph. I want to write a Spring Boot REST controller to expose a serialized (as GraphML) representation of this Tinkergraph. The serialization APIs (g.io) needs a String filepath to be passed to it. Currently I am having to write to a /tmp file and then read the file to get a String representation of the serialized GraphML.
Is there a way to directly get a String output of the serialized GraphML? Without having to write into a tmp file and read it back in?
g.io("graph.xml").write().iterate()
As of the current latest release 3.4.2, I'm afraid that there is no way to do it with the Gremlin language. The reason it only writes to a file and not to something like an Java OutputStream is that the io() step is meant to be programming language agnostic. Python and other languages off the JVM have no way to construct or specify such an object so writing to file makes it work across the board. I don't know if that will change in the future, unless we came up with a reasonable API that would work intuitively across programming languages.
Since you are using an in-memory TinkerGraph you could bypass Gremlin and got back to the very old way of doing things:
Graph graph = TinkerFactory.createModern();
try (OutputStream os = new FileOutputStream("tinkerpop-modern.xml")) {
graph.io(IoCore.graphml()).writer().normalize(true).create().writeGraph(os, graph);
}
You would just replace the FileOutputStream with whatever kind of OutputStream you wanted to use. This approach uses the old Graph API which I think is just deprecated in newer versions, so the option should still be available to you. Note that if you are not on the JVM the only way to do return a String would be by submitting a Gremlin script to Gremlin Server.

Stonestreet One's Bluetopia how do you request a MTU change?

Or more specifically how do you request an MTU change when operating at the "Platform Manager" level?
More details
I'm using the sample program LinuxGATM_CLT which acts as a GATT client and it uses the Bluetopia Platform Manager Framework.
I'm using TI's WL183xMOD WiLink hardware which uses Bluetopia (previously owned by Stonestreet One).
The API call exists
The function exists, but seems to be at stack layer lower than the PM:
~/src/ti_bluetopia/ $ grep GATT_Exchange_MTU_Request ./BluetopiaPM/Bluetopia/include/GATTAPI.h
BTPSAPI_DECLARATION int BTPSAPI GATT_Exchange_MTU_Request(unsigned int BluetoothStackID, unsigned int ConnectionID, Word_t RequestedMTU, GATT_Client_Event_Callback_t ClientEventCallback, unsigned long CallbackParameter);
But its not callable from the "Platform Manager" level
Everything within BluetopiaPM/sample/LinuxGATM/LinuxGATM_CLT.c uses GATM functions from BluetopiaPM/include/client/GATMAPI.h
It feels like the GATT_Exchange_MTU_Request() function has not been exposed at the PM level. Its hard to dig deeper into how the PM works because they only ship binaries (doesn't seem to be open-source). For example the only match is the GATTAPI.h header file and a binary library file:
~/src/ti_bluetopia/ $ grep -ri GATT_Initialize ./
Binary file ./BluetopiaPM/Bluetopia/lib/libSS1BTGAT.a matches
I feel like the solution is to find methods to report my current Platform Manager BluetoothStackID, ConnectionID, and callback parameters so that I can call the GATT_Exchange_MTU_Request() function directly.
In short, the workaround is to get an earlier version of Stonestreet One's Bluetopia, before they created the "Platform Manager". These earlier versions (suchas 4.012 and 4.013) don't have the advantage of the Platform Manager, but they do allow you to have more control, operating at a lower level where you can call:
GATT_Initialize() and
GATT_Exchange_MTU_Request()
One good example is 4.013's SPPLEDemo.c which calls the above-mentioned methods.

Resources