help: new to java security

guo (guo@osf.org)
Wed, 16 Apr 1997 10:39:00 -0400

Date: Wed, 16 Apr 1997 10:39:00 -0400
From: guo <guo@osf.org>
To: java-security@web2.javasoft.com
Subject: help: new to java security

I cut and paste the Example in "Security in JDK 1.1 Access Control
Abstractions", and try to compile it. I get error

Example.java:13: Identifier expected.
g.setMember(p1);

Please give me some clue.

Thank,
Kathy Guo

P.S.
I am working on NT 4.0, and using jdk 1.1.

Here is the Example.java:
-------------------------------------------
import java.security.acl.*;
import sun.security.acl.*;

public class Example {
Principal p1 = new PrincipalImpl("user1");
Principal p2 = new PrincipalImpl("user2");
Principal owner = new PrincipalImpl("owner");

Permission read = new PermissionImpl("READ");
Permission write = new PermissionImpl("WRITE");

Group g = new GroupImpl("group1");
g.setMember(p1);
g.addMember(p2);

//
// create a new acl with the name "exampleAcl"
//
Acl acl = new AclImpl(owner, "exampleAcl");

//
// Allow group all permissions
//
AclEntry entry1 = new AclEntryImpl(g);
entry1.addPermission(read);
entry1.addPermission(write);
acl.addEntry(owner, entry1);

//
// Take away WRITE permissions for
// user1. All others in groups still have
// WRITE privileges.
//
AclEntry entry2 = new AclEntryImpl(p1);
entry2.addPermission(write);
entry2.setNegativePermissions();
acl.addEntry(owner, entry2);

//
// This enumeration is an enumeration of
// Permission interfaces. It should return
// only "READ" permission.
Enumeration e1 = acl.getPermissions(p1);

//
// This enumeration should have "READ" and"WRITE"
// permissions.
Enumeration e2 = acl.getPermissions(p2);

// This should return false.
boolean b1 = acl.checkPermission(p1, write);

// This should all return true;
boolean b2 = acl.checkPermission(p1, read);
boolean b3 = acl.checkPermission(p2, read);
boolean b4 = acl.checkPermission(p2, write);
}