Package org.jivesoftware.smack.sasl.core
Class SASLXOauth2Mechanism
- java.lang.Object
-
- org.jivesoftware.smack.sasl.SASLMechanism
-
- org.jivesoftware.smack.sasl.core.SASLXOauth2Mechanism
-
- All Implemented Interfaces:
Comparable<SASLMechanism>
public class SASLXOauth2Mechanism extends SASLMechanism
The SASL X-OAUTH2 mechanism as described in https://developers.google .com/talk/jep_extensions/oauthThe given password will be used as OAUTH token.
Note that X-OAUTH2 is experimental in Smack. This is because Google defined, besides being a bad practice (XEP-134), custom attributes to the 'auth' stanza, as can be seen here
from https://developers.google.com/cloud-print/docs/rawxmpp and here<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="X-OAUTH2" auth:service="chromiumsync" auth:allow-generated-jid="true" auth:client-uses-full-bind-result="true" xmlns:auth="http://www.google.com/talk/protocol/auth">
from https://developers.google.com/talk/jep_extensions/oauth<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="X-OAUTH2" auth:service="oauth2" xmlns:auth="http://www.google.com/talk/protocol/auth"> base64("\0" + user_name + "\0" + oauth_token) </auth>Those attribute extensions are currently not supported by Smack, and it's unclear how it affects authorization and how widely they are used.
-
-
Field Summary
Fields Modifier and Type Field Description static StringNAME-
Fields inherited from class org.jivesoftware.smack.sasl.SASLMechanism
authenticationId, authorizationId, connection, connectionConfiguration, CRAMMD5, DIGESTMD5, EXTERNAL, GSSAPI, host, password, PLAIN, serviceName, sslSession
-
-
Constructor Summary
Constructors Constructor Description SASLXOauth2Mechanism()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidauthenticateInternal(CallbackHandler cbh)voidcheckIfSuccessfulOrThrow()protected byte[]getAuthenticationText()Should return the initial response of the SASL mechanism.StringgetName()Returns the common name of the SASL mechanism.intgetPriority()Get the priority of this SASL mechanism.SASLXOauth2MechanismnewInstance()-
Methods inherited from class org.jivesoftware.smack.sasl.SASLMechanism
afterFinalSaslChallenge, authenticate, authenticate, authenticateInternal, authzidSupported, challengeReceived, compareTo, evaluateChallenge, instanceForAuthentication, isAuthenticationSuccessful, isFinished, saslPrep, setException, throwExceptionIfRequired, toBytes, toString
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SASLXOauth2Mechanism
public SASLXOauth2Mechanism()
-
-
Method Detail
-
authenticateInternal
protected void authenticateInternal(CallbackHandler cbh)
- Specified by:
authenticateInternalin classSASLMechanism
-
getAuthenticationText
protected byte[] getAuthenticationText()
Description copied from class:SASLMechanismShould return the initial response of the SASL mechanism. The returned byte array will be send base64 encoded to the server. SASL mechanism are free to returnnullor an empty array here.- Specified by:
getAuthenticationTextin classSASLMechanism- Returns:
- the initial response or null
-
getName
public String getName()
Description copied from class:SASLMechanismReturns the common name of the SASL mechanism. E.g.: PLAIN, DIGEST-MD5 or GSSAPI.- Specified by:
getNamein classSASLMechanism- Returns:
- the common name of the SASL mechanism.
-
getPriority
public int getPriority()
Description copied from class:SASLMechanismGet the priority of this SASL mechanism. Lower values mean higher priority.- Specified by:
getPriorityin classSASLMechanism- Returns:
- the priority of this SASL mechanism.
-
newInstance
public SASLXOauth2Mechanism newInstance()
- Specified by:
newInstancein classSASLMechanism
-
checkIfSuccessfulOrThrow
public void checkIfSuccessfulOrThrow()
- Specified by:
checkIfSuccessfulOrThrowin classSASLMechanism
-
-