本文整理汇总了Java中org.apache.usergrid.java.client.auth.UsergridUserAuth类的典型用法代码示例。如果您正苦于以下问题:Java UsergridUserAuth类的具体用法?Java UsergridUserAuth怎么用?Java UsergridUserAuth使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UsergridUserAuth类属于org.apache.usergrid.java.client.auth包,在下文中一共展示了UsergridUserAuth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@NotNull
private UsergridResponse authenticate(@NotNull final UsergridAuth auth) {
Map<String, String> credentials = auth.credentialsMap();
String url = this.usergridClient.clientAppUrl();
if ( auth instanceof UsergridUserAuth){
UsergridUserAuth userAuth = (UsergridUserAuth) auth;
if( userAuth.isAdminUser()){
url = this.usergridClient.managementUrl();
}
}
UsergridRequest request = new UsergridRequest(UsergridHttpMethod.POST, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, url, null, credentials, this.usergridClient.authForRequests(), "token");
UsergridResponse response = performRequest(request);
if (!isEmpty(response.getAccessToken()) && !isEmpty(response.getExpires())) {
auth.setAccessToken(response.getAccessToken());
auth.setExpiry(System.currentTimeMillis() + response.getExpires() - 5000);
}
return response;
}
示例2: clientUserInit
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@Test
public void clientUserInit() {
Usergrid.initSharedInstance(SDKTestConfiguration.ORG_NAME, SDKTestConfiguration.APP_NAME, SDKTestConfiguration.USERGRID_URL);
Usergrid.authenticateUser(new UsergridUserAuth(SDKTestConfiguration.APP_UserName, SDKTestConfiguration.APP_Password));
UsergridResponse getResponse = Usergrid.GET("user","eb8145ea-e171-11e5-a5e5-2bc0953f9fe6");
if( getResponse.getEntities() != null ) {
UsergridEntity entity = getResponse.first();
if( entity instanceof UsergridUser) {
UsergridUser user = (UsergridUser) entity;
System.out.print(user.toString());
}
List<UsergridUser> users = getResponse.users();
if( users != null ) {
System.out.print(users.get(0).toString());
}
}
}
示例3: clientAuth_USER
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@Test
public void clientAuth_USER() {
Usergrid.setAuthMode(UsergridAuthMode.USER);
UsergridUserAuth userAuth = new UsergridUserAuth(SDKTestConfiguration.APP_UserName, SDKTestConfiguration.APP_Password);
UsergridResponse response = Usergrid.authenticateUser(userAuth);
assertTrue("response status is OK", response.ok());
assertNull("no error thrown", response.getResponseError());
assertTrue("appAuth.isValidToken should be true", userAuth.isValidToken());
assertNotNull("should have a token", userAuth.getAccessToken());
assertNotNull("should have an expiry", userAuth.getExpiry());
UsergridUser currentUser = Usergrid.getCurrentUser();
assertNotNull("client.currentUser should not be null", currentUser);
assertNotNull("client.currentUser().getUserAuth() should not be null", currentUser.getUserAuth());
assertEquals("client.currentUser().userAuth should be the same as userAuth", currentUser.getUserAuth(), userAuth);
assertTrue("should have a token that is not empty", userAuth.getAccessToken().length() > 0);
assertTrue("client.currentUser().userAuth.getExpiry() should be set to a future date", userAuth.getExpiry() > System.currentTimeMillis());
assertEquals("client.authForRequests() should be the same as userAuth", Usergrid.authForRequests(), userAuth);
}
示例4: authenticateUser
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@NotNull
public UsergridResponse authenticateUser(@NotNull final UsergridUserAuth userAuth, final boolean setAsCurrentUser) {
UsergridResponse response = this.requestManager.authenticateUser(userAuth);
if( response.ok() && setAsCurrentUser ) {
this.setCurrentUser(response.user());
}
return response;
}
示例5: logoutCurrentUser
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@NotNull
public UsergridResponse logoutCurrentUser() {
UsergridUser currentUser = this.currentUser;
if( currentUser != null ) {
String uuidOrUsername = currentUser.uuidOrUsername();
UsergridUserAuth userAuth = currentUser.getUserAuth();
if( uuidOrUsername != null && userAuth != null ) {
String accessToken = userAuth.getAccessToken();
if( accessToken != null ) {
return logoutUser(uuidOrUsername, accessToken);
}
}
}
return UsergridResponse.fromError(this,"UsergridClient's currentUser is not valid.", "UsergridClient's currentUser is null or has no uuid or username.");
}
示例6: login
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@NotNull
public UsergridResponse login(@NotNull final UsergridClient client, @NotNull final String username, @NotNull final String password) {
UsergridUserAuth userAuth = new UsergridUserAuth(username,password);
UsergridResponse response = client.authenticateUser(userAuth,false);
if( response.ok() ) {
this.userAuth = userAuth;
}
return response;
}
示例7: authenticateUser
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@NotNull
public UsergridResponse authenticateUser(@NotNull final UsergridUserAuth userAuth) {
UsergridResponse response = this.authenticate(userAuth);
UsergridUser responseUser = response.user();
if ( response.ok() && responseUser != null) {
responseUser.setUserAuth(userAuth);
}
return response;
}
示例8: clientAuth_NONE
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@Test
public void clientAuth_NONE() {
Usergrid.setAuthMode(UsergridAuthMode.NONE);
UsergridUserAuth userAuth = new UsergridUserAuth(SDKTestConfiguration.APP_UserName, SDKTestConfiguration.APP_Password);
Usergrid.authenticateUser(userAuth);
assertNull("no auth should be returned from client.authForRequests", Usergrid.authForRequests());
}
示例9: authenticateUser
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
public static void authenticateUser(@NotNull final UsergridClient client, @NotNull final UsergridUserAuth userAuth, final boolean setAsCurrentUser, @NotNull final UsergridResponseCallback responseCallback) {
(new UsergridAsyncTask(responseCallback) {
@Override
public UsergridResponse doTask() {
return client.authenticateUser(userAuth,setAsCurrentUser);
}
}).execute();
}
示例10: setup
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@Override
public boolean setup() {
client = new UsergridClient(getOrg(), getApp(), getBaseUri());
UsergridUserAuth usergridUserAuth = new UsergridUserAuth(email, password, true);
client.authenticateUser(usergridUserAuth);
return insertDatas();
}
示例11: authenticateUser
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@NotNull
public static UsergridResponse authenticateUser(@NotNull final UsergridUserAuth userAuth) {
return Usergrid.getInstance().authenticateUser(userAuth);
}
示例12: testInitUserUsergrid
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@Test
public void testInitUserUsergrid() {
Usergrid.initSharedInstance(SDKTestConfiguration.ORG_NAME, SDKTestConfiguration.APP_NAME, SDKTestConfiguration.USERGRID_URL);
Usergrid.authenticateUser(new UsergridUserAuth(SDKTestConfiguration.APP_UserName, SDKTestConfiguration.APP_Password));
assertTrue("usergrid should be an instance of usergrid client", Usergrid.getInstance().getClass() == UsergridClient.class);
}
示例13: before
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@Before
public void before() {
Usergrid.initSharedInstance(SDKTestConfiguration.ORG_NAME, SDKTestConfiguration.APP_NAME, SDKTestConfiguration.USERGRID_URL, UsergridEnums.UsergridAuthMode.USER);
Usergrid.authenticateUser(new UsergridUserAuth(SDKTestConfiguration.APP_UserName, SDKTestConfiguration.APP_Password));
}
示例14: getUserAuth
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@Nullable public UsergridUserAuth getUserAuth() { return (this.currentUser != null) ? this.currentUser.getUserAuth() : null; }
示例15: getUserAuth
import org.apache.usergrid.java.client.auth.UsergridUserAuth; //导入依赖的package包/类
@JsonIgnore @Nullable public UsergridUserAuth getUserAuth() { return this.userAuth; }