出品者:Noemi P.

Keycloak is an open-source IAM platform providing user federation, SSO, strong authentication, and fine-grained authorization for modern applications and services. Includes React UIs, a Quarkus runtime, TypeScript admin client, and a full test framework.
This block provides the Keycloak SAML adapter libraries for Java/JVM-based service providers, including core SAML authentication handlers, XML configuration parsers, role mapping utilities, and SPI extension points. It targets backend Java developers integrating SAML 2.0 SSO with Keycloak into Wildfly/JBoss, servlet-based, or custom Java applications. This is a Java Maven project, not a Node.js package.
saml/ - SAML 2.0 adapter modules: core logic, public API surface, and Wildfly/Elytron integrationsaml/core/ - Core SAML adapter: authentication handlers, session management, config parsing, role mappingsaml/core-public/ - Public API surface intended for downstream consumers and SPI implementorssaml/wildfly/ - Wildfly-specific SAML adapter integration and deployment descriptorssaml/wildfly-elytron/ - Wildfly Elytron security framework integration for SAMLspi/ - Keycloak SPI (Service Provider Interface) extension modulespom.xml - Root Maven build descriptor; defines module structure and dependency managementsaml/pom.xml - Parent POM for all SAML sub-modulesThis is a Java Maven project. There is no npm package. Add the following to your pom.xml:
# No npm install - this is a Java library.
# Add the following Maven dependencies to your pom.xml instead:
# For SAML core adapter:
# groupId: org.keycloak
# artifactId: keycloak-saml-core
# version: (match your Keycloak server version, e.g. 24.0.0)
# For Wildfly SAML adapter:
# groupId: org.keycloak
# artifactId: keycloak-saml-wildfly-adapter
# version: (match your Keycloak server version)
Maven pom.xml dependency block:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core</artifactId>
<version>24.0.0</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core-public</artifactId>
<version>24.0.0</version>
</dependency>
Native build steps required:
mvn clean install from source/ root.隔離されたサンドボックスを起動しサーバー側で実行 — ローカル設定不要。
このバージョンの Tetrees AI Review
This Express backend / api completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
パイプライン avcp-2026-08-04.1 · SHA-256 b46170309e77d1ca…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
レビュー日 2026年8月4日
この製品をお使いのAI IDE・Webビルダー・クラウドIDEに直接取り込みます。
Tetreesを対応AI IDEに接続し、所有製品の一覧取得と検証済みZIPの取得を、販売者のアップロード権限を公開せずに行えます。
まだレビューがありません。
Sign in to join the discussion
Loading discussion…
Clone / copy the source/ directory into your Java project workspace, or reference the pre-built JARs from Maven Central.
Build from source (if not using Maven Central):
cd source/
mvn clean install -DskipTests
Add to your application POM (see XML above in Required dependencies).
Place keycloak-saml.xml (your SP configuration) at WEB-INF/keycloak-saml.xml in your WAR, or provide it via SamlConfigResolver.
Register the authentication filter in WEB-INF/web.xml:
<filter>
<filter-name>Keycloak SAML Filter</filter-name>
<filter-class>org.keycloak.adapters.saml.servlet.SamlFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Keycloak SAML Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Environment / config: Set IDP metadata URL or inline the IDP certificate. All configuration lives in keycloak-saml.xml; no environment variables are required beyond standard JVM args.
Wildfly users: Install the SAML adapter zip on the server and add <secure-deployment> to standalone.xml.
The following symbols are visible in the source file listing. No excerpts were provided, so documentation is based on class names and package structure as they appear in the file tree.
// org.keycloak.adapters.saml.SamlDeployment
public interface SamlDeployment {
IDP getIDP();
SP getSP();
// binding, name ID format, role mappings provider, etc.
}
Central configuration object representing a fully parsed SAML SP deployment. Use this to access IDP endpoint URLs, signing keys, SP entity ID, and assertion consumer service URLs after parsing keycloak-saml.xml.
// org.keycloak.adapters.saml.SamlDeploymentContext
public class SamlDeploymentContext {
public SamlDeploymentContext(SamlDeployment deployment);
public SamlDeployment resolveDeployment(HttpFacade facade);
}
Holds and resolves the SamlDeployment for the current request. Pass a SamlConfigResolver implementation to support multi-tenant SAML configurations resolved per-request.
// org.keycloak.adapters.saml.config.parsers.DeploymentBuilder
public class DeploymentBuilder {
public SamlDeployment build(
InputStream is,
ResourceLoader resourceLoader
) throws ParsingException;
}
Parses a keycloak-saml.xml input stream into a SamlDeployment. Use this in custom bootstrap code outside of a servlet container to programmatically load SAML configuration.
// org.keycloak.adapters.saml.SamlAuthenticator
public abstract class SamlAuthenticator {
public AuthOutcome authenticate();
protected abstract void assertionHandler(SamlSession session);
}
The primary authentication orchestrator. Extend this class to plug the SAML authentication flow into a custom HTTP framework. It drives the redirect/POST bindings, response validation, and session creation lifecycle.
// org.keycloak.adapters.saml.RoleMappingsProvider
public interface RoleMappingsProvider {
Set<String> mapRoles(
String principalName,
Set<String> roles
);
}
SPI for translating SAML assertion roles into application roles. Implement this interface and register via roleMappingsProvider config in keycloak-saml.xml to customize role translation logic.
Load and inspect a SAML deployment configuration at application startup without a servlet container.
import org.keycloak.adapters.saml.config.parsers.DeploymentBuilder;
import org.keycloak.adapters.saml.config.parsers.ResourceLoader;
import org.keycloak.adapters.saml.SamlDeployment;
import java.io.InputStream;
public class SamlConfigLoader {
public static SamlDeployment load() throws Exception {
InputStream is = SamlConfigLoader.class
.getResourceAsStream("/keycloak-saml.xml");
ResourceLoader loader = resource ->
SamlConfigLoader.class.getResourceAsStream(resource);
DeploymentBuilder builder = new DeploymentBuilder();
SamlDeployment deployment = builder.build(is, loader);
System.out.println("SP Entity ID: " + deployment.getEntityID());
System.out.println("IDP SSO URL: " +
deployment.getIDP().getSingleSignOnService().getRequestBindingUrl());
return deployment;
}
}
Map SAML assertion roles to application-specific roles using a custom provider.
import org.keycloak.adapters.saml.RoleMappingsProvider;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class AppRoleMappingsProvider implements RoleMappingsProvider {
private static final Map<String, String> ROLE_MAP = Map.of(
"saml-admin", "APP_ADMIN",
"saml-viewer", "APP_VIEWER"
);
@Override
public Set<String> mapRoles(String principalName, Set<String> roles) {
return roles.stream()
.map(r -> ROLE_MAP.getOrDefault(r, r))
.collect(Collectors.toSet());
}
@Override
public void init(SP.RoleMappingsProviderConfig config) { }
@Override
public void close() { }
}
Register in keycloak-saml.xml:
<RoleMappingsProvider id="custom-role-mapper"
class="com.example.AppRoleMappingsProvider"/>
Resolve a different SamlDeployment per incoming request based on hostname.
import org.keycloak.adapters.saml.SamlConfigResolver;
import org.keycloak.adapters.saml.SamlDeployment;
import org.keycloak.adapters.saml.SamlDeploymentContext;
import org.keycloak.adapters.spi.HttpFacade;
import org.keycloak.adapters.saml.config.parsers.DeploymentBuilder;
import org.keycloak.adapters.saml.config.parsers.ResourceLoader;
import java.io.InputStream;
import java.util.concurrent.ConcurrentHashMap;
public class TenantSamlConfigResolver implements SamlConfigResolver {
private final ConcurrentHashMap<String, SamlDeployment> cache =
new ConcurrentHashMap<>();
@Override
public SamlDeployment resolve(HttpFacade.Request request) {
String host = request.getHeader("Host");
return cache.computeIfAbsent(host, this::loadForTenant);
}
private SamlDeployment loadForTenant(String host) {
String resource = "/saml/" + host + "/keycloak-saml.xml";
InputStream is = getClass().getResourceAsStream(resource);
ResourceLoader loader = r -> getClass().getResourceAsStream(r);
try {
return new DeploymentBuilder().build(is, loader);
} catch (Exception e) {
throw new RuntimeException("Failed to load SAML config for: " + host, e);
}
}
}
saml/ - Parent directory for all SAML adapter modules; contains module POM.saml/core/ - Core SAML adapter logic: authentication handlers, session model, XML config parsers, role mapping.saml/core/src/main/java/org/keycloak/adapters/saml/ - Top-level SAML adapter classes including SamlAuthenticator, SamlDeployment, SamlSession, and SamlSessionStore.saml/core/src/main/java/org/keycloak/adapters/saml/config/ - Config POJOs: IDP, SP, Key, KeycloakSamlAdapter.saml/core/src/main/java/org/keycloak/adapters/saml/config/parsers/ - XML parsers for keycloak-saml.xml; DeploymentBuilder is the entry point.saml/core/src/main/java/org/keycloak/adapters/saml/profile/ - Authentication handler profiles: web browser SSO (BrowserHandler, SamlEndpoint) and ECP.saml/core/src/main/java/org/keycloak/adapters/saml/rotation/ - Public key locator using SAML IDP descriptor for key rotation support.saml/core/src/main/java/org/keycloak/adapters/saml/descriptor/ - Parsers for SAML metadata descriptor documents (IDP key extraction).saml/core/src/main/java/org/keycloak/adapters/cloned/ - Cloned HTTP client utilities for adapter-internal use; not part of the public API.saml/core-public/ - Stable public API JAR; depend on this rather than saml/core for SPI implementations.saml/wildfly/ - Wildfly subsystem integration, module descriptors, and server-side adapter wiring.saml/wildfly-elytron/ - Elytron security framework bridge for Wildfly SAML authentication.spi/ - Keycloak SPI extension modules for server-side customization.pom.xml - Root Maven build file; use mvn clean install from here.24.0.0).keycloak-saml.xml on classpath: DeploymentBuilder throws a NullPointerException if the stream is null. Fix: verify the file is in WEB-INF/ and the ResourceLoader lambda resolves relative paths correctly.SamlDescriptorPublicKeyLocator with the IDP metadata URL so keys are refreshed automatically.saml/core are not visible to deployments unless the module is listed in jboss-deployment-structure.xml. Fix: add <module name="org.keycloak.keycloak-saml-core"/> to your deployment descriptor.<SP ... EcpEnabled="true"> in keycloak-saml.xml; it is disabled by default.RoleMappingsProvider is on a different classloader than the adapter, it will silently fall back to no mapping. Fix: ensure the provider class is in the same WAR or module as the adapter.I have the Keycloak Java SAML adapter source code located in the `source/` directory
of this project. I also have a USAGE.md file that documents the real class names,
package structure, and integration patterns for this library.
Please help me integrate the Keycloak SAML adapter (keycloak-saml-core) into my
existing Java web application step by step:
1. Read USAGE.md and the file tree under source/ to understand the available classes.
2. Add the correct Maven dependencies to my pom.xml (match my Keycloak server version).
3. Create or update WEB-INF/keycloak-saml.xml with my IDP and SP settings.
4. Register the SAML filter in WEB-INF/web.xml.
5. If I need multi-tenancy, implement SamlConfigResolver using the pattern in USAGE.md.
6. If I need custom role mapping, implement RoleMappingsProvider and register it.
7. Show me how to use DeploymentBuilder to validate my configuration at startup.
8. Point out any version pinning or classloader pitfalls from the Common Pitfalls section.
My project details: [INSERT YOUR FRAMEWORK, JAVA VERSION, AND KEYCLOAK SERVER VERSION HERE]
This source is part of the Keycloak project, licensed under the Apache License, Version 2.0. See source/LICENSE or https://www.apache.org/licenses/LICENSE-2.0.
Upstream repository: https://github.com/keycloak/keycloak
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
完全なインストールガイドと統合プロンプトは購入後に解放されます。
Automation, Utilities & Developer Tools
無料