keycloak-service
公開メンバ関数 | 限定公開メンバ関数 | 限定公開変数類 | 静的関数 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.services.x509.HaProxySslClientCertificateLookup クラス
org.keycloak.services.x509.HaProxySslClientCertificateLookup の継承関係図
Inheritance graph
org.keycloak.services.x509.HaProxySslClientCertificateLookup 連携図
Collaboration graph

公開メンバ関数

 HaProxySslClientCertificateLookup (String sslCientCertHttpHeader, String sslCertChainHttpHeaderPrefix, int certificateChainLength)
 
void close ()
 
X509Certificate [] getCertificateChain (HttpRequest httpRequest) throws GeneralSecurityException
 

限定公開メンバ関数

X509Certificate decodeCertificateFromPem (String pem) throws PemException
 
X509Certificate getCertificateFromHttpHeader (HttpRequest request, String httpHeader) throws GeneralSecurityException
 

限定公開変数類

final String sslClientCertHttpHeader
 
final String sslCertChainHttpHeaderPrefix
 

静的関数

static String getHeaderValue (HttpRequest httpRequest, String headerName)
 

静的非公開変数類

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

詳解

The provider allows to extract X.509 client certificate forwarded to the keycloak middleware configured behind the haproxy reverse proxy.

著者
Peter Nalyvayko
バージョン
Revision
1
から
3/27/2017

構築子と解体子

◆ HaProxySslClientCertificateLookup()

org.keycloak.services.x509.HaProxySslClientCertificateLookup.HaProxySslClientCertificateLookup ( String  sslCientCertHttpHeader,
String  sslCertChainHttpHeaderPrefix,
int  certificateChainLength 
)
inline
42  {
43  super(sslCientCertHttpHeader, sslCertChainHttpHeaderPrefix, certificateChainLength);
44  }
final int certificateChainLength
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:43
final String sslCertChainHttpHeaderPrefix
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:42

関数詳解

◆ close()

void org.keycloak.services.x509.AbstractClientCertificateFromHttpHeadersLookup.close ( )
inlineinherited
62  {
63 
64  }

◆ decodeCertificateFromPem()

X509Certificate org.keycloak.services.x509.HaProxySslClientCertificateLookup.decodeCertificateFromPem ( String  pem) throws PemException
inlineprotected
47  {
48 
49  if (pem == null) {
50  return null;
51  }
52  return PemUtils.decodeCertificate(pem);
53  }

◆ getCertificateChain()

X509Certificate [] org.keycloak.services.x509.AbstractClientCertificateFromHttpHeadersLookup.getCertificateChain ( HttpRequest  httpRequest) throws GeneralSecurityException
inlineinherited

org.keycloak.services.x509.X509ClientCertificateLookupを実装しています。

117  {
118  List<X509Certificate> chain = new ArrayList<>();
119 
120  // Get the client certificate
121  X509Certificate cert = getCertificateFromHttpHeader(httpRequest, sslClientCertHttpHeader);
122  if (cert != null) {
123  chain.add(cert);
124  // Get the certificate of the client certificate chain
125  for (int i = 0; i < certificateChainLength; i++) {
126  try {
127  String s = String.format("%s_%s", sslCertChainHttpHeaderPrefix, i);
128  cert = getCertificateFromHttpHeader(httpRequest, s);
129  if (cert != null) {
130  chain.add(cert);
131  }
132  }
133  catch(GeneralSecurityException e) {
134  logger.warn(e.getMessage(), e);
135  }
136  }
137  }
138  return chain.toArray(new X509Certificate[0]);
139  }
final String sslClientCertHttpHeader
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:41
final int certificateChainLength
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:43
X509Certificate getCertificateFromHttpHeader(HttpRequest request, String httpHeader)
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:85
final String sslCertChainHttpHeaderPrefix
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:42
static final Logger logger
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:39

◆ getCertificateFromHttpHeader()

X509Certificate org.keycloak.services.x509.AbstractClientCertificateFromHttpHeadersLookup.getCertificateFromHttpHeader ( HttpRequest  request,
String  httpHeader 
) throws GeneralSecurityException
inlineprotectedinherited
85  {
86 
87  String encodedCertificate = getHeaderValue(request, httpHeader);
88 
89  // Remove double quotes
90  encodedCertificate = trimDoubleQuotes(encodedCertificate);
91 
92  if (encodedCertificate == null ||
93  encodedCertificate.trim().length() == 0) {
94  logger.warnf("HTTP header \"%s\" is empty", httpHeader);
95  return null;
96  }
97 
98  try {
99  X509Certificate cert = decodeCertificateFromPem(encodedCertificate);
100  if (cert == null) {
101  logger.warnf("HTTP header \"%s\" does not contain a valid x.509 certificate\n%s",
102  httpHeader, encodedCertificate);
103  } else {
104  logger.debugf("Found a valid x.509 certificate in \"%s\" HTTP header",
105  httpHeader);
106  }
107  return cert;
108  }
109  catch(PemException e) {
110  logger.error(e.getMessage(), e);
111  throw new GeneralSecurityException(e);
112  }
113  }
static String getHeaderValue(HttpRequest httpRequest, String headerName)
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:66
static String trimDoubleQuotes(String quotedString)
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:70
static final Logger logger
Definition: AbstractClientCertificateFromHttpHeadersLookup.java:39

◆ getHeaderValue()

static String org.keycloak.services.x509.AbstractClientCertificateFromHttpHeadersLookup.getHeaderValue ( HttpRequest  httpRequest,
String  headerName 
)
inlinestaticpackageinherited
66  {
67  return httpRequest.getHttpHeaders().getRequestHeaders().getFirst(headerName);
68  }

メンバ詳解

◆ logger

final Logger org.keycloak.services.x509.HaProxySslClientCertificateLookup.logger = Logger.getLogger(HaProxySslClientCertificateLookup.class)
staticprivate

◆ sslCertChainHttpHeaderPrefix

final String org.keycloak.services.x509.AbstractClientCertificateFromHttpHeadersLookup.sslCertChainHttpHeaderPrefix
protectedinherited

◆ sslClientCertHttpHeader

final String org.keycloak.services.x509.AbstractClientCertificateFromHttpHeadersLookup.sslClientCertHttpHeader
protectedinherited

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