Browse Source

begin acount management

tags/0.0.5
Robin Thoni 9 years ago
parent
commit
07ac5949d6

+ 27
- 5
app/src/main/AndroidManifest.xml View File

1
 <?xml version="1.0" encoding="utf-8"?>
1
 <?xml version="1.0" encoding="utf-8"?>
2
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
-    package="com.rthoni.camotion">
2
+<manifest package="com.rthoni.camotion"
3
+          xmlns:android="http://schemas.android.com/apk/res/android">
4
+
5
+    <uses-permission android:name="android.permission.INTERNET"/>
6
+    <uses-permission android:name="android.permission.USE_CREDENTIALS"/>
7
+    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
8
+    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
9
+    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
4
 
10
 
5
-    <uses-permission android:name="android.permission.INTERNET" />
6
     <application
11
     <application
7
         android:allowBackup="true"
12
         android:allowBackup="true"
8
         android:icon="@mipmap/ic_launcher"
13
         android:icon="@mipmap/ic_launcher"
14
             android:label="@string/app_name"
19
             android:label="@string/app_name"
15
             android:theme="@style/AppTheme.NoActionBar">
20
             android:theme="@style/AppTheme.NoActionBar">
16
             <intent-filter>
21
             <intent-filter>
17
-                <action android:name="android.intent.action.MAIN" />
22
+                <action android:name="android.intent.action.MAIN"/>
23
+
24
+                <category android:name="android.intent.category.LAUNCHER"/>
25
+            </intent-filter>
26
+        </activity>
18
 
27
 
19
-                <category android:name="android.intent.category.LAUNCHER" />
28
+        <service
29
+            android:name=".business.CamotionAccountBusiness"
30
+            android:exported="true"
31
+            android:process=":auth">
32
+            <intent-filter>
33
+                <action android:name="android.accounts.AccountAuthenticator"/>
20
             </intent-filter>
34
             </intent-filter>
35
+
36
+            <meta-data
37
+                android:name="android.accounts.AccountAuthenticator"
38
+                android:resource="@xml/authenticator"/>
39
+        </service>
40
+
41
+        <activity android:name=".AddAccountActivity">
21
         </activity>
42
         </activity>
43
+
22
     </application>
44
     </application>
23
 
45
 
24
 </manifest>
46
 </manifest>

BIN
app/src/main/ic_launcher-web.png View File


+ 13
- 0
app/src/main/java/com/rthoni/camotion/AddAccountActivity.java View File

1
+package com.rthoni.camotion;
2
+
3
+import android.support.v7.app.AppCompatActivity;
4
+import android.os.Bundle;
5
+
6
+public class AddAccountActivity extends AppCompatActivity {
7
+
8
+    @Override
9
+    protected void onCreate(Bundle savedInstanceState) {
10
+        super.onCreate(savedInstanceState);
11
+        setContentView(R.layout.activity_add_account);
12
+    }
13
+}

+ 2
- 2
app/src/main/java/com/rthoni/camotion/MainActivity.java View File

15
 
15
 
16
 import com.luticate.auth.business.LuticateUsersBusiness;
16
 import com.luticate.auth.business.LuticateUsersBusiness;
17
 import com.luticate.auth.dbo.LuFullLoginDbo;
17
 import com.luticate.auth.dbo.LuFullLoginDbo;
18
-import com.luticate.auth.dbo.LuLoginDbo;
19
 import com.luticate.utils.business.LuPromise;
18
 import com.luticate.utils.business.LuPromise;
19
+import com.rthoni.camotion.business.CamotionBusiness;
20
 
20
 
21
 public class MainActivity extends AppCompatActivity
21
 public class MainActivity extends AppCompatActivity
