Git Product home page Git Product logo

Comments (4)

literallyjustroy avatar literallyjustroy commented on August 19, 2024 1

From a brief test that looks like exactly what we are looking for! Thanks for getting on this so quickly.

from okta-sdk-java.

arvindkrishnakumar-okta avatar arvindkrishnakumar-okta commented on August 19, 2024

Thanks for posting @literallyjustroy!

Will get this addressed, we welcome PRs also, feel free to submit a PR if you could.

from okta-sdk-java.

literallyjustroy avatar literallyjustroy commented on August 19, 2024

So the real problem is that the PolicyApi getPolicy method returns a Policy, which doesn't have a settings field. Since it doesn't even hold the arbitrary data, it can't be cast to a PasswordPolicy. It appears my only option is to call the api directly:

PasswordPolicy passwordPolicy = oktaPolicyApi.getApiClient()
    .invokeAPI("/api/v1/policies/{policyId}",
        HttpMethod.GET,
        Collections.singletonMap("policyId", passwordPolicyId),
        null,
        null,
        new HttpHeaders(),
        new LinkedMultiValueMap<>(),
        null,
        Collections.singletonList(MediaType.APPLICATION_JSON),
        MediaType.APPLICATION_JSON,
        new String[]{"apiToken", "oauth2"},
        new ParameterizedTypeReference<PasswordPolicy>() {}
    ).getBody();

It seems like this usage is flawed, there is no way to get anything other then the general Policy info from the SDK (other than calling endpoints directly). It seems like the getPolicy method shouldn't return a Policy but an object that extends Policy.

On a somewhat similar note, I am not seeing a way to create a new IDP_DISCOVERY Policy Rule. There is no IdentityProviderPolicyRule class. The AccessPolicyRule class seems to include most of the same fields so I can use that perhaps, but when I need to specify the IdpPolicyRuleActionProvider there is no way to set the ID, so I get stuck. I'm not sure if I'm missing something glaring or if this just cannot be done with the version 10 Okta SDK.

If you believe any of this is relatively easy to add I do not mind to spend a few days looking into it.

from okta-sdk-java.

arvindkrishnakumar-okta avatar arvindkrishnakumar-okta commented on August 19, 2024

@literallyjustroy 11.0.0 just got released.

With this latest release, you should be able to use PolicyApiHelper to get sub-typed Policy objects.

PolicyApiHelper<Policy> policyApiHelper = new PolicyApiHelper<>(new PolicyApi(getClient()));
PasswordPolicy passwordPolicy = (PasswordPolicy) policyApiHelper.getPolicy(policy.getId(), null);

Similarly, PolicyRule sub-classes can be created using the PolicyApiHelper instance:

See https://github.com/okta/okta-sdk-java/blob/master/integration-tests/src/test/groovy/com/okta/sdk/tests/it/PoliciesIT.groovy#L141-L142

Let me know if that helps!

from okta-sdk-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.