FileDocCategorySizeDatePackage
PasswordSecurityManager.javaAPI DocExample1371Tue Dec 12 18:57:44 GMT 2000None

PasswordSecurityManager

public class PasswordSecurityManager extends SecurityManager

Fields Summary
private String
password
Constructors Summary
public PasswordSecurityManager(String password)

        super();
        this.password = password;
    
Methods Summary
private booleanaccessOK()

        int c;
        DataInputStream in = new DataInputStream(System.in);
        String response;

        System.out.println("What's the secret password?");
        try {
            response = in.readLine();
            if (response.equals(password))
                return true;
            else
                return false;
        } catch (IOException e) {
            return false;
        }
    
public voidcheckRead(java.io.FileDescriptor filedescriptor)

        if (!accessOK())
            throw new SecurityException("Not a Chance!");
    
public voidcheckRead(java.lang.String filename)

        if (!accessOK())
            throw new SecurityException("No Way!");
    
public voidcheckRead(java.lang.String filename, java.lang.Object executionContext)

        if (!accessOK())
            throw new SecurityException("Forget It!");
    
public voidcheckWrite(java.io.FileDescriptor filedescriptor)

        if (!accessOK())
            throw new SecurityException("Not!");
    
public voidcheckWrite(java.lang.String filename)

        if (!accessOK())
            throw new SecurityException("Not Even!");