CAS Unit Tests
Clover coverage report - CAS Unit Tests
Coverage timestamp: Mon Jul 4 2005 18:13:17 CDT
file stats: LOC: 150   Methods: 2
NCLOC: 121   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Unenroll.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.impl.client;
 12   
 13    import org.globus.cas.CASPortType;
 14   
 15    import org.globus.cas.impl.CasConstants;
 16   
 17    import org.globus.cas.types.DeleteObject;
 18   
 19    import org.globus.cas.faults.CasFault;
 20    import org.globus.cas.faults.NoPermissionFault;
 21   
 22    import org.globus.wsrf.utils.FaultHelper;
 23    /**
 24    * Command client used to unenroll trust anchor, user, namespace, service type
 25    */
 26    public class Unenroll {
 27   
 28    static String msg =
 29    " Usage : cas-remove [<options>] <objectType> <objectDetails>\n"
 30    + " Options are -debug Runs with debug trace \n"
 31    + " -c <instanceURl> Specify URL for CAS server\n"
 32    + " -help Prints this message\n"
 33    + " -v Prints version number\n"
 34    + " -s Identity of CAS server. If not specified, will \n"
 35    + " defualt to host authorization.\n"
 36    + " -m security mechanism. 'msg' for secure message\n"
 37    + " or 'conv' for secure conversation or 'trans' for\n"
 38    + " transport security. If unspecified, if instance\n"
 39    + " url is 'https', then trasport security is used \n"
 40    + " else mechanism defaults to secure message\n"
 41    + " -p protection type, 'sig' signature and 'enc' \n"
 42    + " encryption, defaults to signature\n"
 43    + " <objectType> : Type of object to unenroll. Should be \n"
 44    + " \"trustAnchor\" or \"user\" or \"namespace\"\n"
 45    + " \"object\" or \"serviceType\"\n"
 46    + " <objectDetails> :\n"
 47    + " If \"trustAnchor\", <nickname> \n"
 48    + " <nickname> : Nickname of trust anchor \n"
 49    + " If \"user\", <nickname>\n"
 50    + " <nickname> : Nickname of user \n"
 51    + " If \"namespace\", <nickname>\n"
 52    + " <nickname> : Nickname of namespace \n"
 53    + " If \"object\", <objectName> <objectNamespce>\n"
 54    + " <objectName> : Name of object\n"
 55    + " <objectNamespace> : Namespace the object belongs to\n"
 56    + " If \"serviceType\", <serviceType>\n"
 57    + " <serviceType> : Name of the service type \n";
 58   
 59    static boolean debug = false;
 60   
 61  0 public static void main(String args[]) throws Exception {
 62   
 63  0 if (args.length<1) {
 64  0 System.out.println(msg);
 65  0 System.exit(0);
 66    }
 67   
 68  0 CasClientSetup clientSetup = new CasClientSetup(args, msg);
 69  0 String instanceURL = clientSetup.getInstanceURL();
 70  0 String serverIdentity = clientSetup.getServerIdentity();
 71  0 int startIndex = clientSetup.argsStartIndex;
 72  0 debug = clientSetup.debug;
 73   
 74  0 printMessage("CAS client to unenroll CAS entities.");
 75   
 76  0 if (args.length < startIndex + 1) {
 77  0 System.err.println("Not enough parameters");
 78  0 System.err.println(msg);
 79  0 System.exit(-1);
 80    }
 81   
 82  0 printMessage("Argument starting index is " + startIndex);
 83  0 String objectType = args[startIndex];
 84   
 85  0 try {
 86    // Trust anchor or user
 87  0 if (objectType.equals(CasConstants.TRUSTANCHOR_SPEC)) {
 88  0 CASPortType casPort =
 89    clientSetup.getCASPort(instanceURL, 2, serverIdentity);
 90  0 printMessage(" Remove trust anchor " + args[startIndex+1]);
 91  0 casPort.removeTrustAnchor(args[startIndex+1]);
 92  0 } else if (objectType.equals(CasConstants.USER_SPEC)) {
 93  0 CASPortType casPort =
 94    clientSetup.getCASPort(instanceURL, 2, serverIdentity);
 95  0 printMessage(" Remove user " + args[startIndex+1]);
 96  0 casPort.removeUser(args[startIndex+1]);
 97  0 } else if (objectType.equals(CasConstants.NAMESPACE_SPEC)) {
 98  0 CASPortType casPort =
 99    clientSetup.getCASPort(instanceURL, 2, serverIdentity);
 100  0 printMessage("Unenroll Namespace " + args[startIndex+1]);
 101  0 casPort.deleteObjectNamespace(args[startIndex+1]);
 102  0 } else if (objectType.equals(CasConstants.OBJECT_SPEC)) {
 103  0 CASPortType casPort =
 104    clientSetup.getCASPort(instanceURL, 3, serverIdentity);
 105  0 printMessage("Object " + args[startIndex+1] + " "
 106    + args[startIndex+2]);
 107  0 DeleteObject deleteObject = new DeleteObject();
 108  0 deleteObject.setObjectName(args[startIndex+1]);
 109  0 deleteObject.setObjectNamespace(args[startIndex+2]);
 110  0 casPort.deleteObject(deleteObject);
 111  0 } else if (objectType.equals(CasConstants.SERVICETYPE_SPEC)) {
 112  0 CASPortType casPort =
 113    clientSetup.getCASPort(instanceURL, 2, serverIdentity);
 114  0 printMessage("ServiceType " + args[startIndex+1]);
 115  0 casPort.deleteServiceType(args[startIndex+1]);
 116    } else {
 117  0 System.err.println("Erroneous object type " + objectType);
 118  0 System.err.println(msg);
 119  0 System.exit(-1);
 120    }
 121    } catch (NoPermissionFault noPermFault) {
 122  0 System.err.println(noPermFault.getDescription());
 123  0 System.exit(-1);
 124    } catch (CasFault casFault) {
 125  0 if (!debug) {
 126  0 String desc =
 127    (new FaultHelper(casFault)).getDescriptionAsString();
 128  0 System.err.println(desc);
 129    } else {
 130  0 System.err.println((new FaultHelper(casFault))
 131    .getStackTrace());
 132    }
 133  0 System.exit(-1);
 134    } catch (Exception exp) {
 135  0 if (debug) {
 136  0 System.err.println(exp.toString());
 137    } else {
 138  0 System.err.println(CasClientSetup.getErrorMsg(exp));
 139    }
 140  0 System.exit(-1);
 141    }
 142  0 System.out.println("Completed successfully");
 143    }
 144   
 145  0 private static void printMessage(String msg) {
 146  0 if (debug) {
 147  0 System.out.println(msg);
 148    }
 149    }
 150    }