Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OATS-CADC
ac
Commits
6b3dc505
Commit
6b3dc505
authored
Mar 24, 2016
by
Dustin Jenkins
Browse files
Story 1890: Fix for removing users.
parent
cbe3df3b
Changes
5
Hide whitespace changes
Inline
Side-by-side
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java
View file @
6b3dc505
...
...
@@ -815,7 +815,7 @@ public class LdapUserDAO extends LdapDAO
logger
.
debug
(
"search filter: "
+
filter
);
final
String
[]
attributes
=
new
String
[]
{
LDAP_U
ID
,
LDAP_FIRST_NAME
,
LDAP_LAST_NAME
};
{
LDAP_U
SER_NAME
,
LDAP_FIRST_NAME
,
LDAP_LAST_NAME
};
final
SearchRequest
searchRequest
=
new
SearchRequest
(
usersDN
,
SearchScope
.
ONE
,
filter
,
attributes
);
...
...
@@ -831,10 +831,10 @@ public class LdapUserDAO extends LdapDAO
next
.
getAttributeValue
(
LDAP_FIRST_NAME
);
final
String
lastName
=
next
.
getAttributeValue
(
LDAP_LAST_NAME
).
trim
();
final
String
u
id
=
next
.
getAttributeValue
(
LDAP_U
ID
);
final
String
u
sername
=
next
.
getAttributeValue
(
LDAP_U
SER_NAME
);
User
user
=
new
User
();
user
.
getIdentities
().
add
(
new
HttpPrincipal
(
u
id
));
user
.
getIdentities
().
add
(
new
HttpPrincipal
(
u
sername
));
// Only add Personal Details if it is relevant.
if
(
StringUtil
.
hasLength
(
firstName
)
&&
...
...
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/web/groups/CreateGroupAction.java
View file @
6b3dc505
...
...
@@ -107,7 +107,7 @@ public class CreateGroupAction extends AbstractGroupAction
}
for
(
User
usr
:
group
.
getUserMembers
())
{
addedMembers
.
add
(
usr
.
get
Http
Principal
().
getName
());
addedMembers
.
add
(
usr
.
get
X500
Principal
().
getName
());
}
}
logGroupInfo
(
group
.
getID
(),
null
,
addedMembers
);
...
...
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/web/groups/RemoveUserMemberAction.java
View file @
6b3dc505
...
...
@@ -78,6 +78,7 @@ import ca.nrc.cadc.ac.User;
import
ca.nrc.cadc.ac.server.PluginFactory
;
import
ca.nrc.cadc.ac.server.UserPersistence
;
import
ca.nrc.cadc.auth.AuthenticationUtil
;
import
ca.nrc.cadc.util.ObjectUtil
;
public
class
RemoveUserMemberAction
extends
AbstractGroupAction
{
...
...
@@ -102,6 +103,7 @@ public class RemoveUserMemberAction extends AbstractGroupAction
User
user
=
getUserPersistence
().
getAugmentedUser
(
userPrincipal
);
User
toRemove
=
new
User
();
ObjectUtil
.
setField
(
toRemove
,
user
.
getID
(),
"id"
);
toRemove
.
getIdentities
().
addAll
(
user
.
getIdentities
());
if
(!
group
.
getUserMembers
().
remove
(
toRemove
))
...
...
cadcAccessControl/src/ca/nrc/cadc/ac/User.java
View file @
6b3dc505
...
...
@@ -68,6 +68,7 @@
*/
package
ca.nrc.cadc.ac
;
import
java.io.PrintWriter
;
import
java.security.Principal
;
import
java.util.Comparator
;
import
java.util.Date
;
...
...
@@ -77,8 +78,12 @@ import java.util.TreeSet;
import
ca.nrc.cadc.auth.HttpPrincipal
;
import
javax.security.auth.x500.X500Principal
;
public
class
User
{
// How on God's green earth is this used? Where is it set?
// jenkinsd 2016.03.24
private
InternalID
id
;
private
Set
<
Principal
>
identities
=
new
TreeSet
<
Principal
>(
new
PrincipalComparator
());
...
...
@@ -141,6 +146,14 @@ public class User
return
null
;
}
public
X500Principal
getX500Principal
()
{
final
Set
<
X500Principal
>
identities
=
getIdentities
(
X500Principal
.
class
);
return
identities
.
isEmpty
()
?
null
:
identities
.
iterator
().
next
();
}
/**
* A User is considered consistent if the User's set of identities are a superset
* of this Users set of identities.
...
...
cadcAccessControl/src/ca/nrc/cadc/ac/client/UserClient.java
View file @
6b3dc505
...
...
@@ -117,8 +117,8 @@ public class UserClient
/**
* Constructor.
*
* @param
baseURL
The UR
L
of the supporting access control web service
* obtained from the registry.
* @param
serviceURI
The UR
I
of the supporting access control web service
*
obtained from the registry.
*/
public
UserClient
(
URI
serviceURI
)
throws
IllegalArgumentException
...
...
@@ -129,7 +129,7 @@ public class UserClient
public
UserClient
(
URI
serviceURI
,
RegistryClient
registryClient
)
{
if
(
serviceURI
==
null
)
throw
new
IllegalArgumentException
(
"
invalid s
erviceURI
: "
+
serviceURI
);
throw
new
IllegalArgumentException
(
"
S
ervice
URI
cannot be null."
);
if
(
serviceURI
.
getFragment
()
!=
null
)
throw
new
IllegalArgumentException
(
"invalid serviceURI (fragment not allowed): "
+
serviceURI
);
...
...
@@ -204,7 +204,9 @@ public class UserClient
{
URL
usersURL
=
registryClient
.
getServiceURL
(
usersURI
,
"https"
);
final
List
<
User
>
webUsers
=
new
ArrayList
<
User
>();
HttpDownload
httpDownload
=
new
HttpDownload
(
usersURL
,
new
JsonUserListInputStreamWrapper
(
webUsers
));
HttpDownload
httpDownload
=
new
HttpDownload
(
usersURL
,
new
JsonUserListInputStreamWrapper
(
webUsers
));
httpDownload
.
setRequestProperty
(
"Accept"
,
"application/json"
);
httpDownload
.
run
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment