gluu
公開メンバ関数 | 非公開メンバ関数 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxd.server.service.ValidationService クラス
org.xdi.oxd.server.service.ValidationService 連携図
Collaboration graph

公開メンバ関数

void notNull (IParams params)
 
void notBlankOxdId (String oxdId)
 
void notBlankOpHost (String opHost)
 
Pair< Rp, Boolean > validate (IParams params)
 
IntrospectionResponse introspect (String accessToken, String oxdId)
 
void validate (HasOxdIdParams params)
 
Rp validate (Rp rp)
 

非公開メンバ関数

boolean validate (HasProtectionAccessTokenParams params)
 

静的非公開変数類

static final Logger LOG = LoggerFactory.getLogger(ValidationService.class)
 

詳解

著者
Yuriy Zabrovarnyy

関数詳解

◆ introspect()

IntrospectionResponse org.xdi.oxd.server.service.ValidationService.introspect ( String  accessToken,
String  oxdId 
)
inline
131  {
132  if (StringUtils.isBlank(accessToken)) {
133  throw new ErrorResponseException(ErrorResponseCode.BLANK_PROTECTION_ACCESS_TOKEN);
134  }
135 
136  final RpService rpService = ServerLauncher.getInjector().getInstance(RpService.class);
137  final Rp rp = rpService.getRp(oxdId);
138  if (StringUtils.isNotBlank(rp.getSetupOxdId())) {
139  oxdId = rp.getSetupOxdId();
140  } else {
141  Rp firstSetupClient = rpService.getFirstSetupClient();
142  if (firstSetupClient != null) {
143  oxdId = firstSetupClient.getOxdId();
144  }
145  }
146  LOG.trace("Introspect token with rp: " + rpService.getRp(oxdId));
147 
148  final IntrospectionService introspectionService = ServerLauncher.getInjector().getInstance(IntrospectionService.class);
149  final IntrospectionResponse response = introspectionService.introspectToken(oxdId, accessToken);
150 
151  if (!response.isActive()) {
152  LOG.debug("access_token is not active.");
153  throw new ErrorResponseException(ErrorResponseCode.INACTIVE_PROTECTION_ACCESS_TOKEN);
154  }
155  return response;
156  }
static final Logger LOG
Definition: ValidationService.java:21

◆ notBlankOpHost()

void org.xdi.oxd.server.service.ValidationService.notBlankOpHost ( String  opHost)
inline
35  {
36  if (Strings.isNullOrEmpty(opHost)) {
37  throw new ErrorResponseException(ErrorResponseCode.INVALID_OP_HOST);
38  }
39  }

◆ notBlankOxdId()

void org.xdi.oxd.server.service.ValidationService.notBlankOxdId ( String  oxdId)
inline
29  {
30  if (Strings.isNullOrEmpty(oxdId)) {
31  throw new ErrorResponseException(ErrorResponseCode.BAD_REQUEST_NO_OXD_ID);
32  }
33  }

◆ notNull()

void org.xdi.oxd.server.service.ValidationService.notNull ( IParams  params)
inline
23  {
24  if (params == null) {
25  throw new ErrorResponseException(ErrorResponseCode.INTERNAL_ERROR_NO_PARAMS);
26  }
27  }

◆ validate() [1/4]

Pair<Rp, Boolean> org.xdi.oxd.server.service.ValidationService.validate ( IParams  params)
inline
41  {
42  Boolean isClientLocal = null;
43  notNull(params);
44  if (params instanceof HasOxdIdParams) {
45  validate((HasOxdIdParams) params);
46  isClientLocal = true;
47  }
48  if (params instanceof HasProtectionAccessTokenParams) {
49  if (validate((HasProtectionAccessTokenParams) params)) {
50  isClientLocal = false;
51  }
52  }
53 
54  if (isClientLocal != null && !(params instanceof RegisterSiteParams)) {
55  try {
56  String oxdId = ((HasOxdIdParams) params).getOxdId();
57  if (StringUtils.isNotBlank(oxdId)) {
58  final RpService rpService = ServerLauncher.getInjector().getInstance(RpService.class);
59  final Rp rp = rpService.getRp(oxdId);
60  if (rp != null) {
61  return new Pair<>(rp, isClientLocal);
62  }
63  }
64  } catch (ErrorResponseException e) {
65  if (e.getErrorResponseCode() == ErrorResponseCode.EXPIRED_CLIENT) {
66  throw e;
67  }
68  // ignore
69  } catch (Exception e) {
70  LOG.error("Failed to invoke license service client update. Message: " + e.getMessage(), e);
71  }
72  }
73  return null;
74  }
Pair< Rp, Boolean > validate(IParams params)
Definition: ValidationService.java:41
static final Logger LOG
Definition: ValidationService.java:21
Definition: HasProtectionAccessTokenParams.java:8
Definition: RegisterSiteParams.java:15
void notNull(IParams params)
Definition: ValidationService.java:23
Definition: HasOxdIdParams.java:8