22
         implements NavigationView.OnNavigationItemSelectedListener {
22
         implements NavigationView.OnNavigationItemSelectedListener {
32
         fab.setOnClickListener(new View.OnClickListener() {
32
         fab.setOnClickListener(new View.OnClickListener() {
33
             @Override
33
             @Override
34
             public void onClick(View view) {
34
             public void onClick(View view) {
35
-                LuticateUsersBusiness.loginFull("http://camotion.gigi.rthoni.com", "user", "test42")
35
+                LuticateUsersBusiness.loginFull(CamotionBusiness.getConfig(), "user", "test42")
36
                         .then(new LuPromise.LuConsumer<LuFullLoginDbo>() {
36
                         .then(new LuPromise.LuConsumer<LuFullLoginDbo>() {
37
                             @Override
37
                             @Override
38
                             public void execute(LuFullLoginDbo data) {
38
                             public void execute(LuFullLoginDbo data) {

+ 140
- 0
app/src/main/java/com/rthoni/camotion/business/CamotionAccountBusiness.java View File

1
+package com.rthoni.camotion.business;
2
+
3
+import android.accounts.AbstractAccountAuthenticator;
4
+import android.accounts.Account;
5
+import android.accounts.AccountAuthenticatorResponse;
6
+import android.accounts.AccountManager;
7
+import android.accounts.NetworkErrorException;
8
+import android.app.Service;
9
+import android.content.Context;
10
+import android.content.Intent;
11
+import android.os.Bundle;
12
+import android.os.IBinder;
13
+import android.util.Log;
14
+
15
+import com.rthoni.camotion.AddAccountActivity;
16
+
17
+/**
18
+ *
19
+ * Created by robin on 11/28/15.
20
+ */
21
+public class CamotionAccountBusiness extends Service {
22
+    /**
23
+     * The tag used for the logs.
24
+     */
25
+    private static final String LOG_TAG = CamotionAccountBusiness.class.getSimpleName();
26
+
27
+    /**
28
+     * The implementation of the class |AccountAuthenticatorImpl|.
29
+     * It is implemented as a singleton
30
+     */
31
+    private static AccountAuthenticatorImpl sAccountAuthenticator = null;
32
+
33
+    /**
34
+     * The main constructor.
35
+     */
36
+    public CamotionAccountBusiness() {
37
+        super();
38
+    }
39
+
40
+    /**
41
+     * The bind method of the service.
42
+     * @param intent The intent used to invoke the service
43
+     * @return The binder of the class which has implemented |AbstractAccountAuthenticator|
44
+     */
45
+    @Override
46
+    public IBinder onBind(Intent intent) {
47
+        Log.v(CamotionAccountBusiness.LOG_TAG, "Binding the service");
48
+        IBinder ret = null;
49
+        if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) {
50
+            ret = getAuthenticator().getIBinder();
51
+        }
52
+        return ret;
53
+    }
54
+
55
+    /**
56
+     * The method used to obtain the authenticator. It is implemented as a singleton
57
+     * @return The implementation of the class |AbstractAccountAuthenticator|
58
+     */
59
+    private AccountAuthenticatorImpl getAuthenticator() {
60
+        if (CamotionAccountBusiness.sAccountAuthenticator == null) {
61
+            CamotionAccountBusiness.sAccountAuthenticator = new AccountAuthenticatorImpl(this);
62
+        }
63
+
64
+        return CamotionAccountBusiness.sAccountAuthenticator;
65
+    }
66
+
67
+    /**
68
+     * The class which implements the class |AbstractAccountAuthenticator|.
69
+     * It is the one which the Android system calls to perform any action related with the account
70
+     */
71
+    private static class AccountAuthenticatorImpl extends AbstractAccountAuthenticator {
72
+
73
+        /**
74
+         * The Context used.
75
+         */
76
+        private final Context mContext;
77
+
78
+        /**
79
+         * The main constructor of the class.
80
+         * @param context The context used
81
+         */
82
+        public AccountAuthenticatorImpl(Context context) {
83
+            super(context);
84
+            mContext = context;
85
+        }
86
+
87
+        @Override
88
+        public Bundle addAccount(AccountAuthenticatorResponse response,
89
+                                 String accountType,
90
+                                 String authTokenType,
91
+                                 String[] requiredFeatures,
92
+                                 Bundle options) throws NetworkErrorException {
93
+            Log.d(CamotionAccountBusiness.LOG_TAG, "Adding new account");
94
+            Bundle reply = new Bundle();
95
+
96
+            Log.d(CamotionAccountBusiness.LOG_TAG, "The auth token type is " + authTokenType);
97
+            Intent i = new Intent(mContext, AddAccountActivity.class);
98
+            i.setAction("com.gowex.pista.addnewaccount");
99
+            i.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
100
+            i.putExtra("AuthTokenType", authTokenType);
101
+            reply.putParcelable(AccountManager.KEY_INTENT, i);
102
+
103
+            return reply;
104
+        }
105
+
106
+        @Override
107
+        public Bundle confirmCredentials(AccountAuthenticatorResponse arg0, Account arg1,
108
+                                         Bundle arg2) throws NetworkErrorException {
109
+            return null;
110
+        }
111
+
112
+        @Override
113
+        public Bundle editProperties(AccountAuthenticatorResponse arg0, String arg1) {
114
+            return null;
115
+        }
116
+
117
+        @Override
118
+        public Bundle getAuthToken(AccountAuthenticatorResponse arg0, Account arg1,
119
+                                   String arg2, Bundle arg3) throws NetworkErrorException {
120
+            return null;
121
+        }
122
+
123
+        @Override
124
+        public String getAuthTokenLabel(String arg0) {
125
+            return null;
126
+        }
127
+
128
+        @Override
129
+        public Bundle hasFeatures(AccountAuthenticatorResponse arg0, Account arg1,
130
+                                  String[] arg2) throws NetworkErrorException {
131
+            return null;
132
+        }
133
+
134
+        @Override
135
+        public Bundle updateCredentials(AccountAuthenticatorResponse arg0, Account arg1,
136
+                                        String arg2, Bundle arg3) throws NetworkErrorException {
137
+            return null;
138
+        }
139
+    }
140
+}

+ 16
- 0
app/src/main/java/com/rthoni/camotion/business/CamotionBusiness.java View File

1
+package com.rthoni.camotion.business;
2
+
3
+import com.luticate.utils.dbo.LuDataAccessConfigDbo;
4
+
5
+/**
6
+ * Created by robin on 11/28/15.
7
+ */
8
+public class CamotionBusiness {
9
+
10
+    public static LuDataAccessConfigDbo getConfig()
11
+    {
12
+        LuDataAccessConfigDbo config = new LuDataAccessConfigDbo();
13
+        config.setBaseUrl("http://camotion.gigi.rthoni.com");
14
+        return config;
15
+    }
16
+}

+ 32
- 0
app/src/main/java/com/rthoni/camotion/dbo/LocationDbo.java View File

1
+package com.rthoni.camotion.dbo;
2
+
3
+import com.luticate.utils.dbo.LuDbo;
4
+
5
+import org.json.JSONException;
6
+import org.json.JSONObject;
7
+
8
+import java.util.HashMap;
9
+
10
+/**
11
+ * Created by robin on 11/28/15.
12
+ */
13
+public class LocationDbo extends LuDbo {
14
+
15
+    private String _name;
16
+
17
+    private String _baseUrl;
18
+
19
+    private String _username;
20
+
21
+    private String _password;
22
+
23
+    @Override
24
+    public void fromJson(JSONObject json) throws JSONException {
25
+
26
+    }
27
+
28
+    @Override
29
+    public HashMap<String, Object> toArray() {
30
+        return null;
31
+    }
32
+}

+ 114
- 0
app/src/main/res/layout/activity_add_account.xml View File

1
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+                xmlns:tools="http://schemas.android.com/tools"
3
+                android:layout_width="match_parent"
4
+                android:layout_height="match_parent"
5
+                android:orientation="vertical"
6
+                tools:context="com.rob57530.camotion.ui.AddLocationActivity">
7
+
8
+
9
+    <ScrollView
10
+        android:layout_width="wrap_content"
11
+        android:layout_height="wrap_content"
12
+        android:id="@+id/scrollView"
13
+        android:layout_alignParentLeft="true"
14
+        android:layout_alignParentStart="true"
15
+        android:layout_alignParentTop="true"
16
+        android:layout_alignParentRight="true"
17
+        android:layout_alignParentEnd="true"
18
+        android:layout_above="@+id/linearLayout">
19
+
20
+        <LinearLayout
21
+            android:orientation="vertical"
22
+            android:layout_width="fill_parent"
23
+            android:layout_height="wrap_content">
24
+
25
+            <TextView
26
+                android:layout_width="match_parent"
27
+                android:layout_height="wrap_content"
28
+                android:textAppearance="?android:attr/textAppearanceMedium"
29
+                android:text="@string/add_location_text"
30
+                android:id="@+id/textView"/>
31
+
32
+            <EditText
33
+                android:layout_width="match_parent"
34
+                android:layout_height="wrap_content"
35
+                android:hint="@string/name"
36
+                android:id="@+id/name_input"
37
+                />
38
+
39
+            <EditText
40
+                android:layout_width="match_parent"
41
+                android:layout_height="wrap_content"
42
+                android:hint="@string/username"
43
+                android:id="@+id/username_input"
44
+                />
45
+
46
+            <EditText
47
+                android:layout_width="match_parent"
48
+                android:layout_height="wrap_content"
49
+                android:id="@+id/password_input"
50
+                android:inputType="textPassword"
51
+                android:hint="@string/password"
52
+                android:layout_gravity="center_horizontal"
53
+                />
54
+
55
+            <EditText
56
+                android:layout_width="match_parent"
57
+                android:layout_height="wrap_content"
58
+                android:id="@+id/api_entrypoint_input"
59
+                android:hint="@string/api_entrypoint"
60
+                android:layout_gravity="center_horizontal"
61
+                />
62
+
63
+            <RelativeLayout
64
+                android:layout_width="match_parent"
65
+                android:layout_height="match_parent">
66
+
67
+                <Button
68
+                    android:layout_width="wrap_content"
69
+                    android:layout_height="wrap_content"
70
+                    android:text="@string/check_account"
71
+                    android:id="@+id/test"
72
+                    android:layout_gravity="center_horizontal"
73
+                    android:layout_alignParentTop="true"
74
+                    android:layout_centerHorizontal="true"/>
75
+
76
+                <ImageView
77
+                    android:layout_width="wrap_content"
78
+                    android:layout_height="wrap_content"
79
+                    android:id="@+id/imageView"
80
+                    android:layout_alignParentTop="true"
81
+                    android:layout_toRightOf="@+id/test"
82
+                    android:layout_toEndOf="@+id/test"/>
83
+            </RelativeLayout>
84
+
85
+        </LinearLayout>
86
+    </ScrollView>
87
+
88
+    <LinearLayout
89
+        android:orientation="horizontal"
90
+        android:layout_width="fill_parent"
91
+        android:layout_height="wrap_content"
92
+        android:layout_alignParentBottom="true"
93
+        android:id="@+id/linearLayout"
94
+        style="?android:attr/buttonBarStyle"
95
+        android:weightSum="2">
96
+
97
+        <Button
98
+            android:layout_width="0dp"
99
+            android:layout_height="wrap_content"
100
+            android:text="@android:string/cancel"
101
+            android:id="@+id/cancel"
102
+            android:layout_gravity="center_vertical"
103
+            style="?android:attr/buttonBarButtonStyle"
104
+            android:layout_weight="1"/>
105
+
106
+        <Button
107
+            android:layout_width="0dp"
108
+            android:layout_height="wrap_content"
109
+            android:text="@android:string/ok"
110
+            android:id="@+id/ok"
111
+            style="?android:attr/buttonBarButtonStyle"
112
+            android:layout_weight="1"/>
113
+    </LinearLayout>
114
+</RelativeLayout>

BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png View File


BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png View File


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png View File


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png View File


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png View File


+ 8
- 0
app/src/main/res/values/strings.xml View File

5
     <string name="navigation_drawer_close">Close navigation drawer</string>
5
     <string name="navigation_drawer_close">Close navigation drawer</string>
6
 
6
 
7
     <string name="action_settings">Settings</string>
7
     <string name="action_settings">Settings</string>
8
+
9
+    <string name="add_location">Add a location</string>
10
+    <string name="add_location_text">Fill in the following fields to add a location:</string>
11
+    <string name="name">Location name</string>
12
+    <string name="username">Username</string>
13
+    <string name="password">Password</string>
14
+    <string name="check_account">Check account</string>
15
+    <string name="api_entrypoint">API entry point</string>
8
 </resources>
16
 </resources>

+ 2
- 2
app/src/main/res/values/styles.xml View File

1
 <resources>
1
 <resources>
2
 
2
 
3
     <!-- Base application theme. -->
3
     <!-- Base application theme. -->
4
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
4
+    <style name="AppTheme" parent="Theme.AppCompat">
5
         <!-- Customize your theme here. -->
5
         <!-- Customize your theme here. -->
6
         <item name="colorPrimary">@color/colorPrimary</item>
6
         <item name="colorPrimary">@color/colorPrimary</item>
7
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
7
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
15
 
15
 
16
     <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
16
     <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
17
 
17
 
18
-    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
18
+    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat" />
19
 
19
 
20
 </resources>
20
 </resources>

+ 4
- 0
app/src/main/res/xml/account_preferences.xml View File

1
+<?xml version="1.0" encoding="utf-8"?>
2
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+</PreferenceScreen>

+ 9
- 0
app/src/main/res/xml/authenticator.xml View File

1
+<?xml version="1.0" encoding="utf-8"?>
2
+<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
3
+                       android:accountType="com.rthoni.luticate.account"
4
+                       android:icon="@mipmap/ic_launcher"
5
+                       android:smallIcon="@mipmap/ic_launcher"
6
+                       android:label="@string/app_name"
7
+                       android:accountPreferences="@xml/account_preferences">
8
+
9
+</account-authenticator>

+ 3
- 2
luticateauth/src/main/java/com/luticate/auth/business/LuticatePermissionsBusiness.java View File

4
 import com.luticate.auth.dbo.LuPermissionDbo;
4
 import com.luticate.auth.dbo.LuPermissionDbo;
5
 import com.luticate.utils.business.LuBusinessManager;
5
 import com.luticate.utils.business.LuBusinessManager;
6
 import com.luticate.utils.business.LuPromise;
6
 import com.luticate.utils.business.LuPromise;
7
+import com.luticate.utils.dbo.LuDataAccessConfigDbo;
7
 
8
 
8
 /**
9
 /**
9
  *
10
  *
11
  */
12
  */
12
 public class LuticatePermissionsBusiness extends LuBusinessManager {
13
 public class LuticatePermissionsBusiness extends LuBusinessManager {
13
 
14
 
14
-    public static LuPromise<LuPermissionDbo.LuMultiplePermissionDbo> getAllEffectiveMe(String baseUrl)
15
+    public static LuPromise<LuPermissionDbo.LuMultiplePermissionDbo> getAllEffectiveMe(LuDataAccessConfigDbo config)
15
     {
16
     {
16
-        return LuticatePermissionsDataAccess.getAllEffectiveMe(baseUrl);
17
+        return LuticatePermissionsDataAccess.getAllEffectiveMe(config);
17
     }
18
     }
18
 }
19
 }

+ 8
- 7
luticateauth/src/main/java/com/luticate/auth/business/LuticateUsersBusiness.java View File

6
 import com.luticate.utils.business.LuBusinessManager;
6
 import com.luticate.utils.business.LuBusinessManager;
7
 import com.luticate.utils.business.LuPromise;
7
 import com.luticate.utils.business.LuPromise;
8
 import com.luticate.auth.dbo.LuLoginDbo;
8
 import com.luticate.auth.dbo.LuLoginDbo;
9
+import com.luticate.utils.dbo.LuDataAccessConfigDbo;
9
 
10
 
10
 /**
11
 /**
11
  *
12
  *
13
  */
14
  */
14
 public class LuticateUsersBusiness extends LuBusinessManager {
15
 public class LuticateUsersBusiness extends LuBusinessManager {
15
 
16
 
16
-    public static LuPromise<LuLoginDbo> login(String baseUrl, String username, String password)
17
+    public static LuPromise<LuLoginDbo> login(LuDataAccessConfigDbo config, String username, String password)
17
     {
18
     {
18
-        return LuticateUsersDataAccess.login(baseUrl, username, password);
19
+        return LuticateUsersDataAccess.login(config, username, password);
19
     }
20
     }
20
 
21
 
21
-    public static LuPromise<LuLoginDbo> logout(String baseUrl)
22
+    public static LuPromise<LuLoginDbo> logout(LuDataAccessConfigDbo config)
22
     {
23
     {
23
-        return LuticateUsersDataAccess.logout(baseUrl);
24
+        return LuticateUsersDataAccess.logout(config);
24
     }
25
     }
25
 
26
 
26
-    public static LuPromise<LuFullLoginDbo> loginFull(final String baseUrl, String username, String password)
27
+    public static LuPromise<LuFullLoginDbo> loginFull(final LuDataAccessConfigDbo config, String username, String password)
27
     {
28
     {
28
         final LuPromise<LuFullLoginDbo> promise = new LuPromise<>();
29
         final LuPromise<LuFullLoginDbo> promise = new LuPromise<>();
29
-        login(baseUrl, username, password).then(new LuPromise.LuConsumer<LuLoginDbo>() {
30
+        login(config, username, password).then(new LuPromise.LuConsumer<LuLoginDbo>() {
30
             @Override
31
             @Override
31
             public void execute(final LuLoginDbo user) {
32
             public void execute(final LuLoginDbo user) {
32
-                LuticatePermissionsBusiness.getAllEffectiveMe(baseUrl).then(new LuPromise.LuConsumer<LuPermissionDbo.LuMultiplePermissionDbo>() {
33
+                LuticatePermissionsBusiness.getAllEffectiveMe(config).then(new LuPromise.LuConsumer<LuPermissionDbo.LuMultiplePermissionDbo>() {
33
                     @Override
34
                     @Override
34
                     public void execute(LuPermissionDbo.LuMultiplePermissionDbo permissions) {
35
                     public void execute(LuPermissionDbo.LuMultiplePermissionDbo permissions) {
35
                         LuFullLoginDbo dbo = new LuFullLoginDbo();
36
                         LuFullLoginDbo dbo = new LuFullLoginDbo();

+ 3
- 2
luticateauth/src/main/java/com/luticate/auth/dataaccess/LuticatePermissionsDataAccess.java View File

4
 import com.luticate.utils.dataaccess.LuDataAccess;
4
 import com.luticate.utils.dataaccess.LuDataAccess;
5
 import com.luticate.utils.business.LuPromise;
5
 import com.luticate.utils.business.LuPromise;
6
 import com.luticate.utils.business.LuRequest;
6
 import com.luticate.utils.business.LuRequest;
7
+import com.luticate.utils.dbo.LuDataAccessConfigDbo;
7
 
8
 
8
 /**
9
 /**
9
  *
10
  *
11
  */
12
  */
12
 public class LuticatePermissionsDataAccess extends LuDataAccess {
13
 public class LuticatePermissionsDataAccess extends LuDataAccess {
13
 
14
 
14
-    public static LuPromise<LuPermissionDbo.LuMultiplePermissionDbo> getAllEffectiveMe(String baseUrl)
15
+    public static LuPromise<LuPermissionDbo.LuMultiplePermissionDbo> getAllEffectiveMe(LuDataAccessConfigDbo config)
15
     {
16
     {
16
-        return LuRequest.get(LuPermissionDbo.LuMultiplePermissionDbo.class, baseUrl + "/api/luticate/permissions/effective/me");
17
+        return LuRequest.get(LuPermissionDbo.LuMultiplePermissionDbo.class, config.getBaseUrl() + "/api/luticate/permissions/effective/me");
17
     }
18
     }
18
 }
19
 }

+ 5
- 4
luticateauth/src/main/java/com/luticate/auth/dataaccess/LuticateUsersDataAccess.java View File

4
 import com.luticate.utils.dataaccess.LuDataAccess;
4
 import com.luticate.utils.dataaccess.LuDataAccess;
5
 import com.luticate.utils.business.LuPromise;
5
 import com.luticate.utils.business.LuPromise;
6
 import com.luticate.utils.business.LuRequest;
6
 import com.luticate.utils.business.LuRequest;
7
+import com.luticate.utils.dbo.LuDataAccessConfigDbo;
7
 
8
 
8
 import java.util.HashMap;
9
 import java.util.HashMap;
9
 
10
 
13
  */
14
  */
14
 public class LuticateUsersDataAccess extends LuDataAccess {
15
 public class LuticateUsersDataAccess extends LuDataAccess {
15
 
16
 
16
-    public static LuPromise<LuLoginDbo> login(String baseUrl, String username, String password)
17
+    public static LuPromise<LuLoginDbo> login(LuDataAccessConfigDbo config, String username, String password)
17
     {
18
     {
18
         HashMap<String, String> array = new HashMap<>();
19
         HashMap<String, String> array = new HashMap<>();
19
         array.put("username", username);
20
         array.put("username", username);
20
         array.put("password", password);
21
         array.put("password", password);
21
-        return LuRequest.post(LuLoginDbo.class, baseUrl + "/api/luticate/users/login", array);
22
+        return LuRequest.post(LuLoginDbo.class, config.getBaseUrl() + "/api/luticate/users/login", array);
22
     }
23
     }
23
 
24
 
24
-    public static LuPromise<LuLoginDbo> logout(String baseUrl)
25
+    public static LuPromise<LuLoginDbo> logout(LuDataAccessConfigDbo config)
25
     {
26
     {
26
-        return LuRequest.post(LuLoginDbo.class, baseUrl + "/api/luticate/users/logout");
27
+        return LuRequest.post(LuLoginDbo.class, config.getBaseUrl() + "/api/luticate/users/logout");
27
     }
28
     }
28
 }
29
 }

+ 18
- 0
luticateutils/src/main/java/com/luticate/utils/dbo/LuDataAccessConfigDbo.java View File

1
+package com.luticate.utils.dbo;
2
+
3
+/**
4
+ *
5
+ * Created by robin on 11/28/15.
6
+ */
7
+public class LuDataAccessConfigDbo {
8
+
9
+    private String _baseUrl;
10
+
11
+    public String getBaseUrl() {
12
+        return _baseUrl;
13
+    }
14
+
15
+    public void setBaseUrl(String baseUrl) {
16
+        _baseUrl = baseUrl;
17
+    }
18
+}

Loading…
Cancel
Save