本文整理汇总了Java中com.auth0.android.request.AuthenticationRequest类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationRequest类的具体用法?Java AuthenticationRequest怎么用?Java AuthenticationRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationRequest类属于com.auth0.android.request包,在下文中一共展示了AuthenticationRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldSetRealm
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldSetRealm() throws Exception {
HttpUrl url = HttpUrl.parse(mockAPI.getDomain())
.newBuilder()
.addPathSegment(OAUTH_PATH)
.addPathSegment(TOKEN_PATH)
.build();
AuthenticationRequest req = createRequest(url);
mockAPI.willReturnSuccessfulLogin();
req.setRealm("users")
.execute();
final RecordedRequest request = mockAPI.takeRequest();
Map<String, String> body = bodyFromRequest(request);
assertThat(body, hasEntry("realm", "users"));
}
示例2: shouldWhiteListOAuth2ParametersOnLegacyEndpoints
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldWhiteListOAuth2ParametersOnLegacyEndpoints() throws Exception {
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("extra", "value");
parameters.put("realm", "users");
HttpUrl url = HttpUrl.parse(mockAPI.getDomain())
.newBuilder()
.addPathSegment(OAUTH_PATH)
.addPathSegment(RESOURCE_OWNER_PATH)
.build();
AuthenticationRequest req = createRequest(url);
mockAPI.willReturnSuccessfulLogin();
req.addAuthenticationParameters(parameters)
.execute();
final RecordedRequest request = mockAPI.takeRequest();
Map<String, String> body = bodyFromRequest(request);
assertThat(body, hasEntry("extra", "value"));
assertThat(body, not(hasKey("realm")));
}
示例3: shouldWhiteListLegacyParametersOnNonLegacyEndpoints
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldWhiteListLegacyParametersOnNonLegacyEndpoints() throws Exception {
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("extra", "value");
parameters.put("connection", "my-connection");
HttpUrl url = HttpUrl.parse(mockAPI.getDomain())
.newBuilder()
.addPathSegment(OAUTH_PATH)
.addPathSegment(TOKEN_PATH)
.build();
AuthenticationRequest req = createRequest(url);
mockAPI.willReturnSuccessfulLogin();
req.addAuthenticationParameters(parameters)
.execute();
final RecordedRequest request = mockAPI.takeRequest();
Map<String, String> body = bodyFromRequest(request);
assertThat(body, hasEntry("extra", "value"));
assertThat(body, not(hasKey("connection")));
}
示例4: onDatabaseAuthenticationRequest
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@SuppressWarnings("unused")
@Subscribe
public void onDatabaseAuthenticationRequest(DatabaseLoginEvent event) {
if (configuration.getDatabaseConnection() == null) {
Log.w(TAG, "There is no default Database connection to authenticate with");
return;
}
lockView.showProgress(true);
lastDatabaseLogin = event;
AuthenticationAPIClient apiClient = options.getAuthenticationAPIClient();
final HashMap<String, Object> parameters = new HashMap<>(options.getAuthenticationParameters());
if (event.getVerificationCode() != null) {
parameters.put(KEY_VERIFICATION_CODE, event.getVerificationCode());
}
final String connection = configuration.getDatabaseConnection().getName();
AuthenticationRequest request = apiClient.login(event.getUsernameOrEmail(), event.getPassword(), connection)
.addAuthenticationParameters(parameters);
if (options.getScope() != null) {
request.setScope(options.getScope());
}
if (options.getAudience() != null && options.getAccount().isOIDCConformant()) {
request.setAudience(options.getAudience());
}
request.start(authCallback);
}
示例5: setConnection
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
/**
* Sets the 'connection' parameter.
*
* @param connection name of the connection
* @return itself
*/
@Override
public AuthenticationRequest setConnection(String connection) {
if (!hasLegacyPath()) {
Log.w(TAG, "Not setting the 'connection' parameter as the request is using a OAuth 2.0 API Authorization endpoint that doesn't support it.");
return this;
}
addParameter(CONNECTION_KEY, connection);
return this;
}
示例6: setRealm
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
/**
* Sets the 'realm' parameter. A realm identifies the host against which the authentication will be made, and usually helps to know which username and password to use.
*
* @param realm name of the realm
* @return itself
*/
@Override
public AuthenticationRequest setRealm(String realm) {
if (hasLegacyPath()) {
Log.w(TAG, "Not setting the 'realm' parameter as the request is using a Legacy Authorization API endpoint that doesn't support it.");
return this;
}
addParameter(REALM_KEY, realm);
return this;
}
示例7: addAuthenticationParameters
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Override
public AuthenticationRequest addAuthenticationParameters(Map<String, Object> parameters) {
final HashMap<String, Object> params = new HashMap<>(parameters);
if (parameters.containsKey(CONNECTION_KEY)) {
setConnection((String) params.remove(CONNECTION_KEY));
}
if (parameters.containsKey(REALM_KEY)) {
setRealm((String) params.remove(REALM_KEY));
}
addParameters(params);
return this;
}
示例8: loginWithToken
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
private AuthenticationRequest loginWithToken(Map<String, Object> parameters) {
HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder()
.addPathSegment(OAUTH_PATH)
.addPathSegment(TOKEN_PATH)
.build();
final Map<String, Object> requestParameters = ParameterBuilder.newBuilder()
.setClientId(getClientId())
.addAll(parameters)
.asDictionary();
return factory.authenticationPOST(url, client, gson)
.addAuthenticationParameters(requestParameters);
}
示例9: loginWithResourceOwner
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
private AuthenticationRequest loginWithResourceOwner(Map<String, Object> parameters) {
HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder()
.addPathSegment(OAUTH_PATH)
.addPathSegment(RESOURCE_OWNER_PATH)
.build();
final Map<String, Object> requestParameters = ParameterBuilder.newBuilder()
.setClientId(getClientId())
.addAll(parameters)
.asDictionary();
return factory.authenticationPOST(url, client, gson)
.addAuthenticationParameters(requestParameters);
}
示例10: shouldNotSetConnectionOnNonLegacyEndpoints
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldNotSetConnectionOnNonLegacyEndpoints() throws Exception {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("method POST must have a request body.");
//no body was sent
HttpUrl url = HttpUrl.parse(mockAPI.getDomain())
.newBuilder()
.addPathSegment(OAUTH_PATH)
.addPathSegment(TOKEN_PATH)
.build();
AuthenticationRequest req = createRequest(url);
req.setConnection("my-connection")
.execute();
}
示例11: shouldSetAudience
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldSetAudience() throws Exception {
final AuthenticationRequest req = signUpRequest.setAudience("https://domain.auth0.com/api");
verify(authenticationMockRequest).setAudience("https://domain.auth0.com/api");
Assert.assertThat(req, is(notNullValue()));
Assert.assertThat(req, Matchers.<AuthenticationRequest>is(signUpRequest));
}
示例12: shouldSetDevice
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldSetDevice() throws Exception {
final AuthenticationRequest req = signUpRequest.setDevice("nexus-5x");
verify(authenticationMockRequest).setDevice("nexus-5x");
Assert.assertThat(req, is(notNullValue()));
Assert.assertThat(req, Matchers.<AuthenticationRequest>is(signUpRequest));
}
示例13: shouldSetGrantType
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldSetGrantType() throws Exception {
final AuthenticationRequest req = signUpRequest.setGrantType("token");
verify(authenticationMockRequest).setGrantType("token");
Assert.assertThat(req, is(notNullValue()));
Assert.assertThat(req, Matchers.<AuthenticationRequest>is(signUpRequest));
}
示例14: shouldSetAccessToken
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
@Test
public void shouldSetAccessToken() throws Exception {
final AuthenticationRequest req = signUpRequest.setAccessToken("super-access-token");
verify(authenticationMockRequest).setAccessToken("super-access-token");
Assert.assertThat(req, is(notNullValue()));
Assert.assertThat(req, Matchers.<AuthenticationRequest>is(signUpRequest));
}
示例15: shouldYieldCredentialsForRequest
import com.auth0.android.request.AuthenticationRequest; //导入依赖的package包/类
private void shouldYieldCredentialsForRequest(AuthenticationRequest request, final Credentials credentials) {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
//noinspection unchecked
BaseCallback<Credentials, AuthenticationException> callback = (BaseCallback<Credentials, AuthenticationException>) invocation.getArguments()[0];
callback.onSuccess(credentials);
return null;
}
}).when(request).start(Matchers.<BaseCallback<Credentials, AuthenticationException>>any());
}