keycloak-service
静的公開メンバ関数 | 静的非公開メンバ関数 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils クラス
org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils 連携図
Collaboration graph

静的公開メンバ関数

static Set< String > resolveValidRedirectUris (String clientRootUrl, Collection< String > clientRedirectUris)
 
static String resolveValidSectorIdentifier (String sectorIdentifierUri)
 
static String resolveValidSectorIdentifier (String clientRootUrl, Set< String > clientRedirectUris)
 
static boolean matchesRedirects (String clientRootUrl, Set< String > clientRedirectUris, Set< String > sectorRedirects)
 
static List< ProtocolMapperRepresentation > getPairwiseSubMappers (ClientRepresentation client)
 

静的非公開メンバ関数

static boolean matchesRedirect (Set< String > validRedirects, String redirect)
 
static String relativeToAbsoluteURI (String rootUrl, String relative)
 

静的非公開変数類

static final Logger logger = Logger.getLogger(PairwiseSubMapperUtils.class)
 

詳解

関数詳解

◆ getPairwiseSubMappers()

static List<ProtocolMapperRepresentation> org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.getPairwiseSubMappers ( ClientRepresentation  client)
inlinestatic
151  {
152  List<ProtocolMapperRepresentation> pairwiseMappers = new LinkedList<>();
153  List<ProtocolMapperRepresentation> mappers = client.getProtocolMappers();
154 
155  if (mappers != null) {
156  client.getProtocolMappers().stream().filter((ProtocolMapperRepresentation mapping) -> {
157  return mapping.getProtocolMapper().endsWith(AbstractPairwiseSubMapper.PROVIDER_ID_SUFFIX);
158  }).forEach((ProtocolMapperRepresentation mapping) -> {
159  pairwiseMappers.add(mapping);
160  });
161  }
162 
163  return pairwiseMappers;
164  }

◆ matchesRedirect()

static boolean org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.matchesRedirect ( Set< String >  validRedirects,
String  redirect 
)
inlinestaticprivate
125  {
126  for (String validRedirect : validRedirects) {
127  if (validRedirect.endsWith("*") && !validRedirect.contains("?")) {
128  // strip off the query component - we don't check them when wildcards are effective
129  String r = redirect.contains("?") ? redirect.substring(0, redirect.indexOf("?")) : redirect;
130  // strip off *
131  int length = validRedirect.length() - 1;
132  validRedirect = validRedirect.substring(0, length);
133  if (r.startsWith(validRedirect)) return true;
134  // strip off trailing '/'
135  if (length - 1 > 0 && validRedirect.charAt(length - 1) == '/') length--;
136  validRedirect = validRedirect.substring(0, length);
137  if (validRedirect.equals(r)) return true;
138  } else if (validRedirect.equals(redirect)) return true;
139  }
140  return false;
141  }

◆ matchesRedirects()

static boolean org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.matchesRedirects ( String  clientRootUrl,
Set< String >  clientRedirectUris,
Set< String >  sectorRedirects 
)
inlinestatic

Checks if the the registered client redirect URIs matches the set of redirect URIs from the sector identifier URI.

引数
clientRootUrlroot url registered on the client.
clientRedirectUrisredirect URIs registered on the client.
sectorRedirectsvalue of the sector identifier URI.
戻り値
true
iff. the all the redirect URIs can be described by the
sectorRedirects
, i.e if the registered redirect URIs is a subset of the
sectorRedirects
, otherwise
false
.
117  {
118  Set<String> validRedirects = resolveValidRedirectUris(clientRootUrl, clientRedirectUris);
119  for (String redirect : validRedirects) {
120  if (!matchesRedirect(sectorRedirects, redirect)) return false;
121  }
122  return true;
123  }
static Set< String > resolveValidRedirectUris(String clientRootUrl, Collection< String > clientRedirectUris)
Definition: PairwiseSubMapperUtils.java:28
static boolean matchesRedirect(Set< String > validRedirects, String redirect)
Definition: PairwiseSubMapperUtils.java:125

◆ relativeToAbsoluteURI()

static String org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.relativeToAbsoluteURI ( String  rootUrl,
String  relative 
)
inlinestaticprivate
143  {
144  if (rootUrl == null || rootUrl.isEmpty()) {
145  return null;
146  }
147  relative = rootUrl + relative;
148  return relative;
149  }

