Remote authentication using Rest API

This topic has 2 replies, 2 voices, and was last updated 5 years, 6 months ago by mat_sunil.

  • Author
    Posts
  • #15479
     mat_sunil
    Participant

    Hi,

    We are replacing OAM with OpenAM. I saw message that we shouldn’t use Client SDK to do authentication remotely, and instead use Rest APIs. Can anyone point me to some examples to do this in Java for the following use-cases:
    1. Connect to OpenAM for remote authentication and obtain SSO token.
    2. Logout from OpenAM using SSO token.

    Appreciate any help.

    Regards,
    Sunil

    #15480
     Brad Tumy
    Participant

    Here are some resources for you:

    OpenAM Developer’s Guide:
    https://backstage.forgerock.com/docs/openam/13.5/dev-guide#chap-client-dev

    *From Google:
    http://rest.elkstein.org/2008/02/using-rest-in-java.html

    *This is clearly an older resource but easily found on Google by searching “rest calls in java”

    • This reply was modified 5 years, 6 months ago by Brad Tumy.
    • This reply was modified 5 years, 6 months ago by Brad Tumy.
    • This reply was modified 5 years, 6 months ago by Brad Tumy.
    #15489
     mat_sunil
    Participant

    Thanks for the reply. I was hoping I could use openam-core-rest-13.5.0.jar to make the REST calls. I don’t want to deal with parsing the string. From the test classes I was able to come up with something like below.

    CoreServicesWrapper coreServicesWrapper = new CoreServicesWrapper();
    LoginAuthenticator loginAuthenticator = new LoginAuthenticator(coreServicesWrapper);
    RestAuthCallbackHandlerFactory restAuthCallbackHandlerFactory = RestAuthCallbackHandlerFactory.getInstance();
    RestAuthCallbackHandlerManager restAuthCallbackHandlerManager = new RestAuthCallbackHandlerManager(restAuthCallbackHandlerFactory);
    AMAuthErrorCodeResponseStatusMapping amAuthErrorCodeResponseStatusMapping = new AMAuthErrorCodeResponseStatusMapping();
    JwtBuilderFactory jwtBuilderFactory = new JwtBuilderFactory();
    SigningManager signingManager = new SigningManager();
    AuthIdHelper authIdHelper = new AuthIdHelper(coreServicesWrapper, jwtBuilderFactory, signingManager);
    LoginConfiguration loginConfiguration = new LoginConfiguration();

    RestAuthenticationHandler restAuthenticationHandler = new RestAuthenticationHandler(loginAuthenticator, restAuthCallbackHandlerManager,
    amAuthErrorCodeResponseStatusMapping, authIdHelper);

    AuthContextLocal authContextLocal = new AuthContextLocal();
    AuthContextLocalWrapper authContextLocalWrapper = new AuthContextLocalWrapper(ac);
    LoginProcess loginProcess = new LoginProcess(loginAuthenticator, loginConfiguration, authContext, coreServicesWrapper);
    loginAuthenticator.getLoginProcess(loginConfiguration);
    SignedJwt signedJwt = authIdHelper.reconstructAuthId(“AUTH_ID”);

    Is there something similar that I could use?

    Regards,
    Sunil

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?