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 java.util.StringTokenizer;
12 import org.apache.commons.logging.Log;
13 import org.apache.commons.logging.LogFactory;
14 import org.opensciencegrid.authz.common.GridId;
15 import org.opensciencegrid.authz.common.LocalId;
16 import org.opensciencegrid.authz.service.GRIDIdentityMappingService;
17
18 /*** Implements a GRID Identity Mapping Service by using GUMS logic.
19 *
20 * @author Gabriele Carcassi
21 */
22 public class GUMSAuthZServiceImpl implements GRIDIdentityMappingService {
23 private Log log = LogFactory.getLog(GUMSAuthZServiceImpl.class);
24 private static GUMSAPI gums = new GUMSAPIImpl();
25
26 public LocalId mapCredentials(GridId gridID) {
27 log.debug("Mapping credentials on '" + gridID.getHostDN() + "' for '" + gridID.getUserDN() + "' coming as '" + gridID.getUserFQAN() + "' authenticated by '" + gridID.getUserFQANIssuer() + "'");
28 if (gridID.getHostDN() == null) throw new RuntimeException("The request had a null host");
29 String username = gums.mapUser(gridID.getHostDN(), gridID.getUserDN(), gridID.getUserFQAN());
30 log.debug("Denied access");
31 if (username == null)
32 return null;
33 LocalId id = new LocalId();
34 id.setUserName(username);
35 log.debug("Credentials mapped on '" + gridID.getHostDN() + "' to '" + id.getUserName() + "' part of '" + id.getGroupName() + "'");
36 return id;
37 }
38
39 }