コード例 #1
0
  protected AuthOutcome handleSamlRequest(String samlRequest, String relayState) {
    SAMLDocumentHolder holder = null;
    boolean postBinding = false;
    String requestUri = facade.getRequest().getURI();
    if (facade.getRequest().getMethod().equalsIgnoreCase("GET")) {
      // strip out query params
      int index = requestUri.indexOf('?');
      if (index > -1) {
        requestUri = requestUri.substring(0, index);
      }
      holder = SAMLRequestParser.parseRequestRedirectBinding(samlRequest);
    } else {
      postBinding = true;
      holder = SAMLRequestParser.parseRequestPostBinding(samlRequest);
    }
    RequestAbstractType requestAbstractType = (RequestAbstractType) holder.getSamlObject();
    if (!requestUri.equals(requestAbstractType.getDestination().toString())) {
      log.error(
          "expected destination '"
              + requestUri
              + "' got '"
              + requestAbstractType.getDestination()
              + "'");
      return AuthOutcome.FAILED;
    }

    if (requestAbstractType instanceof LogoutRequestType) {
      if (deployment.getIDP().getSingleLogoutService().validateRequestSignature()) {
        try {
          validateSamlSignature(holder, postBinding, GeneralConstants.SAML_REQUEST_KEY);
        } catch (VerificationException e) {
          log.error("Failed to verify saml request signature", e);
          return AuthOutcome.FAILED;
        }
      }
      LogoutRequestType logout = (LogoutRequestType) requestAbstractType;
      return logoutRequest(logout, relayState);

    } else {
      log.error("unknown SAML request type");
      return AuthOutcome.FAILED;
    }
  }
コード例 #2
0
ファイル: SamlService.java プロジェクト: gautric/keycloak
 @Override
 protected SAMLDocumentHolder extractResponseDocument(String response) {
   return SAMLRequestParser.parseResponseRedirectBinding(response);
 }
コード例 #3
0
ファイル: SamlService.java プロジェクト: gautric/keycloak
 @Override
 protected SAMLDocumentHolder extractRequestDocument(String samlRequest) {
   return SAMLRequestParser.parseRequestRedirectBinding(samlRequest);
 }
コード例 #4
0
 protected SAMLDocumentHolder extractPostBindingResponse(String response) {
   byte[] samlBytes = PostBindingUtil.base64Decode(response);
   return SAMLRequestParser.parseResponseDocument(samlBytes);
 }