throw new ResourceException(UTIL.getString("no_auth_server")); builder.security().authentication().enable().saslMechanism(saslMechanism).username(userName) .realm(authenticationRealm).password(password).serverName(authenticationServerName); } else if (saslMechanism != null && saslMechanism.equals("EXTERNAL")) { builder.security().authentication().enable().saslMechanism("EXTERNAL").callbackHandler(callback) .ssl().enable().keyStoreFileName(keyStoreFileName) .keyStorePassword(keyStorePassword.toCharArray()).trustStoreFileName(trustStoreFileName) .trustStorePassword(trustStorePassword.toCharArray());
private RemoteCacheManager createRemoteCache(Map<String, String> properties) { String username = properties.get(USERNAME); String password = properties.get(PASSWORD); String realm = properties.get(REALM); String host = properties.get(HOST); String port = properties.get(PORT); try { ConfigurationBuilder builder = getMaybeSecurityBuilder(username, password, realm) .addServer() .host(host) .port(Integer.parseInt(port)) .marshaller(new ProtoStreamMarshaller()) .marshaller(marshaller); return new RemoteCacheManager(builder.build()); } catch (Exception e) { throw new InfinispanException(MessageFormat.format("Error trying to connect to server <{0}:{1}>", host, port), e); } }
.security() .authentication() .serverName(serverName) //define server name, should be specified in XML configuration on JDG side .saslMechanism("DIGEST-MD5") // define SASL mechanism, in this example we use DIGEST with MD5 hash .callbackHandler(new LoginHandler(username, password.toCharArray(), realm)) // define login handler, implementation defined .enable() .build();
private AuthenticationConfigurationBuilder getMaybeSecurityBuilder(String username, String password, String realm) { ConfigurationBuilder b = new ConfigurationBuilder(); if (StringUtils.isNotEmpty(username)) { checkNotEmpty("password", password); checkNotEmpty("realm", realm); return b.security().authentication() .enable() .saslMechanism(SASL_MECHANISM) .callbackHandler(new LoginHandler(username, password.toCharArray(), realm)); } else { return b.security().authentication().disable(); } }
public SecurityConfigurationHelper forSubject(Subject subj) { this.security().authentication().clientSubject(subj).callbackHandler(new SimpleLoginHandler("", "")); //callback handle is required by ISPN config validation return this; }
public SecurityConfigurationHelper forIspnServer(RemoteInfinispanServer ispnServer) { String hostname = ispnServer.getHotrodEndpoint().getInetAddress().getHostName(); this.addServer().host(hostname).port(ispnServer.getHotrodEndpoint().getPort()); this.security().authentication().saslMechanism(saslMech).enable(); return this; }
public SecurityConfigurationHelper forExternalAuth() { this.security().authentication().callbackHandler(new VoidCallbackHandler()); return this; }
public SecurityConfigurationHelper withServerName(String serverName) { this.security().authentication().serverName(serverName); return this; } }
private AuthenticationConfigurationBuilder getMaybeSecurityBuilder(String username, String password, String realm) { ConfigurationBuilder b = new ConfigurationBuilder(); if (StringUtils.isNotEmpty(username)) { checkNotEmpty("password", password); checkNotEmpty("realm", realm); return b.security().authentication() .enable() .saslMechanism(SASL_MECHANISM) .callbackHandler(new LoginHandler(username, password.toCharArray(), realm)); } else { return b.security().authentication().disable(); } }
public SecurityConfigurationHelper forCredentials(String login, String password) { this.security().authentication().callbackHandler(new SimpleLoginHandler(login, password, DEFAULT_TEST_REALM)); return this; }
private RemoteCacheManager createRemoteCache(Map<String, String> properties) { String username = properties.get(USERNAME); String password = properties.get(PASSWORD); String realm = properties.get(REALM); String host = properties.get(HOST); String port = properties.get(PORT); try { ConfigurationBuilder builder = getMaybeSecurityBuilder(username, password, realm) .addServer() .host(host) .port(Integer.parseInt(port)) .marshaller(new ProtoStreamMarshaller()) .marshaller(marshaller); return new RemoteCacheManager(builder.build()); } catch (Exception e) { throw new InfinispanException(MessageFormat.format("Error trying to connect to server <{0}:{1}>", host, port), e); } }