CAS Unit Tests
Clover coverage report - CAS Unit Tests
Coverage timestamp: Mon Jul 4 2005 18:13:17 CDT
file stats: LOC: 131   Methods: 7
NCLOC: 95   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestSetup.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Portions of this file Copyright 1999-2005 University of Chicago
 3    * Portions of this file Copyright 1999-2005 The University of Southern California.
 4    *
 5    * This file or a portion of this file is licensed under the
 6    * terms of the Globus Toolkit Public License, found at
 7    * http://www.globus.org/toolkit/download/license.html.
 8    * If you redistribute this file, with or without
 9    * modifications, you must include this notice in the file.
 10    */
 11    package org.globus.cas.utils;
 12   
 13    import org.globus.cas.CASPortType;
 14    import org.globus.cas.CommunityAuthorizationServiceLocator;
 15   
 16    import org.globus.wsrf.impl.security.authentication.Constants;
 17    import org.globus.wsrf.impl.security.authorization.Authorization;
 18    import org.globus.wsrf.impl.security.authorization.NoAuthorization;
 19    import org.globus.wsrf.impl.security.authorization.IdentityAuthorization;
 20   
 21    import javax.xml.rpc.Stub;
 22   
 23    import org.globus.axis.gsi.GSIConstants;
 24   
 25    import java.net.URL;
 26   
 27    import org.apache.commons.logging.Log;
 28    import org.apache.commons.logging.LogFactory;
 29   
 30    public class TestSetup {
 31   
 32    static Log logger = LogFactory.getLog(TestSetup.class.getName());
 33    String instanceUrl = null;
 34    CASPortType casPort = null;
 35    Object mechanism = Constants.GSI_TRANSPORT;
 36    String mechanismOption = "-m trans";
 37    Object protection = Constants.SIGNATURE;
 38    String protectionOption = "-p sig";
 39    TestSetup testSetup = null;
 40    Authorization authz = null;
 41    String authzOption = null;
 42   
 43  0 public TestSetup(String host, String port, String securityType,
 44    String protType) {
 45  0 this(host, port, securityType, protType, null);
 46    }
 47   
 48  0 public TestSetup(String host, String port, String securityType,
 49    String protType, String identity) {
 50  0 if (securityType != null) {
 51  0 if (securityType.equalsIgnoreCase("message")) {
 52  0 this.mechanism = Constants.GSI_SEC_MSG;
 53  0 this.mechanismOption = "-m msg";
 54  0 } else if (securityType.equalsIgnoreCase("conversation")) {
 55  0 this.mechanism = Constants.GSI_SEC_CONV;
 56  0 this.mechanismOption = "-m conv";
 57  0 } else if (securityType.equalsIgnoreCase("transport")) {
 58  0 this.mechanism = Constants.GSI_TRANSPORT;
 59    }
 60    }
 61   
 62  0 if (protType != null) {
 63  0 if (protType.equalsIgnoreCase("signature")) {
 64  0 this.protection = Constants.SIGNATURE;
 65   
 66  0 } if (protType.equalsIgnoreCase("encryption")) {
 67  0 this.protection = Constants.ENCRYPTION;
 68  0 this.protectionOption = "-p enc";
 69    }
 70    }
 71   
 72  0 if (host == null) {
 73  0 host = "127.0.0.1";
 74    }
 75   
 76  0 if (port == null) {
 77  0 port = "8080";
 78    }
 79   
 80  0 if (mechanism.equals(Constants.GSI_TRANSPORT)) {
 81  0 this.instanceUrl = "https://" + host + ":" + port
 82    + "/wsrf/services/CASService";
 83    } else {
 84  0 this.instanceUrl = "http://" + host + ":" + port
 85    + "/wsrf/services/CASService";
 86    }
 87   
 88  0 if (identity == null) {
 89  0 this.authz = NoAuthorization.getInstance();
 90    } else {
 91  0 this.authz = new IdentityAuthorization(identity);
 92  0 this.authzOption = "-s " + identity;
 93    }
 94    }
 95   
 96  0 public synchronized CASPortType getCasPort() throws Exception {
 97   
 98  0 if (this.casPort != null) {
 99  0 return this.casPort;
 100    }
 101   
 102  0 CommunityAuthorizationServiceLocator loc =
 103    new CommunityAuthorizationServiceLocator();
 104   
 105  0 logger.debug("Instance url " + instanceUrl);
 106  0 this.casPort =
 107    loc.getCASPortTypePort(new URL(instanceUrl));
 108  0 ((Stub)casPort)._setProperty((String)mechanism, protection);
 109   
 110  0 ((Stub)casPort)._setProperty(Constants.AUTHORIZATION,
 111    this.authz);
 112   
 113  0 return casPort;
 114    }
 115   
 116  0 public String getMechanismOption() {
 117  0 return this.mechanismOption;
 118    }
 119   
 120  0 public String getProtectionOption() {
 121  0 return this.protectionOption;
 122    }
 123   
 124  0 public String getAuthzOption() {
 125  0 return this.authzOption;
 126    }
 127   
 128  0 public String getInstanceUrl() {
 129  0 return this.instanceUrl;
 130    }
 131    }