use of org.infinispan.server.configuration.security.TokenRealmConfiguration in project infinispan by infinispan.
the class Server method getLoginConfiguration.
@Override
public Map<String, String> getLoginConfiguration(ProtocolServer protocolServer) {
Map<String, String> loginConfiguration = new HashMap<>();
// Get the REST endpoint's authentication configuration
RestServerConfiguration rest = (RestServerConfiguration) protocolServer.getConfiguration();
if (rest.authentication().mechanisms().contains("BEARER_TOKEN")) {
// Find the token realm
RealmConfiguration realm = serverConfiguration.security().realms().getRealm(rest.authentication().securityRealm());
TokenRealmConfiguration realmConfiguration = realm.realmProviders().stream().filter(r -> r instanceof TokenRealmConfiguration).map(r -> (TokenRealmConfiguration) r).findFirst().get();
loginConfiguration.put("mode", "OIDC");
loginConfiguration.put("url", realmConfiguration.authServerUrl());
loginConfiguration.put("realm", realmConfiguration.name());
loginConfiguration.put("clientId", realmConfiguration.clientId());
} else {
loginConfiguration.put("mode", "HTTP");
for (String mechanism : rest.authentication().mechanisms()) {
loginConfiguration.put(mechanism, "true");
}
}
Authenticator authenticator = rest.authentication().authenticator();
loginConfiguration.put("ready", Boolean.toString(authenticator == null || authenticator.isReadyForHttpChallenge()));
return loginConfiguration;
}
use of org.infinispan.server.configuration.security.TokenRealmConfiguration in project infinispan by infinispan.
the class ServerConfigurationSerializer method writeSecurityRealms.
private void writeSecurityRealms(ConfigurationWriter writer, RealmsConfiguration realms) {
if (!realms.realms().isEmpty()) {
writer.writeStartArrayElement(Element.SECURITY_REALMS);
for (Map.Entry<String, RealmConfiguration> e : realms.realms().entrySet()) {
RealmConfiguration realm = e.getValue();
writer.writeStartElement(Element.SECURITY_REALM);
realm.attributes().write(writer);
writeServerIdentities(writer, realm.serverIdentitiesConfiguration());
for (RealmProvider provider : realm.realmProviders()) {
if (provider instanceof FileSystemRealmConfiguration) {
writeRealm(writer, (FileSystemRealmConfiguration) provider);
} else if (provider instanceof LdapRealmConfiguration) {
writeRealm(writer, (LdapRealmConfiguration) provider);
} else if (provider instanceof LocalRealmConfiguration) {
writeRealm(writer, (LocalRealmConfiguration) provider);
} else if (provider instanceof PropertiesRealmConfiguration) {
writeRealm(writer, (PropertiesRealmConfiguration) provider);
} else if (provider instanceof TokenRealmConfiguration) {
writeRealm(writer, (TokenRealmConfiguration) provider);
} else if (provider instanceof TrustStoreConfiguration) {
writeRealm(writer, (TrustStoreRealmConfiguration) provider);
}
}
// SECURITY_REALM
writer.writeEndElement();
}
// SECURITY_REALMS
writer.writeEndArrayElement();
}
}
Aggregations