-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to support bearer tokens and remove accountdb access from WDK
- Loading branch information
1 parent
cf0c5d3
commit ffff175
Showing
30 changed files
with
433 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 0 additions & 185 deletions
185
Model/src/main/java/org/gusdb/wdk/controller/filter/CheckLoginFilterShared.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Model/src/main/java/org/gusdb/wdk/model/user/BearerTokenUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.gusdb.wdk.model.user; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.gusdb.oauth2.client.ValidatedToken; | ||
import org.gusdb.oauth2.shared.token.IdTokenFields; | ||
import org.gusdb.wdk.model.WdkModel; | ||
import org.gusdb.wdk.session.WdkOAuthClientWrapper; | ||
import org.json.JSONObject; | ||
|
||
public class BearerTokenUser extends User { | ||
|
||
private static final Logger LOG = Logger.getLogger(BearerTokenUser.class); | ||
|
||
private final WdkOAuthClientWrapper _client; | ||
private final ValidatedToken _token; | ||
private boolean _userInfoFetched = false; | ||
|
||
public BearerTokenUser(WdkModel wdkModel, WdkOAuthClientWrapper client, ValidatedToken token) { | ||
// parent constructor sets immutable fields provided on the token | ||
super(wdkModel, | ||
Long.valueOf(token.getUserId()), | ||
token.isGuest(), | ||
token.getTokenContents().get(IdTokenFields.signature.name(), String.class), | ||
token.getTokenContents().get(IdTokenFields.preferred_username.name(), String.class)); | ||
_client = client; | ||
_token = token; | ||
} | ||
|
||
@Override | ||
protected void fetchUserInfo() { | ||
// return if already fetched | ||
if (_userInfoFetched) return; | ||
|
||
LOG.info("User data fetch requested for user " + getUserId() + "; querying OAuth server."); | ||
// fetch user info from OAuth server where it is stored (but only on demand, and only once for this object's lifetime) | ||
JSONObject userInfo = _client.getUserData(_token); | ||
|
||
// set email (standard property but mutable so set on user profile and not token | ||
setEmail(userInfo.getString(IdTokenFields.email.name())); | ||
|
||
// set other user properties found only on user profile object | ||
for (WdkUserProperty userProp : User.USER_PROPERTIES.values()) { | ||
userProp.setValue(this, userInfo.optString(userProp.getName(), null)); | ||
} | ||
|
||
LOG.info("User data successfully fetched for " + getDisplayName() + " / " + getOrganization()); | ||
_userInfoFetched = true; | ||
} | ||
|
||
} | ||
|
28 changes: 0 additions & 28 deletions
28
Model/src/main/java/org/gusdb/wdk/model/user/RegisteredUser.java
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
Model/src/main/java/org/gusdb/wdk/model/user/UnregisteredUser.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.