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

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