1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * ident "%Z%%M% %I% %E% SMI" 24*0Sstevel@tonic-gate * 25*0Sstevel@tonic-gate * Copyright (c) 1999-2000 by Sun Microsystems, Inc. 26*0Sstevel@tonic-gate * All rights reserved. 27*0Sstevel@tonic-gate */ 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate import java.awt.*; 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate import Principal; 32*0Sstevel@tonic-gate import Policy; 33*0Sstevel@tonic-gate import Defaults; 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate public class Test { 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate /** 38*0Sstevel@tonic-gate * main method for easier debugging 39*0Sstevel@tonic-gate */ main(String[] args)40*0Sstevel@tonic-gate public static void main(String[] args) { 41*0Sstevel@tonic-gate System.out.println("\nThese are unit tests for the JNI code."); 42*0Sstevel@tonic-gate System.out.println("They assume the existence of a jnitest/admin"); 43*0Sstevel@tonic-gate System.out.println("user principal, with the password 'test123',"); 44*0Sstevel@tonic-gate System.out.println("and the existance of a 'default' policy.\n"); 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate Kadmin k = new Kadmin(); 47*0Sstevel@tonic-gate String [] p; 48*0Sstevel@tonic-gate Defaults d = new Defaults("$HOME/.gkadmin", Color.white); 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate System.out.println("==> Set up a session for jnitest/admin.\n"); 51*0Sstevel@tonic-gate boolean b = false; 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate System.out.println("*** First, one with a bogus port number."); 54*0Sstevel@tonic-gate try { 55*0Sstevel@tonic-gate b = k.sessionInit("jnitest/admin", "test123", 56*0Sstevel@tonic-gate "SUNSOFT.ENG.SUN.COM", "ulong.eng.sun.com", 333); 57*0Sstevel@tonic-gate b = false; 58*0Sstevel@tonic-gate k.sessionExit(); 59*0Sstevel@tonic-gate System.out.println("Unexpected success!\n"); 60*0Sstevel@tonic-gate } catch (Exception e) { 61*0Sstevel@tonic-gate b = false; 62*0Sstevel@tonic-gate System.out.println("Expected failure "+e.getMessage()+"\n"); 63*0Sstevel@tonic-gate } 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate System.out.println("*** Next, one with the correct port number."); 66*0Sstevel@tonic-gate try { 67*0Sstevel@tonic-gate b = k.sessionInit("jnitest/admin", "test123", 68*0Sstevel@tonic-gate "SUNSOFT.ENG.SUN.COM", "ulong.eng.sun.com", 749); 69*0Sstevel@tonic-gate b = false; 70*0Sstevel@tonic-gate k.sessionExit(); 71*0Sstevel@tonic-gate System.out.println("sessionInit was successful.\n"); 72*0Sstevel@tonic-gate } catch (Exception e) { 73*0Sstevel@tonic-gate b = false; 74*0Sstevel@tonic-gate System.out.println("Unexpected exception!"+e.getMessage()+"\n"); 75*0Sstevel@tonic-gate } 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate System.out.println("*** Finally, try one with a zero port number."); 78*0Sstevel@tonic-gate try { 79*0Sstevel@tonic-gate b = k.sessionInit("jnitest/admin", "test123", 80*0Sstevel@tonic-gate "SUNSOFT.ENG.SUN.COM", "ulong.eng.sun.com", 0); 81*0Sstevel@tonic-gate } catch (Exception e) { 82*0Sstevel@tonic-gate b = false; 83*0Sstevel@tonic-gate System.out.println("Unexpected exception!"+e.getMessage()+"\n"); 84*0Sstevel@tonic-gate } 85*0Sstevel@tonic-gate if (!b) { 86*0Sstevel@tonic-gate System.out.println("sessionInit failed\n"); 87*0Sstevel@tonic-gate return; 88*0Sstevel@tonic-gate } 89*0Sstevel@tonic-gate System.out.println("sessionInit was successful!\n"); 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate System.out.println("==> Get the lists\n"); 93*0Sstevel@tonic-gate System.out.println("*** Principal list"); 94*0Sstevel@tonic-gate try { 95*0Sstevel@tonic-gate p = k.getPrincipalList(); 96*0Sstevel@tonic-gate System.out.println("Called getPrincipalList()"); 97*0Sstevel@tonic-gate } catch (Exception e) { 98*0Sstevel@tonic-gate p = null; 99*0Sstevel@tonic-gate System.out.println("getPrincipalList exception"+e.getMessage()); 100*0Sstevel@tonic-gate } 101*0Sstevel@tonic-gate for (int i = 0; p != null && i < p.length; i++) 102*0Sstevel@tonic-gate System.out.println(p[i]); 103*0Sstevel@tonic-gate System.out.println(new Integer(p.length).toString()+" entries."); 104*0Sstevel@tonic-gate System.out.println("Principal list done\n"); 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate System.out.println("*** Policy list"); 108*0Sstevel@tonic-gate try { 109*0Sstevel@tonic-gate p = k.getPolicyList(); 110*0Sstevel@tonic-gate System.out.println("Called getPolicyList()"); 111*0Sstevel@tonic-gate } catch (Exception e) { 112*0Sstevel@tonic-gate p = null; 113*0Sstevel@tonic-gate System.out.println("getPolicyList exception "+e.getMessage()); 114*0Sstevel@tonic-gate } 115*0Sstevel@tonic-gate for (int i = 0; p != null && i < p.length; i++) 116*0Sstevel@tonic-gate System.out.println(p[i]); 117*0Sstevel@tonic-gate System.out.println(new Integer(p.length).toString()+" entries."); 118*0Sstevel@tonic-gate System.out.println("Policy list done\n"); 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate System.out.println("==> Get privileges\n"); 122*0Sstevel@tonic-gate System.out.println("Calling getPrivs()"); 123*0Sstevel@tonic-gate int privs = 0; 124*0Sstevel@tonic-gate try { 125*0Sstevel@tonic-gate privs = k.getPrivs(); 126*0Sstevel@tonic-gate System.out.println("Privs are " 127*0Sstevel@tonic-gate +(new Integer(privs)).toHexString(privs)+"\n"); 128*0Sstevel@tonic-gate } catch (Exception e) { 129*0Sstevel@tonic-gate System.out.println("getPrivs exception "+e.getMessage()+"\n"); 130*0Sstevel@tonic-gate } 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate System.out.println("==> Database tests\n"); 134*0Sstevel@tonic-gate System.out.println("*** load a principal"); 135*0Sstevel@tonic-gate System.out.println("Calling Principal(k)"); 136*0Sstevel@tonic-gate Principal pr = new Principal(k, d); 137*0Sstevel@tonic-gate System.out.println("Calling loadPrincipal(jnitest/admin)"); 138*0Sstevel@tonic-gate try { 139*0Sstevel@tonic-gate b = k.loadPrincipal("jnitest/admin", pr); 140*0Sstevel@tonic-gate } catch (Exception e) { 141*0Sstevel@tonic-gate b = false; 142*0Sstevel@tonic-gate System.out.println("loadPrincipal exception "+e.getMessage()); 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate if (!b) 145*0Sstevel@tonic-gate System.out.println("loadPrincipal failed\n"); 146*0Sstevel@tonic-gate else { 147*0Sstevel@tonic-gate System.out.println("loadPrincipal succeeded, details:"); 148*0Sstevel@tonic-gate System.out.println(pr.toString()); 149*0Sstevel@tonic-gate } 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate System.out.println("*** load a policy"); 153*0Sstevel@tonic-gate Policy po = new Policy(k); 154*0Sstevel@tonic-gate try { 155*0Sstevel@tonic-gate b = k.loadPolicy("default", po); 156*0Sstevel@tonic-gate } catch (Exception e) { 157*0Sstevel@tonic-gate b = false; 158*0Sstevel@tonic-gate System.out.println("loadPolicy exception "+e.getMessage()); 159*0Sstevel@tonic-gate } 160*0Sstevel@tonic-gate if (!b) 161*0Sstevel@tonic-gate System.out.println("loadPolicy failed\n"); 162*0Sstevel@tonic-gate else { 163*0Sstevel@tonic-gate System.out.println("loadPolicy succeeded"); 164*0Sstevel@tonic-gate System.out.println("RefCount for "+po.PolicyName+" is " 165*0Sstevel@tonic-gate +po.RefCount.toString()); 166*0Sstevel@tonic-gate System.out.println("PwMinLife for "+po.PolicyName+" is " 167*0Sstevel@tonic-gate +po.PwMinLife.toString()+"\n"); 168*0Sstevel@tonic-gate } 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate System.out.println("*** load and store a policy"); 172*0Sstevel@tonic-gate try { 173*0Sstevel@tonic-gate b = k.loadPolicy("default", po); 174*0Sstevel@tonic-gate } catch (Exception e) { 175*0Sstevel@tonic-gate b = false; 176*0Sstevel@tonic-gate System.out.println("loadPolicy exception "+e.getMessage()); 177*0Sstevel@tonic-gate } 178*0Sstevel@tonic-gate if (b) { 179*0Sstevel@tonic-gate po.setPolMinlife("555"); 180*0Sstevel@tonic-gate try { 181*0Sstevel@tonic-gate b = k.savePolicy(po); 182*0Sstevel@tonic-gate } catch (Exception e) { 183*0Sstevel@tonic-gate b = false; 184*0Sstevel@tonic-gate System.out.println("savePolicy exception "+e.getMessage()); 185*0Sstevel@tonic-gate } 186*0Sstevel@tonic-gate if (!b) 187*0Sstevel@tonic-gate System.out.println("savePolicy failed\n"); 188*0Sstevel@tonic-gate else 189*0Sstevel@tonic-gate System.out.println("savePolicy succeeded\n"); 190*0Sstevel@tonic-gate } 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gate System.out.println("*** create a policy"); 194*0Sstevel@tonic-gate po = new Policy("aliens"); 195*0Sstevel@tonic-gate try { 196*0Sstevel@tonic-gate b = k.createPolicy(po); 197*0Sstevel@tonic-gate } catch (Exception e) { 198*0Sstevel@tonic-gate b = false; 199*0Sstevel@tonic-gate System.out.println("createPolicy exception "+e.getMessage()); 200*0Sstevel@tonic-gate } 201*0Sstevel@tonic-gate if (!b) 202*0Sstevel@tonic-gate System.out.println("createPolicy failed\n"); 203*0Sstevel@tonic-gate else 204*0Sstevel@tonic-gate System.out.println("createPolicy succeeded\n"); 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate System.out.println("*** verify creation"); 207*0Sstevel@tonic-gate try { 208*0Sstevel@tonic-gate p = k.getPolicyList(); 209*0Sstevel@tonic-gate System.out.println("Called getPolicyList()"); 210*0Sstevel@tonic-gate } catch (Exception e) { 211*0Sstevel@tonic-gate p = null; 212*0Sstevel@tonic-gate System.out.println("getPolicyList exception "+e.getMessage()); 213*0Sstevel@tonic-gate } 214*0Sstevel@tonic-gate for (int i = 0; p != null && i < p.length; i++) 215*0Sstevel@tonic-gate if (p[i].equals("aliens")) 216*0Sstevel@tonic-gate System.out.println("Found 'aliens' as expected"); 217*0Sstevel@tonic-gate System.out.println(new Integer(p.length).toString()+" entries."); 218*0Sstevel@tonic-gate System.out.println("Policy list done\n"); 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate System.out.println("*** delete a policy"); 222*0Sstevel@tonic-gate try { 223*0Sstevel@tonic-gate b = k.deletePolicy("aliens"); 224*0Sstevel@tonic-gate } catch (Exception e) { 225*0Sstevel@tonic-gate b = false; 226*0Sstevel@tonic-gate System.out.println("deletePolicy exception "+e.getMessage()); 227*0Sstevel@tonic-gate } 228*0Sstevel@tonic-gate if (!b) 229*0Sstevel@tonic-gate System.out.println("deletePolicy failed\n"); 230*0Sstevel@tonic-gate else 231*0Sstevel@tonic-gate System.out.println("deletePolicy succeeded\n"); 232*0Sstevel@tonic-gate 233*0Sstevel@tonic-gate System.out.println("*** verify deletion"); 234*0Sstevel@tonic-gate try { 235*0Sstevel@tonic-gate p = k.getPolicyList(); 236*0Sstevel@tonic-gate System.out.println("Called getPolicyList()"); 237*0Sstevel@tonic-gate } catch (Exception e) { 238*0Sstevel@tonic-gate p = null; 239*0Sstevel@tonic-gate System.out.println("getPolicyList exception "+e.getMessage()); 240*0Sstevel@tonic-gate } 241*0Sstevel@tonic-gate for (int i = 0; p != null && i < p.length; i++) 242*0Sstevel@tonic-gate if (p[i].equals("aliens")) 243*0Sstevel@tonic-gate System.out.println("Found 'aliens' - oops!"); 244*0Sstevel@tonic-gate System.out.println(new Integer(p.length).toString()+" entries."); 245*0Sstevel@tonic-gate System.out.println("Policy list done\n"); 246*0Sstevel@tonic-gate 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gate System.out.println("*** load and store a principal"); 249*0Sstevel@tonic-gate try { 250*0Sstevel@tonic-gate b = k.loadPrincipal("jnitest/admin", pr); 251*0Sstevel@tonic-gate } catch (Exception e) { 252*0Sstevel@tonic-gate b = false; 253*0Sstevel@tonic-gate System.out.println("loadPrincipal exception "+e); 254*0Sstevel@tonic-gate } 255*0Sstevel@tonic-gate if (b) { 256*0Sstevel@tonic-gate System.out.println("Loaded "+pr.toString()); 257*0Sstevel@tonic-gate pr.setPolicy("default"); 258*0Sstevel@tonic-gate System.out.println("Expiry "+pr.PrExpireTime.toString()); 259*0Sstevel@tonic-gate System.out.println("PwExpiry "+pr.PwExpireTime.toString()); 260*0Sstevel@tonic-gate try { 261*0Sstevel@tonic-gate b = k.savePrincipal(pr); 262*0Sstevel@tonic-gate } catch (Exception e) { 263*0Sstevel@tonic-gate b = false; 264*0Sstevel@tonic-gate System.out.println("savePrincipal exception "+e); 265*0Sstevel@tonic-gate } 266*0Sstevel@tonic-gate if (!b) 267*0Sstevel@tonic-gate System.out.println("savePrincipal failed\n"); 268*0Sstevel@tonic-gate else 269*0Sstevel@tonic-gate System.out.println("savePrincipal succeeded\n"); 270*0Sstevel@tonic-gate } 271*0Sstevel@tonic-gate 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate System.out.println("*** ensure a principal is absent"); 274*0Sstevel@tonic-gate try { 275*0Sstevel@tonic-gate b = k.deletePrincipal("harriet"); 276*0Sstevel@tonic-gate System.out.println("deleted principal\n"); 277*0Sstevel@tonic-gate } catch (Exception e) { 278*0Sstevel@tonic-gate System.out.println("Expected exception"+e+"\n"); 279*0Sstevel@tonic-gate } 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate System.out.println("*** create a principal"); 283*0Sstevel@tonic-gate pr = new Principal("harriet"); 284*0Sstevel@tonic-gate pr.setPassword("test123"); 285*0Sstevel@tonic-gate System.out.println("Built "+pr.toString()); 286*0Sstevel@tonic-gate try { 287*0Sstevel@tonic-gate b = k.createPrincipal(pr); 288*0Sstevel@tonic-gate } catch (Exception e) { 289*0Sstevel@tonic-gate b = false; 290*0Sstevel@tonic-gate System.out.println("createPrincipal exception "+e); 291*0Sstevel@tonic-gate } 292*0Sstevel@tonic-gate if (!b) 293*0Sstevel@tonic-gate System.out.println("createPrincipal failed"); 294*0Sstevel@tonic-gate else 295*0Sstevel@tonic-gate System.out.println("createPrincipal succeeded"); 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate System.out.println("*** verify creation"); 298*0Sstevel@tonic-gate try { 299*0Sstevel@tonic-gate p = k.getPrincipalList(); 300*0Sstevel@tonic-gate } catch (Exception e) { 301*0Sstevel@tonic-gate p = null; 302*0Sstevel@tonic-gate System.out.println("getPrincipalList exception "+e); 303*0Sstevel@tonic-gate } 304*0Sstevel@tonic-gate System.out.println("Called getPrincipalList()"); 305*0Sstevel@tonic-gate for (int i = 0; p != null && i < p.length; i++) 306*0Sstevel@tonic-gate if (p[i].equals("harriet")) 307*0Sstevel@tonic-gate System.out.println("Found 'harriet' as expected"); 308*0Sstevel@tonic-gate System.out.println(new Integer(p.length).toString()+" entries."); 309*0Sstevel@tonic-gate System.out.println("Principal list done\n"); 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gate System.out.println("*** set comments"); 313*0Sstevel@tonic-gate pr = new Principal(k, d); 314*0Sstevel@tonic-gate try { 315*0Sstevel@tonic-gate b = k.loadPrincipal("harriet", pr); 316*0Sstevel@tonic-gate } catch (Exception e) { 317*0Sstevel@tonic-gate b = false; 318*0Sstevel@tonic-gate System.out.println("loadPrincipal exception "+e); 319*0Sstevel@tonic-gate } 320*0Sstevel@tonic-gate if (b) { 321*0Sstevel@tonic-gate pr.setComments("Who knows this user?"); 322*0Sstevel@tonic-gate try { 323*0Sstevel@tonic-gate b = k.savePrincipal(pr); 324*0Sstevel@tonic-gate } catch (Exception e) { 325*0Sstevel@tonic-gate b = false; 326*0Sstevel@tonic-gate System.out.println("savePrincipal exception "+e); 327*0Sstevel@tonic-gate } 328*0Sstevel@tonic-gate if (b) { 329*0Sstevel@tonic-gate try { 330*0Sstevel@tonic-gate b = k.loadPrincipal("harriet", pr); 331*0Sstevel@tonic-gate } catch (Exception e) { 332*0Sstevel@tonic-gate b = false; 333*0Sstevel@tonic-gate System.out.println("loadPrincipal exception "+e); 334*0Sstevel@tonic-gate } 335*0Sstevel@tonic-gate System.out.println("Loaded "+pr.toString()); 336*0Sstevel@tonic-gate System.out.println("Comments are "+pr.Comments+"\n"); 337*0Sstevel@tonic-gate } else 338*0Sstevel@tonic-gate System.out.println("savePrincipal failed"); 339*0Sstevel@tonic-gate } 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gate 342*0Sstevel@tonic-gate System.out.println("*** set password"); 343*0Sstevel@tonic-gate pr = new Principal(k, d); 344*0Sstevel@tonic-gate try { 345*0Sstevel@tonic-gate b = k.loadPrincipal("harriet", pr); 346*0Sstevel@tonic-gate } catch (Exception e) { 347*0Sstevel@tonic-gate b = false; 348*0Sstevel@tonic-gate System.out.println("loadPrincipal exception "+e); 349*0Sstevel@tonic-gate } 350*0Sstevel@tonic-gate if (b) { 351*0Sstevel@tonic-gate pr.setPassword("test234"); 352*0Sstevel@tonic-gate try { 353*0Sstevel@tonic-gate b = k.savePrincipal(pr); 354*0Sstevel@tonic-gate } catch (Exception e) { 355*0Sstevel@tonic-gate b = false; 356*0Sstevel@tonic-gate System.out.println("savePrincipal exception "+e); 357*0Sstevel@tonic-gate } 358*0Sstevel@tonic-gate if (!b) 359*0Sstevel@tonic-gate System.out.println("savePrincipal failed\n"); 360*0Sstevel@tonic-gate else 361*0Sstevel@tonic-gate System.out.println("savePrincipal succeeded\n"); 362*0Sstevel@tonic-gate } 363*0Sstevel@tonic-gate 364*0Sstevel@tonic-gate 365*0Sstevel@tonic-gate System.out.println("*** delete principal"); 366*0Sstevel@tonic-gate try { 367*0Sstevel@tonic-gate b = k.deletePrincipal("harriet"); 368*0Sstevel@tonic-gate } catch (Exception e) { 369*0Sstevel@tonic-gate b = false; 370*0Sstevel@tonic-gate System.out.println("deletePrincipal exception "+e); 371*0Sstevel@tonic-gate } 372*0Sstevel@tonic-gate if (!b) 373*0Sstevel@tonic-gate System.out.println("deletePrincipal failed\n"); 374*0Sstevel@tonic-gate else 375*0Sstevel@tonic-gate System.out.println("deletePrincipal succeeded\n"); 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gate System.out.println("*** verify deletion"); 378*0Sstevel@tonic-gate try { 379*0Sstevel@tonic-gate p = k.getPrincipalList(); 380*0Sstevel@tonic-gate System.out.println("Called getPrincipalList()"); 381*0Sstevel@tonic-gate } catch (Exception e) { 382*0Sstevel@tonic-gate p = null; 383*0Sstevel@tonic-gate System.out.println("getPrincipalList exception "+e); 384*0Sstevel@tonic-gate } 385*0Sstevel@tonic-gate for (int i = 0; p != null && i < p.length; i++) 386*0Sstevel@tonic-gate if (p[i].equals("harriet")) 387*0Sstevel@tonic-gate System.out.println("Found 'harriet' - oops!"); 388*0Sstevel@tonic-gate System.out.println(new Integer(p.length).toString()+" entries."); 389*0Sstevel@tonic-gate System.out.println("Principal list done\n"); 390*0Sstevel@tonic-gate 391*0Sstevel@tonic-gate 392*0Sstevel@tonic-gate System.out.println("*** create a principal with comments"); 393*0Sstevel@tonic-gate pr = new Principal("harriet"); 394*0Sstevel@tonic-gate pr.setPassword("test123"); 395*0Sstevel@tonic-gate pr.setComments("Room 1229"); 396*0Sstevel@tonic-gate System.out.println("Built "+pr.toString()); 397*0Sstevel@tonic-gate try { 398*0Sstevel@tonic-gate b = k.createPrincipal(pr); 399*0Sstevel@tonic-gate } catch (Exception e) { 400*0Sstevel@tonic-gate b = false; 401*0Sstevel@tonic-gate System.out.println("createPrincipal exception "+e); 402*0Sstevel@tonic-gate } 403*0Sstevel@tonic-gate if (!b) 404*0Sstevel@tonic-gate System.out.println("createPrincipal failed\n"); 405*0Sstevel@tonic-gate else 406*0Sstevel@tonic-gate System.out.println("createPrincipal succeeded\n"); 407*0Sstevel@tonic-gate 408*0Sstevel@tonic-gate System.out.println("*** verify comments"); 409*0Sstevel@tonic-gate try { 410*0Sstevel@tonic-gate b = k.loadPrincipal("harriet", pr); 411*0Sstevel@tonic-gate } catch (Exception e) { 412*0Sstevel@tonic-gate b = false; 413*0Sstevel@tonic-gate System.out.println("loadPrincipal exception "+e); 414*0Sstevel@tonic-gate } 415*0Sstevel@tonic-gate if (b) { 416*0Sstevel@tonic-gate System.out.println("Loaded "+pr.toString()); 417*0Sstevel@tonic-gate System.out.println("Comments "+pr.Comments+"\n"); 418*0Sstevel@tonic-gate try { 419*0Sstevel@tonic-gate b = k.deletePrincipal("harriet"); 420*0Sstevel@tonic-gate } catch (Exception e) { 421*0Sstevel@tonic-gate b = false; 422*0Sstevel@tonic-gate System.out.println("deletePrincipal exception "+e); 423*0Sstevel@tonic-gate } 424*0Sstevel@tonic-gate } 425*0Sstevel@tonic-gate 426*0Sstevel@tonic-gate System.out.println("All tests completed.\n"); 427*0Sstevel@tonic-gate k.sessionExit(); 428*0Sstevel@tonic-gate } 429*0Sstevel@tonic-gate } 430