◆ resolveValidRedirectUris()

static Set<String> org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.resolveValidRedirectUris ( String  clientRootUrl,
Collection< String >  clientRedirectUris 
)
inlinestatic

Returns a set of valid redirect URIs from the root url and redirect URIs registered on a client.

引数
clientRootUrl
clientRedirectUris
戻り値
28  {
29  if (clientRedirectUris == null) {
30  return Collections.emptySet();
31  }
32 
33  Set<String> validRedirects = new HashSet<String>();
34  for (String redirectUri : clientRedirectUris) {
35  if (redirectUri.startsWith("/")) {
36  redirectUri = relativeToAbsoluteURI(clientRootUrl, redirectUri);
37  logger.debugv("replacing relative valid redirect with: {0}", redirectUri);
38  }
39  if (redirectUri != null) {
40  validRedirects.add(redirectUri);
41  }
42  }
43  return validRedirects.stream()
44  .filter(r -> r != null && !r.trim().isEmpty())
45  .collect(Collectors.toSet());
46  }
static String relativeToAbsoluteURI(String rootUrl, String relative)
Definition: PairwiseSubMapperUtils.java:143
static final Logger logger
Definition: PairwiseSubMapperUtils.java:19

◆ resolveValidSectorIdentifier() [1/2]

static String org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.resolveValidSectorIdentifier ( String  sectorIdentifierUri)
inlinestatic

Tries to resolve a valid sector identifier from a sector identifier URI.

引数
sectorIdentifierUri
戻り値
a sector identifier iff. the sector identifier URI is a valid URI, contains a valid scheme and contains a valid host component.
54  {
55  URI uri;
56  try {
57  uri = new URI(sectorIdentifierUri);
58  } catch (URISyntaxException e) {
59  logger.debug("Invalid sector identifier URI", e);
60  return null;
61  }
62 
63  if (uri.getScheme() == null) {
64  logger.debugv("Invalid sector identifier URI: {0}", sectorIdentifierUri);
65  return null;
66  }
67 
68  /*if (!uri.getScheme().equalsIgnoreCase("https")) {
69  logger.debugv("The sector identifier URI scheme must be HTTPS. Was '{0}'", uri.getScheme());
70  return null;
71  }*/
72 
73  if (uri.getHost() == null) {
74  logger.debug("The sector identifier URI must specify a host");
75  return null;
76  }
77 
78  return uri.getHost();
79  }
static final Logger logger
Definition: PairwiseSubMapperUtils.java:19

◆ resolveValidSectorIdentifier() [2/2]

static String org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.resolveValidSectorIdentifier ( String  clientRootUrl,
Set< String >  clientRedirectUris 
)
inlinestatic

Tries to resolve a valid sector identifier from the redirect URIs registered on a client.

引数
clientRootUrlRoot url registered on the client.
clientRedirectUrisRedirect URIs registered on the client.
戻り値
a sector identifier iff. all the registered redirect URIs are located at the same host, otherwise
null
.
88  {
89  Set<String> hosts = new HashSet<>();
90  for (String redirectUri : resolveValidRedirectUris(clientRootUrl, clientRedirectUris)) {
91  try {
92  URI uri = new URI(redirectUri);
93  hosts.add(uri.getHost());
94  } catch (URISyntaxException e) {
95  logger.debugv("client redirect uris contained an invalid uri: {0}", redirectUri);
96  }
97  }
98  if (hosts.isEmpty()) {
99  logger.debug("could not infer any valid sector_identifiers from client redirect uris");
100  return null;
101  }
102  if (hosts.size() > 1) {
103  logger.debug("the client redirect uris contained multiple hosts");
104  return null;
105  }
106  return hosts.iterator().next();
107  }
static Set< String > resolveValidRedirectUris(String clientRootUrl, Collection< String > clientRedirectUris)
Definition: PairwiseSubMapperUtils.java:28
static final Logger logger
Definition: PairwiseSubMapperUtils.java:19

メンバ詳解

◆ logger

final Logger org.keycloak.protocol.oidc.utils.PairwiseSubMapperUtils.logger = Logger.getLogger(PairwiseSubMapperUtils.class)
staticprivate

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