|
1 | 1 | package com.github.bcgov.keycloak.protocol.saml.mappers;
|
2 | 2 |
|
| 3 | +import org.keycloak.models.AuthenticatedClientSessionModel; |
3 | 4 | import org.keycloak.models.ClientSessionContext;
|
4 | 5 | import org.keycloak.models.KeycloakSession;
|
5 | 6 | import org.keycloak.models.UserSessionModel;
|
6 | 7 | import org.keycloak.protocol.saml.mappers.AbstractSAMLProtocolMapper;
|
| 8 | +import org.keycloak.protocol.saml.mappers.SAMLAttributeStatementMapper; |
7 | 9 | import org.keycloak.protocol.saml.mappers.SAMLLoginResponseMapper;
|
8 | 10 | import org.keycloak.protocol.saml.SamlProtocol;
|
9 | 11 | import org.keycloak.representations.idm.ProtocolMapperRepresentation;
|
|
16 | 18 | import org.keycloak.provider.ProviderConfigProperty;
|
17 | 19 | import org.keycloak.models.ProtocolMapperModel;
|
18 | 20 | import org.jboss.logging.Logger;
|
| 21 | +import org.keycloak.dom.saml.v2.assertion.AttributeStatementType; |
| 22 | +import org.keycloak.dom.saml.v2.assertion.AttributeStatementType.ASTChoiceType; |
19 | 23 | import org.keycloak.dom.saml.v2.assertion.NameIDType;
|
20 | 24 | import org.keycloak.dom.saml.v2.assertion.SubjectConfirmationType;
|
21 | 25 | import org.keycloak.dom.saml.v2.assertion.SubjectType;
|
|
24 | 28 | import java.net.URI;
|
25 | 29 | import java.util.*;
|
26 | 30 |
|
27 |
| -public class PPIDAttributeMapperNameId extends AbstractSAMLProtocolMapper implements SAMLLoginResponseMapper { |
| 31 | +public class PPIDAttributeMapperNameId extends AbstractSAMLProtocolMapper |
| 32 | + implements SAMLLoginResponseMapper, SAMLAttributeStatementMapper { |
28 | 33 |
|
29 | 34 | private static final Logger logger = Logger.getLogger(PPIDAttributeMapperNameId.class);
|
30 | 35 |
|
@@ -131,4 +136,17 @@ public static ProtocolMapperRepresentation create(String name, String nameIdValu
|
131 | 136 | return rep;
|
132 | 137 | }
|
133 | 138 |
|
| 139 | + @Override |
| 140 | + public void transformAttributeStatement(AttributeStatementType attributeStatement, ProtocolMapperModel mappingModel, |
| 141 | + KeycloakSession keycloakSession, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) { |
| 142 | + List<ASTChoiceType> attributes = attributeStatement.getAttributes(); |
| 143 | + for (int i = attributes.size(); i-- > 0;) { |
| 144 | + AttributeStatementType.ASTChoiceType attribute = attributes.get(i); |
| 145 | + String name = attribute.getAttribute().getName(); |
| 146 | + if (name.equals(PRIVACY_ZONE_MAPPER)) { |
| 147 | + attributeStatement.removeAttribute(attribute); |
| 148 | + break; |
| 149 | + } |
| 150 | + } |
| 151 | + } |
134 | 152 | }
|
0 commit comments