mirror of https://github.com/jacekkow/keycloak-protocol-cas

Phy
2020-02-28 8379a316bc051ff05ac2fb06671871ab82f01feb
Update to Keycloak 9.0.0 and apply API change

- DefaultClientSessionContext.fromClientSessionAndScopeParameter adds session parm
- Add SAMLCASConstants to address removed constants from Keycloak
1 files added
3 files modified
21 ■■■■ changed files
pom.xml 2 ●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/representations/SAMLCASConstants.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/representations/SamlResponseHelper.java 6 ●●●● patch | view | raw | blame | history
pom.xml
@@ -22,7 +22,7 @@
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-protocol-cas</artifactId>
    <version>8.0.2</version>
    <version>9.0.0</version>
    <name>Keycloak CAS Protocol</name>
    <description />
src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java
@@ -153,7 +153,7 @@
    protected Map<String, Object> getUserAttributes() {
        UserSessionModel userSession = clientSession.getUserSession();
        // CAS protocol does not support scopes, so pass null scopeParam
        ClientSessionContext clientSessionCtx = DefaultClientSessionContext.fromClientSessionAndScopeParameter(clientSession, null);
        ClientSessionContext clientSessionCtx = DefaultClientSessionContext.fromClientSessionAndScopeParameter(clientSession, null, session);
        Set<ProtocolMapperModel> mappings = clientSessionCtx.getProtocolMappers();
        KeycloakSessionFactory sessionFactory = session.getKeycloakSessionFactory();
src/main/java/org/keycloak/protocol/cas/representations/SAMLCASConstants.java
New file
@@ -0,0 +1,11 @@
package org.keycloak.protocol.cas.representations;
public interface SAMLCASConstants {
    String AUTH_METHOD_PASSWORD = "urn:oasis:names:tc:SAML:1.0:am:password";
    String FORMAT_EMAIL_ADDRESS = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress";
    String FORMAT_UNSPECIFIED = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified";
}
src/main/java/org/keycloak/protocol/cas/representations/SamlResponseHelper.java
@@ -74,7 +74,7 @@
                            conditions.setNotOnOrAfter(factory.newXMLGregorianCalendar(GregorianCalendar.from(nowZoned.plusMinutes(5))));
                        }));
                        assertion.add(applyTo(new SAML11AuthenticationStatementType(
                                URI.create(SAML11Constants.AUTH_METHOD_PASSWORD),
                                URI.create(SAMLCASConstants.AUTH_METHOD_PASSWORD),
                                now
                        ), stmt -> stmt.setSubject(toSubject(username))));
                        assertion.addAllStatements(toAttributes(username, attributes));
@@ -141,8 +141,8 @@
    private static URI nameIdFormat(String username) {
        return URI.create(Validation.isEmailValid(username) ?
                SAML11Constants.FORMAT_EMAIL_ADDRESS :
                SAML11Constants.FORMAT_UNSPECIFIED
                SAMLCASConstants.FORMAT_EMAIL_ADDRESS :
                SAMLCASConstants.FORMAT_UNSPECIFIED
        );
    }