Skip to content

Commit

Permalink
Issue #405
Browse files Browse the repository at this point in the history
  • Loading branch information
pavels committed May 3, 2016
1 parent 0ff45d0 commit 9e9b779
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void setUserManager(UserManager uMan) {
@Override
protected String updateExistingUser(String userName, ShibbolethUserWrapper w) throws SQLException {
User u = this.usersManager.findUserByLoginName(userName);

UserUtils.associateGroups(u, this.usersManager);
UserUtils.associateCommonGroup(u, this.usersManager);
String password = GeneratePasswordUtils.generatePswd();
Expand All @@ -52,12 +53,13 @@ protected boolean checkIfUserExists(String userName) throws ConfigurationExcepti
@Override
protected String createNewUser(String user, ShibbolethUserWrapper w)
throws JSONException, ConfigurationException, SQLException {
UserImpl u = new UserImpl(-1, w.getProperty(UserUtils.FIRST_NAME_KEY),
User u = new UserImpl(-1, w.getProperty(UserUtils.FIRST_NAME_KEY),
w.getProperty(UserUtils.LAST_NAME_KEY), w.getCalculatedName(), -1);
String password = GeneratePasswordUtils.generatePswd();
List<String> roles = w.getRoles();
this.usersManager.insertUser(u, password);
this.usersManager.activateUser(u);
u = this.usersManager.findUserByLoginName(w.getCalculatedName());
if (roles.size() > 0) {
this.usersManager.changeRoles(u, roles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ public Object executeJDBCCommand(Connection con)
});

Role[] roles = user.getGroups();

for (final Role role : roles) {
commands.add(new JDBCCommand() {

Expand Down Expand Up @@ -857,9 +858,11 @@ public Object executeJDBCCommand(Connection con)
.getInstanceOf("disassociateRole");
String sql = template.toString();
Role[] roles = user.getGroups();
for (Role r : roles) {
new JDBCUpdateTemplate(con, false).executeUpdate(sql,
user.getId(), r.getId());
if (roles != null) {
for (Role r : roles) {
new JDBCUpdateTemplate(con, false).executeUpdate(sql,
user.getId(), r.getId());
}
}
return getPreviousResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ public String getQueryString() {
else return "";
}

public boolean isUnderShibbolethSession() {
HttpServletRequest req = this.requestProvider.get();
return ShibbolethUtils.isUnderShibbolethSession(req);
}

public boolean getShibbLogoutEnabled() {
HttpServletRequest req = this.requestProvider.get();
if (ShibbolethUtils.isUnderShibbolethSession(req)) {
return KConfiguration.getInstance().getConfiguration().getBoolean("security.shib.logout.enabled",false);
}
return true;
}


public String getShibbLogout() {
HttpServletRequest req = this.requestProvider.get();
Expand Down
19 changes: 11 additions & 8 deletions search/web/inc/menu.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@

<!-- logout - only for logged -->
<scrd:loggedusers>
<c:choose>
<c:when test="${empty buttons.shibbLogout}">
<a href="logout.jsp?redirectURL=${searchFormViewObject.requestedAddress}"><fmt:message bundle="${lctx}">application.logout</fmt:message></a>
</c:when>
<c:otherwise>
<a href="${buttons.shibbLogout}"><view:msg>application.logout</view:msg></a>
</c:otherwise>
</c:choose>

<c:if test="${buttons.underShibbolethSession == false}">
<a href="logout.jsp?redirectURL=${searchFormViewObject.requestedAddress}"><fmt:message bundle="${lctx}">application.logout</fmt:message></a>
</c:if>

<c:if test="${buttons.underShibbolethSession == true}">
<c:if test="${buttons.shibbLogout}">
<a href="${buttons.shibbLogout}"><view:msg>application.logout</view:msg></a>
</c:if>
</c:if>

</scrd:loggedusers>

<a href="javascript:showHelp('<c:out value="${param.language}" />');"><view:msg>application.help</view:msg>
Expand Down

0 comments on commit 9e9b779

Please sign in to comment.