SFDC , Customer Java App Integration with Okta

Hi We have the following Use cases. We would like someone to guide us the correct way of achieving this using Okta.

Use case 1

User logs into SFDC and get Authenticated via Okta ( SAML). User open an SFDC opportunity and click a button from there need to get redirected to a custom java application ( configured with Okta using OpenId). From the custom app user want to save some data back to SFDC via SalesForce API , however SFDC need to know the reach and details of the user , so their privileges are managed properly within SFDC. Basically we need to keep the same identification of the user between apps ( both ways) without the need to re-login

Use Case 2

  1. User logs into the custom Java App and get authenticated via Okta. from the App user want to navigate to SFDC at some point of time.

Both apps are using Okta as the Identity provider. SFDC using SAML Assertion and Custom Java App is using OpenId Connect

Can you suggest the correct way of configuring Okta for the above scenarios and any need of custom changes or configurations or code requirement at SFDC and Java App to achieve this seamless flow between application keeping the SSO experience.

That should work OOTB with the Okta Session cookie behaviour:

https://developer.okta.com/docs/guides/session-cookie/overview/