CAS Unit Tests
Clover coverage report - CAS Unit Tests
Coverage timestamp: Mon Jul 4 2005 18:13:17 CDT
file stats: LOC: 135   Methods: 1
NCLOC: 102   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ListCasObjects.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.faults.CasFault;
 16    import org.globus.cas.faults.NoPermissionFault;
 17   
 18    import org.globus.cas.types.ArrayOfString;
 19   
 20    import org.globus.cas.impl.CasConstants;
 21   
 22    import org.globus.wsrf.utils.FaultHelper;
 23   
 24    /**
 25    * Command line client to get a list of trustAnchor/namespace/
 26    * user/userGroup/object/objectGroup/serviceType/serviceTypeAction/
 27    * serviceActionGroup.
 28    */
 29    public class ListCasObjects {
 30   
 31    static String msg =
 32    " Usage : cas-list-object [<options>] <objectType>\n"
 33    + " Options are -debug Runs with debug trace \n"
 34    + " -c <instanceURl> Specify URL for CAS server\n"
 35    + " -help Prints this message\n"
 36    + " -v Prints version number\n"
 37    + " -s Identity of CAS server. If not specified, will \n"
 38    + " defualt to host authorization.\n"
 39    + " -m security mechanism. 'msg' for secure message\n"
 40    + " or 'conv' for secure conversation or 'trans' for\n"
 41    + " transport security. If unspecified, if instance\n"
 42    + " url is 'https', then trasport security is used \n"
 43    + " else mechanism defaults to secure message\n"
 44    + " -p protection type, 'sig' signature and 'enc' \n"
 45    + " encryption, defaults to signature\n"
 46    + " <objectType> : Type of object that needs to be listed. Should be\n"
 47    + " \"user\" or \"userGroup\" or \"object\" or \n"
 48    + " \"objectGroup\" or \"namespace\" or \n"
 49    + " \"serviceType\" or \"serviceAction\" or \n"
 50    + " \"serviceActionGroup\" or \"policy\"";
 51   
 52    static boolean debug = false;
 53   
 54  0 public static void main(String args[]) throws Exception {
 55   
 56  0 if (args.length<1) {
 57  0 System.out.println(msg);
 58  0 System.exit(0);
 59    }
 60  0 CasClientSetup clientSetup = new CasClientSetup(args, msg);
 61  0 String instanceURL = clientSetup.getInstanceURL();
 62  0 String serverIdentity = clientSetup.getServerIdentity();
 63  0 int startIndex = clientSetup.argsStartIndex;
 64  0 debug = clientSetup.debug;
 65   
 66  0 if (debug)
 67  0 System.out.println("CAS client to return a list of CAS objects.");
 68   
 69  0 if (args.length < startIndex + 1) {
 70  0 System.err.println("Not enough parameters");
 71  0 System.err.println(msg);
 72  0 System.exit(-1);
 73    }
 74   
 75  0 String type = args[startIndex].trim();
 76  0 if ( !(type.equals(CasConstants.TRUSTANCHOR_SPEC) ||
 77    type.equals(CasConstants.USER_SPEC) ||
 78    type.equals(CasConstants.USERGP_SPEC) ||
 79    type.equals(CasConstants.OBJECT_SPEC) ||
 80    type.equals(CasConstants.OBJECTGP_SPEC) ||
 81    type.equals(CasConstants.NAMESPACE_SPEC) ||
 82    type.equals(CasConstants.POLICY_SPEC) ||
 83    type.equals(CasConstants.SERVICEACTION_SPEC) ||
 84    type.equals(CasConstants.SERVICEACTIONGP_SPEC) ||
 85    type.equals(CasConstants.SERVICETYPE_SPEC))) {
 86   
 87  0 System.err.println("Erroneous type " + type);
 88  0 System.err.println(msg);
 89  0 System.exit(-1);
 90    }
 91   
 92   
 93  0 CASPortType casPort =
 94    clientSetup.getCASPort(instanceURL, 1, serverIdentity);
 95   
 96  0 String[] objects = null;
 97  0 try {
 98  0 ArrayOfString arrayOfString = casPort.list(type);
 99  0 if (arrayOfString != null) {
 100  0 objects = arrayOfString.getStrings();
 101    }
 102    } catch (NoPermissionFault noPermFault) {
 103  0 System.err.println(noPermFault.getDescription());
 104  0 System.exit(-1);
 105    } catch (CasFault casFault) {
 106  0 if (!debug) {
 107  0 String desc =
 108    (new FaultHelper(casFault)).getDescriptionAsString();
 109  0 System.err.println(desc);
 110    } else {
 111  0 System.err.println((new FaultHelper(casFault))
 112    .getStackTrace());
 113    }
 114  0 System.exit(-1);
 115    } catch (Exception exp) {
 116  0 if (debug) {
 117  0 System.err.println(exp.toString());
 118    } else {
 119  0 System.err.println(CasClientSetup.getErrorMsg(exp));
 120    }
 121  0 System.exit(-1);
 122    }
 123   
 124  0 if (objects == null) {
 125  0 System.out.println("No CasObject of type " + type + " found");
 126    }
 127    else {
 128  0 System.out.println("List:");
 129  0 for (int i=0; i<objects.length; i++) {
 130  0 System.out.println(objects[i]);
 131    }
 132    }
 133  0 System.out.println("Completed successfully");
 134    }
 135    }