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

github-actions
2023-11-24 a793b81f64d6430a14e736b1dd4729ffa8e873ab
commit | author | age
7f7e0c 1 package org.keycloak.protocol.cas;
MP 2
fdb9f6 3 import jakarta.ws.rs.Path;
JK 4 import jakarta.ws.rs.core.Context;
5 import jakarta.ws.rs.core.HttpHeaders;
6 import jakarta.ws.rs.core.Response;
7 import jakarta.ws.rs.core.UriBuilder;
7f7e0c 8 import org.jboss.resteasy.spi.HttpRequest;
MP 9 import org.jboss.resteasy.spi.ResteasyProviderFactory;
10 import org.keycloak.events.EventBuilder;
11 import org.keycloak.models.KeycloakSession;
12 import org.keycloak.models.RealmModel;
74023a 13 import org.keycloak.protocol.cas.endpoints.*;
7f7e0c 14 import org.keycloak.services.resources.RealmsResource;
MP 15
16 public class CASLoginProtocolService {
58cce9 17     private KeycloakSession session;
7f7e0c 18     private RealmModel realm;
MP 19     private EventBuilder event;
20
58cce9 21     public CASLoginProtocolService(KeycloakSession session, EventBuilder event) {
G 22         this.session = session;
23         this.realm = session.getContext().getRealm();
7f7e0c 24         this.event = event;
MP 25     }
26
27     public static UriBuilder serviceBaseUrl(UriBuilder baseUriBuilder) {
28         return baseUriBuilder.path(RealmsResource.class).path("{realm}/protocol/" + CASLoginProtocol.LOGIN_PROTOCOL);
29     }
30
31     @Path("login")
32     public Object login() {
58cce9 33         AuthorizationEndpoint endpoint = new AuthorizationEndpoint(session, event);
7f7e0c 34         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
MP 35         return endpoint;
36     }
37
38     @Path("logout")
39     public Object logout() {
e1b962 40         LogoutEndpoint endpoint = new LogoutEndpoint(session, realm);
7f7e0c 41         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
MP 42         return endpoint;
43     }
44
45     @Path("validate")
46     public Object validate() {
e1b962 47         ValidateEndpoint endpoint = new ValidateEndpoint(session, realm, event);
7f7e0c 48         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
MP 49         return endpoint;
50     }
51
74023a 52     @Path("samlValidate")
EH 53     public Object validateSaml11() {
e1b962 54         SamlValidateEndpoint endpoint = new SamlValidateEndpoint(session, realm, event);
74023a 55         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
EH 56         return endpoint;
57     }
58
7f7e0c 59     @Path("serviceValidate")
MP 60     public Object serviceValidate() {
e1b962 61         ServiceValidateEndpoint endpoint = new ServiceValidateEndpoint(session, realm, event);
7f7e0c 62         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
MP 63         return endpoint;
64     }
65
66     @Path("proxyValidate")
67     public Object proxyValidate() {
5a0869 68         //TODO implement
MP 69         return serviceValidate();
7f7e0c 70     }
MP 71
72     @Path("proxy")
73     public Object proxy() {
5a0869 74         return Response.serverError().entity("Not implemented").build();
7f7e0c 75     }
MP 76
77     @Path("p3/serviceValidate")
78     public Object p3ServiceValidate() {
79         return serviceValidate();
80     }
81
82     @Path("p3/proxyValidate")
83     public Object p3ProxyValidate() {
84         return proxyValidate();
85     }
86 }