Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.PasswordRecord


    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet s = wb.createSheet();
    s.protectSheet("abcdefghij");
    Sheet sheet = s.getSheet();
    ProtectRecord protect = sheet.getProtect();
    PasswordRecord pass = sheet.getPassword();
    assertTrue("protection should be on",protect.getProtect());
    assertTrue("object protection should be on",sheet.isProtected()[1]);
    assertTrue("scenario protection should be on",sheet.isProtected()[2]);
    assertEquals("well known value for top secret hash should be "+Integer.toHexString(expected).substring(4),expected,pass.getPassword());
  }
View Full Code Here


    /**
     * @return a new Password record with password set to 0x0000 (no password).
     */
    private static PasswordRecord createPassword() {
        return new PasswordRecord(0x0000); // no password by default!
    }
View Full Code Here

    /**
     * @return a new Password record with password set to 0x0000 (no password).
     */
    private static PasswordRecord createPassword() {
        return new PasswordRecord(0x0000); // no password by default!
    }
View Full Code Here

    /**
     * creates a Password record with password set to 0x0000.
     */
    private static PasswordRecord createPassword() {
        return new PasswordRecord(0x0000);
    }
View Full Code Here

     * @param scenarios are protected
     */
    public void protectSheet( String password, boolean objects, boolean scenarios ) {
        int protIdx = -1;
        ProtectRecord prec = getProtect();
        PasswordRecord pass = getPassword();
        prec.setProtect(true);
        pass.setPassword(PasswordRecord.hashPassword(password));
        if((objprotect == null && objects) || (scenprotect != null && scenarios)) {
            protIdx = _records.indexOf( protect );
        }
        if(objprotect == null && objects) {
            ObjectProtectRecord rec = createObjectProtect();
View Full Code Here

    public void unprotectSheet( boolean sheet, boolean objects, boolean scenarios ) {

        if (!sheet) {
           ProtectRecord prec = getProtect();
           prec.setProtect(sheet);
           PasswordRecord pass = getPassword();
           pass.setPassword((short)00);
        }
        if(objprotect != null && !objects) {
            objprotect.setProtect(false);
        }
        if(scenprotect != null && !scenarios) {
View Full Code Here

    /**
     * @return a new Password record with password set to 0x0000 (no password).
     */
    private static PasswordRecord createPassword() {
        return new PasswordRecord(0x0000); // no password by default!
    }
View Full Code Here

    /**
     * @return a new Password record with password set to 0x0000 (no password).
     */
    private static PasswordRecord createPassword() {
        return new PasswordRecord(0x0000); // no password by default!
    }
View Full Code Here

  HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet s = wb.createSheet();
    s.protectSheet("abcdefghij");
    Sheet sheet = s.getSheet();
  ProtectRecord protect = sheet.getProtect();
  PasswordRecord pass = sheet.getPassword();
    assertTrue("protection should be on",protect.getProtect());
    assertTrue("object protection should be on",sheet.isProtected()[1]);
    assertTrue("scenario protection should be on",sheet.isProtected()[2]);
    assertEquals("well known value for top secret hash should be "+Integer.toHexString(expected).substring(4),expected,pass.getPassword());
  }
View Full Code Here

    /**
     * creates a Password record with password set to 0x0000.
     */
    private static PasswordRecord createPassword() {
        return new PasswordRecord(0x0000);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.PasswordRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.