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
| | |
| | | |
| | | <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 /> |
| | | |
| | |
| | | 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(); |
New file |
| | |
| | | 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"; |
| | | |
| | | } |
| | |
| | | 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)); |
| | |
| | | |
| | | 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 |
| | | ); |
| | | } |
| | | |