getSASLAuthentication().challengeReceived(challengeData); break; case "success": BodyQName.create(XMPPBOSHConnection.BOSH_URI, "to"), getXMPPServiceDomain().toString()).build()); Success success = new Success(parser.nextText()); getSASLAuthentication().authenticated(success); break; case "features": if ("urn:ietf:params:xml:ns:xmpp-sasl".equals(parser.getNamespace(null))) { final SASLFailure failure = PacketParserUtils.parseSASLFailure(parser); getSASLAuthentication().authenticationFailed(failure);
@Override protected void loginInternal(String username, String password, Resourcepart resource) throws XMPPException, SmackException, IOException, InterruptedException { // Authenticate using SASL saslAuthentication.authenticate(username, password, config.getAuthzid(), null); bindResourceAndEstablishSession(resource); afterSuccessfulLogin(false); }
/** * Create a new XMPPConnection to an XMPP server. * * @param configuration The configuration which is used to establish the connection. */ protected AbstractXMPPConnection(ConnectionConfiguration configuration) { saslAuthentication = new SASLAuthentication(this, configuration); config = configuration; SmackDebuggerFactory debuggerFactory = configuration.getDebuggerFactory(); if (debuggerFactory != null) { debugger = debuggerFactory.create(this); } else { debugger = null; } // Notify listeners that a new connection has been established for (ConnectionCreationListener listener : XMPPConnectionRegistry.getConnectionCreationListeners()) { listener.connectionCreated(this); } }
saslAuthentication.hasNonAnonymousAuthentication()) { response = saslAuthentication.authenticate(username, password, resource);
protected void authenticate() throws IOException, XMPPException { //final AuthMechanism packet = new AuthMechanism(NAME, null); // Send the authentication to the server getSASLAuthentication().send(null); //getSASLAuthentication().send(packet); }
/** * The server is challenging the SASL authentication we just sent. Forward the challenge * to the current SASLMechanism we are using. The SASLMechanism will eventually send a response to * the server. The length of the challenge-response sequence varies according to the * SASLMechanism in use. * * @param challenge a base64 encoded string representing the challenge. * @param finalChallenge true if this is the last challenge send by the server within the success stanza * @throws SmackException * @throws InterruptedException */ public void challengeReceived(String challenge, boolean finalChallenge) throws SmackException, InterruptedException { try { currentMechanism.challengeReceived(challenge, finalChallenge); } catch (InterruptedException | SmackException e) { authenticationFailed(e); throw e; } }
public SaslAuthFixBean() { super(); // fix SASL auth SASLAuthentication.supportSASLMechanism("PLAIN", 0); } }
saslAuthentication.hasAnonymousAuthentication()) { response = saslAuthentication.authenticateAnonymously();
SASLAuthentication(AbstractXMPPConnection connection, ConnectionConfiguration configuration) { this.configuration = configuration; this.connection = connection; this.init(); }
/** * Wrapper for {@link #challengeReceived(String, boolean)}, with <code>finalChallenge</code> set * to <code>false</code>. * * @param challenge a base64 encoded string representing the challenge. * @throws SmackException * @throws InterruptedException */ public void challengeReceived(String challenge) throws SmackException, InterruptedException { challengeReceived(challenge, false); }
@Override public List<Exception> initialize() { SASLAuthentication.registerSASLMechanism(new SASLExternalMechanism()); SASLAuthentication.registerSASLMechanism(new SASLGSSAPIMechanism()); SASLAuthentication.registerSASLMechanism(new SASLDigestMD5Mechanism()); SASLAuthentication.registerSASLMechanism(new SASLCramMD5Mechanism()); SASLAuthentication.registerSASLMechanism(new SASLPlainMechanism()); return null; }
SASLAuthentication.registerSASLMechanism( new SASLExternalMechanism() ); builder.setKeystoreType(localPref.getPKIStore()); if(localPref.getPKIStore().equals("PKCS11")) { SASLAuthentication.unregisterSASLMechanism( SASLGSSAPIMechanism.class.getName() ); SASLAuthentication.unregisterSASLMechanism( SASLGSSAPIv3CompatMechanism.class.getName() ); SASLAuthentication.registerSASLMechanism( new SASLGSSAPIv3CompatMechanism() ); SASLAuthentication.registerSASLMechanism( new SASLGSSAPIMechanism() );
saslAuthentication.hasNonAnonymousAuthentication()) { response = saslAuthentication.authenticate(username, password, resource); .authenticate(username, resource, config);
protected void authenticate() throws IOException, XMPPException { final StringBuilder stanza = new StringBuilder(); stanza.append("<auth mechanism=\"").append(getName()); stanza.append("\" xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"); stanza.append("</auth>"); // Send the authentication to the server getSASLAuthentication().send(new Packet(){ @Override public String toXML() { return stanza.toString(); } }); }
/** * Notification message saying that SASL authentication has failed. The server may have * closed the connection depending on the number of possible retries. * * @param saslFailure the SASL failure as reported by the server * @see <a href="https://tools.ietf.org/html/rfc6120#section-6.5">RFC6120 6.5</a> */ public void authenticationFailed(SASLFailure saslFailure) { authenticationFailed(new SASLErrorException(currentMechanism.getName(), saslFailure)); }
@Override public XMPPConnection createConnection( final ConnectionConfiguration config) { config.setCallbackHandler(this); final XMPPConnection conn = new XMPPConnection(config); // This just adds oauth2 to the mechanisms we support. SASLAuthentication.supportSASLMechanism("X-OAUTH2"); return conn; }
saslAuthentication.hasAnonymousAuthentication()) { response = saslAuthentication.authenticateAnonymously();
saslAuthentication.init(); saslFeatureReceived.init(); lastFeaturesReceived.init();
/** * Notification message saying that SASL authentication was successful. The next step * would be to bind the resource. * @param success result of the authentication. * @throws SmackException * @throws InterruptedException */ public void authenticated(Success success) throws SmackException, InterruptedException { // RFC6120 6.3.10 "At the end of the authentication exchange, the SASL server (the XMPP // "receiving entity") can include "additional data with success" if appropriate for the // SASL mechanism in use. In XMPP, this is done by including the additional data as the XML // character data of the <success/> element." The used SASL mechanism should be able to // verify the data send by the server in the success stanza, if any. if (success.getData() != null) { challengeReceived(success.getData(), true); } currentMechanism.checkIfSuccessfulOrThrow(); authenticationSuccessful = true; // Wake up the thread that is waiting in the #authenticate method synchronized (this) { notify(); } }
@Override public List<Exception> initialize() { SASLAuthentication.registerSASLMechanism(new SASLDigestMD5Mechanism()); SASLAuthentication.registerSASLMechanism(new SASLExternalMechanism()); SASLAuthentication.registerSASLMechanism(new SASLPlainMechanism()); return null; }