1
2
3
4
5
6
7 package gov.bnl.gums.service;
8
9 import gov.bnl.gums.admin.GUMSAPI;
10 import gov.bnl.gums.admin.GUMSAPIImpl;
11 import org.apache.commons.logging.Log;
12 import org.apache.commons.logging.LogFactory;
13 import org.opensciencegrid.authz.common.GridId;
14 import org.opensciencegrid.authz.common.LocalId;
15 import org.opensciencegrid.authz.service.GRIDIdentityMappingService;
16
17
18
19
20
21 public class GUMSAuthZServiceImpl implements GRIDIdentityMappingService {
22 private Log log = LogFactory.getLog(GUMSAuthZServiceImpl.class);
23 private static GUMSAPI gums = new GUMSAPIImpl();
24
25 public LocalId mapCredentials(GridId gridID) {
26 log.debug("Mapping credentials on '" + gridID.getHostDN() + "' for '" + gridID.getUserDN() + "' coming as '" + gridID.getUserFQAN() + "' authenticated by '" + gridID.getUserFQANIssuer() + "'");
27 if (gridID.getHostDN() == null) throw new RuntimeException("The request had a null host");
28 String account = gums.mapUser(gridID.getHostDN(), gridID.getUserDN(), gridID.getUserFQAN());
29 log.debug("Denied access");
30 if (account == null)
31 return null;
32 LocalId id = new LocalId();
33 id.setUserName(account);
34 log.debug("Credentials mapped on '" + gridID.getHostDN() + "' to '" + id.getUserName() + "' part of '" + id.getGroupName() + "'");
35 return id;
36 }
37
38 }