keycloak-service
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint クラス
org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint の継承関係図
Inheritance graph
org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint 連携図
Collaboration graph

公開メンバ関数

 OpenShiftTokenReviewEndpoint (KeycloakSession session)
 
void setEvent (EventBuilder event)
 
Response tokenReview (OpenShiftTokenReviewRequestRepresentation reviewRequest) throws Exception
 
Response tokenReview (@PathParam("client_id") String clientId, OpenShiftTokenReviewRequestRepresentation reviewRequest) throws Exception
 
default void close ()
 

非公開メンバ関数

void checkSsl ()
 
void checkRealm ()
 
void authorizeClient ()
 
void error (int statusCode, String error, String description)
 

非公開変数類

KeycloakSession session
 
TokenManager tokenManager
 
EventBuilder event
 

詳解

著者
Bill Burke
バージョン
Revision
1

構築子と解体子

◆ OpenShiftTokenReviewEndpoint()

org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.OpenShiftTokenReviewEndpoint ( KeycloakSession  session)
inline
56  {
57  this.session = session;
58  this.tokenManager = new TokenManager();
59  }
KeycloakSession session
Definition: OpenShiftTokenReviewEndpoint.java:52
TokenManager tokenManager
Definition: OpenShiftTokenReviewEndpoint.java:53

関数詳解

◆ authorizeClient()

void org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.authorizeClient ( )
inlineprivate
144  {
145  try {
146  ClientModel client = AuthorizeClientUtil.authorizeClient(session, event).getClient();
147  event.client(client);
148 
149  if (client == null || client.isPublicClient()) {
150  error(401, Errors.INVALID_CLIENT, "Public client is not permitted to invoke token review endpoint");
151  }
152 
153  } catch (ErrorResponseException ere) {
154  error(401, Errors.INVALID_CLIENT_CREDENTIALS, ere.getErrorDescription());
155  } catch (Exception e) {
156  error(401, Errors.INVALID_CLIENT_CREDENTIALS, null);
157  }
158  }
KeycloakSession session
Definition: OpenShiftTokenReviewEndpoint.java:52
EventBuilder event
Definition: OpenShiftTokenReviewEndpoint.java:54
void error(int statusCode, String error, String description)
Definition: OpenShiftTokenReviewEndpoint.java:160

◆ checkRealm()

void org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.checkRealm ( )
inlineprivate
138  {
139  if (!session.getContext().getRealm().isEnabled()) {
140  error(401, Errors.REALM_DISABLED,null);
141  }
142  }
KeycloakSession session
Definition: OpenShiftTokenReviewEndpoint.java:52
void error(int statusCode, String error, String description)
Definition: OpenShiftTokenReviewEndpoint.java:160

◆ checkSsl()

void org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.checkSsl ( )
inlineprivate
132  {
133  if (!session.getContext().getUri().getBaseUri().getScheme().equals("https") && session.getContext().getRealm().getSslRequired().isRequired(session.getContext().getConnection())) {
134  error(401, Errors.SSL_REQUIRED, null);
135  }
136  }
KeycloakSession session
Definition: OpenShiftTokenReviewEndpoint.java:52
void error(int statusCode, String error, String description)
Definition: OpenShiftTokenReviewEndpoint.java:160

◆ close()

default void org.keycloak.protocol.oidc.ext.OIDCExtProvider.close ( )
inlineinherited
11  {
12  }

◆ error()

void org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.error ( int  statusCode,
String  error,
String  description 
)
inlineprivate
160  {
161  OpenShiftTokenReviewResponseRepresentation rep = new OpenShiftTokenReviewResponseRepresentation();
162  rep.getStatus().setAuthenticated(false);
163 
164  Response response = Response.status(statusCode).entity(rep).type(MediaType.APPLICATION_JSON_TYPE).build();
165 
166  event.error(error);
167  event.detail(Details.REASON, description);
168 
169  throw new ErrorResponseException(response);
170  }
void error(int statusCode, String error, String description)
Definition: OpenShiftTokenReviewEndpoint.java:160

◆ setEvent()

void org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.setEvent ( EventBuilder  event)
inline

