Skip to content

Commit

Permalink
Rework for client, and undo access-control-server changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
at88mph committed Oct 23, 2023
1 parent 948bdec commit 14e00e1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cadc-access-control-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '1.3.34'
version = '1.3.33'

description = 'OpenCADC User+Group server library'
def git_url = 'https://github.com/opencadc/ac'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.auth.SignedToken;
import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.util.FileUtil;
import ca.nrc.cadc.util.MultiValuedProperties;
import ca.nrc.cadc.util.PropertiesReader;
import ca.nrc.cadc.util.RsaSignatureGenerator;
Expand Down Expand Up @@ -334,7 +335,6 @@ private static Map<String, Object> buildTokenClaimsSet(RelyParty rp, String requ

if (rp.getClaims().contains(RelyParty.Claim.NAME)) {
claimsMap.put(RelyParty.Claim.NAME.getValue(), useridPrincipal.getName());
claimsMap.put(RelyParty.Claim.PREFERRED_USERNAME.getValue(), useridPrincipal.getName());
}
if (rp.getClaims().contains(RelyParty.Claim.EMAIL)) {
claimsMap.put(RelyParty.Claim.EMAIL.getValue(), email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public boolean equals(Object o) {

public enum Claim {
NAME("name", "Name"),
PREFERRED_USERNAME("preferred_username", "Username"),
EMAIL("email", "Email Address"),
GROUPS("memberOf", "Group Memberships");

Expand Down
2 changes: 1 addition & 1 deletion cadc-gms/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '1.0.9'
version = '1.0.10'

description = 'OpenCADC GMS API library'
def git_url = 'https://github.com/opencadc/ac'
Expand Down
22 changes: 16 additions & 6 deletions cadc-gms/src/main/java/org/opencadc/auth/PosixMapperClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import ca.nrc.cadc.auth.AuthenticationUtil;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.PosixPrincipal;
import ca.nrc.cadc.io.ResourceIterator;
import ca.nrc.cadc.net.HttpGet;
import ca.nrc.cadc.net.ResourceAlreadyExistsException;
import ca.nrc.cadc.net.ResourceNotFoundException;
Expand All @@ -88,7 +89,6 @@
import java.security.Principal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.security.auth.Subject;
Expand Down Expand Up @@ -234,14 +234,14 @@ public List<PosixGroup> getURI(List<Integer> groups)
* @throws ResourceAlreadyExistsException Not used.
* @throws InterruptedException Should not ever happen.
*/
public Iterator<PosixPrincipal> getUserMap() throws IOException, ResourceNotFoundException,
ResourceAlreadyExistsException, InterruptedException {
public ResourceIterator<PosixPrincipal> getUserMap() throws IOException, ResourceNotFoundException,
ResourceAlreadyExistsException, InterruptedException {
final URL userMapURL = getServiceURL(Standards.POSIX_USERMAP);
final HttpGet get = new HttpGet(userMapURL, true);
get.setRequestProperty("accept", "text/tab-separated-values");
get.prepare();

return new Iterator<PosixPrincipal>() {
return new ResourceIterator<PosixPrincipal>() {
private final BufferedReader reader = new BufferedReader(new InputStreamReader(get.getInputStream()));
private String line;

Expand All @@ -260,6 +260,11 @@ public PosixPrincipal next() {
line = null;
return nextPrincipal;
}

@Override
public void close() throws IOException {
reader.close();
}
};
}

Expand All @@ -275,14 +280,14 @@ public PosixPrincipal next() {
* @throws ResourceAlreadyExistsException Not used.
* @throws InterruptedException Should not ever happen.
*/
public Iterator<PosixGroup> getGroupMap() throws IOException, ResourceNotFoundException,
public ResourceIterator<PosixGroup> getGroupMap() throws IOException, ResourceNotFoundException,
ResourceAlreadyExistsException, InterruptedException {
final URL userMapURL = getServiceURL(Standards.POSIX_GROUPMAP);
final HttpGet get = new HttpGet(userMapURL, true);
get.setRequestProperty("accept", "text/tab-separated-values");
get.prepare();

return new Iterator<PosixGroup>() {
return new ResourceIterator<PosixGroup>() {
private final BufferedReader reader = new BufferedReader(new InputStreamReader(get.getInputStream()));
private String line;
@Override
Expand All @@ -300,6 +305,11 @@ public PosixGroup next() {
line = null;
return posixGroup;
}

@Override
public void close() throws IOException {
reader.close();
}
};
}

Expand Down

0 comments on commit 14e00e1

Please sign in to comment.