Refine search
protected SaslClient createDigestSaslClient(String[] mechanismNames, String saslDefaultRealm, CallbackHandler saslClientCallbackHandler) throws IOException { return Sasl.createSaslClient(mechanismNames, null, null, saslDefaultRealm, saslProps, saslClientCallbackHandler); }
public SaslServer getServer() throws SaslException { return Sasl.createSaslServer(mechanism, protocol, serverName, props, cbh); } });
FastSaslServerFactory(Map<String,?> props) { final Enumeration<SaslServerFactory> factories = Sasl.getSaslServerFactories(); while (factories.hasMoreElements()) { SaslServerFactory factory = factories.nextElement(); for (String mech : factory.getMechanismNames(props)) { if (!factoryCache.containsKey(mech)) { factoryCache.put(mech, new ArrayList<SaslServerFactory>()); } factoryCache.get(mech).add(factory); } } }
@SuppressWarnings("unchecked") Map<String, ?> propsMap = (Map) props; sc = Sasl.createSaslClient(mechs, authzid, name, host, propsMap, cbh); } catch (SaslException sex) { logger.fine("SASL client " + sc.getMechanismName()); args.writeAtom(sc.getMechanismName()); if (pr.hasCapability("SASL-IR") && sc.hasInitialResponse()) { String irs; byte[] ba = sc.evaluateChallenge(new byte[0]);
@Override public byte[] run() throws Exception { Map<String, String> props = new HashMap<>(); props.put("javax.security.sasl.server.authentication", "true"); saslClient = Sasl.createSaslClient(new String[]{NAME}, null, protocol, serverName, props, null); if (saslClient.hasInitialResponse()) { return saslClient.evaluateChallenge(new byte[0]); } return null; } });
p.put("gnu.crypto.sasl.password", password); SaslClient sasl = Sasl.createSaslClient(m, null, "smtp", socket.getInetAddress().getHostName(), p, ch); cmd.append(' '); cmd.append(mechanism); if (sasl.hasInitialResponse()) byte[] init = sasl.evaluateChallenge(new byte[0]); cmd.append(new String(init, "US-ASCII")); String qop = (String) sasl.getNegotiatedProperty(Sasl.QOP); if ("auth-int".equalsIgnoreCase(qop) || "auth-conf".equalsIgnoreCase(qop))
private Command startAuth() throws SaslException { // destroy previous client. destroySaslClient(); this.saslClient = Sasl.createSaslClient(authInfo.getMechanisms(), null, "memcached", memcachedTCPSession.getRemoteSocketAddress().toString(), null, this.authInfo.getCallbackHandler()); byte[] response = saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY_BYTES) : EMPTY_BYTES; CountDownLatch latch = new CountDownLatch(1); Command command = this.commandFactory.createAuthStartCommand(saslClient.getMechanismName(), latch, response); if (!this.memcachedTCPSession.isClosed()) this.memcachedTCPSession.write(command); else { log.error("Authentication fail,because the connection has been closed"); throw new RuntimeException("Authentication fai,connection has been close"); } return command; }
String protocol = adminConfig.getProtocol(); String serverName = adminConfig.getServerName(); saslClient = Sasl.createSaslClient(new String[]{"GSSAPI"}, null, protocol, serverName, props, null); } catch (SaslException e) { response = saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY) : EMPTY; } catch (SaslException e) { LOG.error("Sasl client evaluate challenge failed." + e); while (!saslClient.isComplete()) { int ssComplete = message.getInt(); if (ssComplete == 0) {
private void runNegotiation(CallbackHandler clientCbh, CallbackHandler serverCbh) throws SaslException { String mechanism = AuthMethod.PLAIN.getMechanismName(); SaslClient saslClient = Sasl.createSaslClient( new String[]{ mechanism }, null, null, null, null, clientCbh); assertNotNull(saslClient); SaslServer saslServer = Sasl.createSaslServer( mechanism, null, "localhost", null, serverCbh); assertNotNull("failed to find PLAIN server", saslServer); byte[] response = saslClient.evaluateChallenge(new byte[0]); assertNotNull(response); assertTrue(saslClient.isComplete()); response = saslServer.evaluateResponse(response); assertNull(response); assertTrue(saslServer.isComplete()); assertNotNull(saslServer.getAuthorizationID()); }
p.put("gnu.crypto.sasl.password", password); SaslClient sasl = Sasl.createSaslClient(m, null, "pop3", socket.getInetAddress().getHostName(), p, ch); String qop = (String) sasl.getNegotiatedProperty(Sasl.QOP); if ("auth-int".equalsIgnoreCase(qop) || "auth-conf".equalsIgnoreCase(qop)) byte[] r0 = sasl.evaluateChallenge(c1); byte[] r1 = BASE64.encode(r0); // response out.write(r1);
@Override public void initialize() { try { SaslClient sc = Sasl.createSaslClient(mech, null, "memcached", serverName, props, cbh); byte[] response = buildResponse(sc); String mechanism = sc.getMechanismName(); prepareBuffer(mechanism, 0, response); } catch (SaslException e) { // XXX: Probably something saner can be done here. throw new RuntimeException("Can't make SASL go.", e); } }
private static SaslClientFactory getSaslClientFactory(String mechName, Map props) { if (mechName == null) { return null; } if ("ANONYMOUS".equals(mechName)) { mechName = "PLAIN"; } for(Enumeration factories = Sasl.getSaslClientFactories(); factories.hasMoreElements();) { SaslClientFactory factory = (SaslClientFactory) factories.nextElement(); String[] mechs = factory.getMechanismNames(props); for (int i = 0; mechs != null && i < mechs.length; i++) { if (mechName.endsWith(mechs[i])) { return factory; } } } return null; }
@SuppressWarnings("unchecked") Map<String, ?> propsMap = (Map) props; sc = Sasl.createSaslClient(mechs, authzid, name, host, propsMap, cbh); } catch (SaslException sex) { logger.fine("SASL client " + sc.getMechanismName()); args.writeAtom(sc.getMechanismName()); if (pr.hasCapability("SASL-IR") && sc.hasInitialResponse()) { String irs; byte[] ba = sc.evaluateChallenge(new byte[0]);
@Override public byte[] run() throws Exception { Map<String, String> props = new HashMap<>(); props.put("javax.security.sasl.server.authentication", "true"); saslClient = Sasl.createSaslClient(new String[]{NAME}, null, protocol, serverName, props, null); if (saslClient.hasInitialResponse()) { return saslClient.evaluateChallenge(new byte[0]); } return null; } });
p.put("gnu.crypto.sasl.username", username); p.put("gnu.crypto.sasl.password", password); SaslClient sasl = Sasl.createSaslClient(m, null, "smtp", cmd.append(' '); cmd.append(mechanism); if (sasl.hasInitialResponse()) { cmd.append(' '); byte[] init = sasl.evaluateChallenge(new byte[0]); if (init.length == 0) { cmd.append('='); byte[] c0 = response.getBytes("US-ASCII"); byte[] c1 = BASE64.decode(c0); // challenge byte[] r0 = sasl.evaluateChallenge(c1); byte[] r1 = BASE64.encode(r0); // response out.write(r1);
private Command startAuth() throws SaslException { // destroy previous client. destroySaslClient(); this.saslClient = Sasl.createSaslClient(authInfo.getMechanisms(), null, "memcached", memcachedTCPSession.getRemoteSocketAddress().toString(), null, this.authInfo.getCallbackHandler()); byte[] response = saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY_BYTES) : EMPTY_BYTES; CountDownLatch latch = new CountDownLatch(1); Command command = this.commandFactory.createAuthStartCommand(saslClient.getMechanismName(), latch, response); if (!this.memcachedTCPSession.isClosed()) this.memcachedTCPSession.write(command); else { log.error("Authentication fail,because the connection has been closed"); throw new RuntimeException("Authentication fai,connection has been close"); } return command; }
String protocol = adminConfig.getProtocol(); String serverName = adminConfig.getServerName(); saslClient = Sasl.createSaslClient(new String[]{"GSSAPI"}, null, protocol, serverName, props, null); } catch (SaslException e) { response = saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY) : EMPTY; } catch (SaslException e) { LOG.error("Sasl client evaluate challenge failed." + e); while (!saslClient.isComplete()) { int ssComplete = message.getInt(); if (ssComplete == 0) {
private void runNegotiation(CallbackHandler clientCbh, CallbackHandler serverCbh) throws SaslException { String mechanism = AuthMethod.PLAIN.getMechanismName(); SaslClient saslClient = Sasl.createSaslClient( new String[]{ mechanism }, null, null, null, null, clientCbh); assertNotNull(saslClient); SaslServer saslServer = Sasl.createSaslServer( mechanism, null, "localhost", null, serverCbh); assertNotNull("failed to find PLAIN server", saslServer); byte[] response = saslClient.evaluateChallenge(new byte[0]); assertNotNull(response); assertTrue(saslClient.isComplete()); response = saslServer.evaluateResponse(response); assertNull(response); assertTrue(saslServer.isComplete()); assertNotNull(saslServer.getAuthorizationID()); }
p.put("gnu.crypto.sasl.username", username); p.put("gnu.crypto.sasl.password", password); SaslClient sasl = Sasl.createSaslClient(m, null, "imap", socket.getInetAddress(). getHostName(), p, ch); (String) sasl.getNegotiatedProperty(Sasl.QOP); if ("auth-int".equalsIgnoreCase(qop) || "auth-conf".equalsIgnoreCase(qop)) byte[] r0 = sasl.evaluateChallenge(c1); byte[] r1 = BASE64.encode(r0); // response out.write(r1);
@Override public void initialize() { try { SaslClient sc=Sasl.createSaslClient(mech, null, "memcached", serverName, props, cbh); byte[] response = buildResponse(sc); String mechanism = sc.getMechanismName(); prepareBuffer(mechanism, 0, response); } catch(SaslException e) { // XXX: Probably something saner can be done here. throw new RuntimeException("Can't make SASL go.", e); } }