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

Matthias Piepkorn
2018-09-08 9532f1b237bbd5f74f6a4ef137dbdcbd1c58d0ba
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 UriInfo uriInfo;
23
24     @Context
25     private KeycloakSession session;
26
27     @Context
28     private HttpHeaders headers;
29
30     @Context
31     private HttpRequest request;
32
33     public CASLoginProtocolService(RealmModel realm, EventBuilder event) {
34         this.realm = realm;
35         this.event = event;
36     }
37
38     public static UriBuilder serviceBaseUrl(UriBuilder baseUriBuilder) {
39         return baseUriBuilder.path(RealmsResource.class).path("{realm}/protocol/" + CASLoginProtocol.LOGIN_PROTOCOL);
40     }
41
42     @Path("login")
43     public Object login() {
44         AuthorizationEndpoint endpoint = new AuthorizationEndpoint(realm, event);
45         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
46         return endpoint;
47     }
48
49     @Path("logout")
50     public Object logout() {
51         LogoutEndpoint endpoint = new LogoutEndpoint(realm, event);
52         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
53         return endpoint;
54     }
55
56     @Path("validate")
57     public Object validate() {
58         ValidateEndpoint endpoint = new ValidateEndpoint(realm, event);
59         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
60         return endpoint;
61     }
62
63     @Path("serviceValidate")
64     public Object serviceValidate() {
65         ServiceValidateEndpoint endpoint = new ServiceValidateEndpoint(realm, event);
66         ResteasyProviderFactory.getInstance().injectProperties(endpoint);
67         return endpoint;
68     }
69
70     @Path("proxyValidate")
71     public Object proxyValidate() {
5a0869 72         //TODO implement
MP 73         return serviceValidate();
7f7e0c 74     }
MP 75
76     @Path("proxy")
77     public Object proxy() {
5a0869 78         return Response.serverError().entity("Not implemented").build();
7f7e0c 79     }
MP 80
81     @Path("p3/serviceValidate")
82     public Object p3ServiceValidate() {
83         return serviceValidate();
84     }
85
86     @Path("p3/proxyValidate")
87     public Object p3ProxyValidate() {
88         return proxyValidate();
89     }
90 }