org.keycloak.protocol.oidc.ext.OIDCExtProviderを実装しています。

62  {
63  this.event = event;
64  }
EventBuilder event
Definition: OpenShiftTokenReviewEndpoint.java:54

◆ tokenReview() [1/2]

Response org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.tokenReview ( OpenShiftTokenReviewRequestRepresentation  reviewRequest) throws Exception
inline
70  {
71  return tokenReview(null, reviewRequest);
72  }
Response tokenReview(OpenShiftTokenReviewRequestRepresentation reviewRequest)
Definition: OpenShiftTokenReviewEndpoint.java:70

◆ tokenReview() [2/2]

Response org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.tokenReview ( @PathParam("client_id") String  clientId,
OpenShiftTokenReviewRequestRepresentation  reviewRequest 
) throws Exception
inline
78  {
79  event.event(EventType.INTROSPECT_TOKEN);
80 
81  if (clientId != null) {
82  session.setAttribute("client_id", clientId);
83  }
84 
85  checkSsl();
86  checkRealm();
88 
89  RealmModel realm = session.getContext().getRealm();
90 
91  AccessToken token = null;
92  try {
93  TokenVerifier<AccessToken> verifier = TokenVerifier.create(reviewRequest.getSpec().getToken(), AccessToken.class)
94  .realmUrl(Urls.realmIssuer(session.getContext().getUri().getBaseUri(), realm.getName()));
95 
96  SignatureVerifierContext verifierContext = session.getProvider(SignatureProvider.class, verifier.getHeader().getAlgorithm().name()).verifier(verifier.getHeader().getKeyId());
97  verifier.verifierContext(verifierContext);
98 
99  verifier.verify();
100  token = verifier.getToken();
101  } catch (VerificationException e) {
102  error(401, Errors.INVALID_TOKEN, "Token verification failure");
103  }
104 
106  error(401, Errors.INVALID_TOKEN, "Token verification failure");
107  }
108 
109  OpenShiftTokenReviewResponseRepresentation response = new OpenShiftTokenReviewResponseRepresentation();
110  response.getStatus().setAuthenticated(true);
111  response.getStatus().setUser(new OpenShiftTokenReviewResponseRepresentation.User());
112 
113  OpenShiftTokenReviewResponseRepresentation.User userRep = response.getStatus().getUser();
114  userRep.setUid(token.getSubject());
115  userRep.setUsername(token.getPreferredUsername());
116 
117  if (token.getScope() != null && !token.getScope().isEmpty()) {
118  OpenShiftTokenReviewResponseRepresentation.Extra extra = new OpenShiftTokenReviewResponseRepresentation.Extra();
119  extra.setScopes(token.getScope().split(" "));
120  userRep.setExtra(extra);
121  }
122 
123  if (token.getOtherClaims() != null && token.getOtherClaims().get("groups") != null) {
124  List<String> groups = (List<String>) token.getOtherClaims().get("groups");
125  userRep.setGroups(groups);
126  }
127 
128  event.success();
129  return Response.ok(response, MediaType.APPLICATION_JSON).build();
130  }
boolean checkTokenValidForIntrospection(KeycloakSession session, RealmModel realm, AccessToken token)
Definition: TokenManager.java:215
void checkRealm()
Definition: OpenShiftTokenReviewEndpoint.java:138
KeycloakSession session
Definition: OpenShiftTokenReviewEndpoint.java:52
void checkSsl()
Definition: OpenShiftTokenReviewEndpoint.java:132
void error(int statusCode, String error, String description)
Definition: OpenShiftTokenReviewEndpoint.java:160
void authorizeClient()
Definition: OpenShiftTokenReviewEndpoint.java:144
TokenManager tokenManager
Definition: OpenShiftTokenReviewEndpoint.java:53

メンバ詳解

◆ event

EventBuilder org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.event
private

◆ session

KeycloakSession org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.session
private

◆ tokenManager

TokenManager org.keycloak.protocol.openshift.OpenShiftTokenReviewEndpoint.tokenManager
private

このクラス詳解は次のファイルから抽出されました: