forked from mff-uk/odcs
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #629 from UnifiedViews/feature/restApiUsers
Feature/rest api users improvement - users from User DB
- Loading branch information
Showing
14 changed files
with
263 additions
and
82 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
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
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
38 changes: 38 additions & 0 deletions
38
master/src/main/java/eu/unifiedviews/master/api/UserHelper.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,38 @@ | ||
package eu.unifiedviews.master.api; | ||
|
||
import eu.unifiedviews.master.authentication.BasicAuthenticationFilter; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isEmpty; | ||
|
||
@Component | ||
public class UserHelper { | ||
|
||
@Autowired | ||
private BasicAuthenticationFilter authFilter; | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(UserHelper.class); | ||
|
||
public String getUser(String userExternalId) { | ||
|
||
if (isEmpty(userExternalId)) { | ||
String username = this.authFilter.getUserName(); | ||
if (isEmpty(username)) { | ||
LOG.error("No user defined in the parameter and no user was retrieved from the authentication header"); | ||
return null; | ||
} | ||
else { | ||
return username; | ||
} | ||
} | ||
else { | ||
//no change, return what was provided in the param | ||
return userExternalId; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.