@Override public AuthenticationConfiguration create() { return new AuthenticationConfiguration(enabled, Collections.unmodifiableSet(allowedMechs), serverAuthenticationProvider, mechProperties, serverName, serverSubject); }
@Override public Builder<?> read(AuthenticationConfiguration template) { this.enabled = template.enabled(); this.allowedMechs.clear(); this.allowedMechs.addAll(template.allowedMechs()); this.serverAuthenticationProvider = template.serverAuthenticationProvider(); this.mechProperties = template.mechProperties(); this.serverName = template.serverName(); return this; }
public Authentication(Channel channel, HotRodServer server) { this.channel = channel; this.server = server; serverConfig = server.getConfiguration(); authenticationConfig = serverConfig.authentication(); enabled = authenticationConfig.enabled(); requireAuthentication = !authenticationConfig.mechProperties().containsKey(Sasl.POLICY_NOANONYMOUS) || authenticationConfig.mechProperties().get(Sasl.POLICY_NOANONYMOUS).equals("true"); }
ServerAuthenticationProvider sap = authenticationConfig.serverAuthenticationProvider(); callbackHandler = sap.getCallbackHandler(mech, authenticationConfig.mechProperties()); final SaslServerFactory ssf; if ("EXTERNAL".equals(mech)) { ssf = server.getSaslServerFactory(mech); if (authenticationConfig.serverSubject() != null) { saslServer = Subject.doAs(authenticationConfig.serverSubject(), (PrivilegedExceptionAction<SaslServer>) () -> ssf.createSaslServer(mech, "hotrod", authenticationConfig.serverName(), authenticationConfig.mechProperties(), callbackHandler)); } else { saslServer = ssf.createSaslServer(mech, "hotrod", authenticationConfig.serverName(), authenticationConfig.mechProperties(), callbackHandler);
private void setupSasl() { Iterator<SaslServerFactory> saslFactories = SaslUtils.getSaslServerFactories(this.getClass().getClassLoader(), true); while (saslFactories.hasNext()) { SaslServerFactory saslFactory = saslFactories.next(); String[] saslFactoryMechs = saslFactory.getMechanismNames(configuration.authentication().mechProperties()); for (String supportedMech : saslFactoryMechs) { for (String mech : configuration.authentication().allowedMechs()) { if (supportedMech.equals(mech)) { saslMechFactories.putIfAbsent(mech, saslFactory); } } } } }
public void authMechList(HotRodHeader header) { writeResponse(header, header.encoder().authMechListResponse(header, server, channel.alloc(), authenticationConfig.allowedMechs())); }