◆ validate() [2/4]

boolean org.xdi.oxd.server.service.ValidationService.validate ( HasProtectionAccessTokenParams  params)
inlineprivate

Returns whether has valid token

引数
paramsparams
戻り値
true - client is remote, false - client is local. If validation does not pass exception must be thrown
82  {
83  if (params instanceof SetupClientParams) {
84  return false;
85  }
86  if (params instanceof UpdateSiteParams) {
87  final RpService rpService = ServerLauncher.getInjector().getInstance(RpService.class);
88  final Rp rp = rpService.getRp(params.getOxdId());
89  if (rp.getSetupClient() != null && rp.getSetupClient()) {
90  return false; // skip validation if client is setup client (if we can setup client without protection access token then we allow also update it)
91  }
92  }
93 
94  final OxdServerConfiguration configuration = ServerLauncher.getInjector().getInstance(ConfigurationService.class).get();
95  if (configuration.getProtectCommandsWithAccessToken() != null && !configuration.getProtectCommandsWithAccessToken()) {
96  if (StringUtils.isBlank(params.getProtectionAccessToken())) {
97  return false; // skip validation since protectCommandsWithAccessToken=false
98  } // otherwise if token is not blank then let it validate it
99  }
100 
101  final String accessToken = params.getProtectionAccessToken();
102 
103  if (StringUtils.isBlank(accessToken)) {
104  throw new ErrorResponseException(ErrorResponseCode.BLANK_PROTECTION_ACCESS_TOKEN);
105  }
106  if (params instanceof RegisterSiteParams) {
107  return false; // skip validation for site registration because we have to associate oxd_id with client_id, validation is performed inside operation
108  }
109 
110  final RpService rpService = ServerLauncher.getInjector().getInstance(RpService.class);
111 
112  final Rp rp = rpService.getRp(params.getOxdId());
113  if (StringUtils.isBlank(rp.getSetupClientId())) {
114  throw new ErrorResponseException(ErrorResponseCode.NO_SETUP_CLIENT_FOR_OXD_ID);
115  }
116 
117  final IntrospectionResponse introspectionResponse = introspect(accessToken, params.getOxdId());
118 
119  LOG.trace("access_token: " + accessToken + ", introspection: " + introspectionResponse + ", setupClientId: " + rp.getSetupClientId());
120  if (StringUtils.isBlank(introspectionResponse.getClientId())) {
121  throw new ErrorResponseException(ErrorResponseCode.NO_CLIENT_ID_IN_INTROSPECTION_RESPONSE);
122  }
123 
124  if (introspectionResponse.getClientId().equals(rp.getSetupClientId())) {
125  return true;
126  }
127 
128  throw new ErrorResponseException(ErrorResponseCode.INVALID_PROTECTION_ACCESS_TOKEN);
129  }
IntrospectionResponse introspect(String accessToken, String oxdId)
Definition: ValidationService.java:131
Definition: UpdateSiteParams.java:15
static final Logger LOG
Definition: ValidationService.java:21
Definition: SetupClientParams.java:11
Definition: RegisterSiteParams.java:15

◆ validate() [3/4]

void org.xdi.oxd.server.service.ValidationService.validate ( HasOxdIdParams  params)
inline
158  {
159  notNull(params);
160  notBlankOxdId(params.getOxdId());
161  }
void notBlankOxdId(String oxdId)
Definition: ValidationService.java:29
void notNull(IParams params)
Definition: ValidationService.java:23

◆ validate() [4/4]

Rp org.xdi.oxd.server.service.ValidationService.validate ( Rp  rp)
inline
163  {
164  if (rp == null) {
165  throw new ErrorResponseException(ErrorResponseCode.INVALID_OXD_ID);
166  }
167 
168  notBlankOxdId(rp.getOxdId());
169  notBlankOpHost(rp.getOpHost());
170  return rp;
171  }
void notBlankOxdId(String oxdId)
Definition: ValidationService.java:29
void notBlankOpHost(String opHost)
Definition: ValidationService.java:35

メンバ詳解

◆ LOG

final Logger org.xdi.oxd.server.service.ValidationService.LOG = LoggerFactory.getLogger(ValidationService.class)
staticprivate

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