Search in sources :

Example 1 with AddressClaimSet

use of org.keycloak.representations.AddressClaimSet in project keycloak by keycloak.

the class AddressMapper method setClaim.

@Override
protected void setClaim(IDToken token, ProtocolMapperModel mappingModel, UserSessionModel userSession) {
    UserModel user = userSession.getUser();
    AddressClaimSet addressSet = new AddressClaimSet();
    addressSet.setStreetAddress(getUserModelAttributeValue(user, mappingModel, STREET));
    addressSet.setLocality(getUserModelAttributeValue(user, mappingModel, AddressClaimSet.LOCALITY));
    addressSet.setRegion(getUserModelAttributeValue(user, mappingModel, AddressClaimSet.REGION));
    addressSet.setPostalCode(getUserModelAttributeValue(user, mappingModel, AddressClaimSet.POSTAL_CODE));
    addressSet.setCountry(getUserModelAttributeValue(user, mappingModel, AddressClaimSet.COUNTRY));
    addressSet.setFormattedAddress(getUserModelAttributeValue(user, mappingModel, AddressClaimSet.FORMATTED));
    token.getOtherClaims().put("address", addressSet);
}
Also used : UserModel(org.keycloak.models.UserModel) AddressClaimSet(org.keycloak.representations.AddressClaimSet)

Example 2 with AddressClaimSet

use of org.keycloak.representations.AddressClaimSet in project keycloak by keycloak.

the class OIDCScopeTest method assertAddress.

private void assertAddress(IDToken idToken, boolean claimsIn) {
    AddressClaimSet address = idToken.getAddress();
    if (claimsIn) {
        Assert.assertNotNull(address);
        Assert.assertEquals("Elm 5", address.getStreetAddress());
    } else {
        Assert.assertNull(address);
    }
}
Also used : AddressClaimSet(org.keycloak.representations.AddressClaimSet)

Aggregations

AddressClaimSet (org.keycloak.representations.AddressClaimSet)2 UserModel (org.keycloak.models.UserModel)1