Java Code Examples for org.keycloak.representations.idm.RealmRepresentation#getWebAuthnPolicyRequireResidentKey()

The following examples show how to use org.keycloak.representations.idm.RealmRepresentation#getWebAuthnPolicyRequireResidentKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebAuthnRegisterAndLoginTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private RealmRepresentation backupWebAuthnRealmSettings() {
    RealmRepresentation rep = testRealm().toRepresentation();
    signatureAlgorithms = rep.getWebAuthnPolicySignatureAlgorithms();
    attestationConveyancePreference = rep.getWebAuthnPolicyAttestationConveyancePreference();
    authenticatorAttachment = rep.getWebAuthnPolicyAuthenticatorAttachment();
    requireResidentKey = rep.getWebAuthnPolicyRequireResidentKey();
    rpEntityName = rep.getWebAuthnPolicyRpEntityName();
    userVerificationRequirement = rep.getWebAuthnPolicyUserVerificationRequirement();
    rpId = rep.getWebAuthnPolicyRpId();
    createTimeout = rep.getWebAuthnPolicyCreateTimeout();
    avoidSameAuthenticatorRegister = rep.isWebAuthnPolicyAvoidSameAuthenticatorRegister();
    acceptableAaguids = rep.getWebAuthnPolicyAcceptableAaguids();
    return rep;
}
 
Example 2
Source File: RepresentationToModel.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private static WebAuthnPolicy getWebAuthnPolicyTwoFactor(RealmRepresentation rep) {
    WebAuthnPolicy webAuthnPolicy = new WebAuthnPolicy();

    String webAuthnPolicyRpEntityName = rep.getWebAuthnPolicyRpEntityName();
    if (webAuthnPolicyRpEntityName == null || webAuthnPolicyRpEntityName.isEmpty())
        webAuthnPolicyRpEntityName = Constants.DEFAULT_WEBAUTHN_POLICY_RP_ENTITY_NAME;
    webAuthnPolicy.setRpEntityName(webAuthnPolicyRpEntityName);

    List<String> webAuthnPolicySignatureAlgorithms = rep.getWebAuthnPolicySignatureAlgorithms();
    if (webAuthnPolicySignatureAlgorithms == null || webAuthnPolicySignatureAlgorithms.isEmpty())
        webAuthnPolicySignatureAlgorithms = Arrays.asList(Constants.DEFAULT_WEBAUTHN_POLICY_SIGNATURE_ALGORITHMS.split(","));
    webAuthnPolicy.setSignatureAlgorithm(webAuthnPolicySignatureAlgorithms);

    String webAuthnPolicyRpId = rep.getWebAuthnPolicyRpId();
    if (webAuthnPolicyRpId == null || webAuthnPolicyRpId.isEmpty())
        webAuthnPolicyRpId = "";
    webAuthnPolicy.setRpId(webAuthnPolicyRpId);

    String webAuthnPolicyAttestationConveyancePreference = rep.getWebAuthnPolicyAttestationConveyancePreference();
    if (webAuthnPolicyAttestationConveyancePreference == null || webAuthnPolicyAttestationConveyancePreference.isEmpty())
        webAuthnPolicyAttestationConveyancePreference = Constants.DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED;
    webAuthnPolicy.setAttestationConveyancePreference(webAuthnPolicyAttestationConveyancePreference);

    String webAuthnPolicyAuthenticatorAttachment = rep.getWebAuthnPolicyAuthenticatorAttachment();
    if (webAuthnPolicyAuthenticatorAttachment == null || webAuthnPolicyAuthenticatorAttachment.isEmpty())
        webAuthnPolicyAuthenticatorAttachment = Constants.DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED;
    webAuthnPolicy.setAuthenticatorAttachment(webAuthnPolicyAuthenticatorAttachment);

    String webAuthnPolicyRequireResidentKey = rep.getWebAuthnPolicyRequireResidentKey();
    if (webAuthnPolicyRequireResidentKey == null || webAuthnPolicyRequireResidentKey.isEmpty())
        webAuthnPolicyRequireResidentKey = Constants.DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED;
    webAuthnPolicy.setRequireResidentKey(webAuthnPolicyRequireResidentKey);

    String webAuthnPolicyUserVerificationRequirement = rep.getWebAuthnPolicyUserVerificationRequirement();
    if (webAuthnPolicyUserVerificationRequirement == null || webAuthnPolicyUserVerificationRequirement.isEmpty())
        webAuthnPolicyUserVerificationRequirement = Constants.DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED;
    webAuthnPolicy.setUserVerificationRequirement(webAuthnPolicyUserVerificationRequirement);

    Integer webAuthnPolicyCreateTimeout = rep.getWebAuthnPolicyCreateTimeout();
    if (webAuthnPolicyCreateTimeout != null) webAuthnPolicy.setCreateTimeout(webAuthnPolicyCreateTimeout);
    else webAuthnPolicy.setCreateTimeout(0);

    Boolean webAuthnPolicyAvoidSameAuthenticatorRegister = rep.isWebAuthnPolicyAvoidSameAuthenticatorRegister();
    if (webAuthnPolicyAvoidSameAuthenticatorRegister != null) webAuthnPolicy.setAvoidSameAuthenticatorRegister(webAuthnPolicyAvoidSameAuthenticatorRegister);

    List<String> webAuthnPolicyAcceptableAaguids = rep.getWebAuthnPolicyAcceptableAaguids();
    if (webAuthnPolicyAcceptableAaguids != null) webAuthnPolicy.setAcceptableAaguids(webAuthnPolicyAcceptableAaguids);

    return webAuthnPolicy;
}