code: public boolean setProtection(int level, String pwd) {
      	boolean result = false;
      	if(this.protectionHash == null) {
      		if(!setProtectionLevel(level)) {
      			result = false;
      		}
      		else
      		{
  	    		protectionHash = RtfProtection.generateHash(pwd);
  	    		result = true;
      		}
      	}
      	else {
  	    	if(this.protectionHash.equals(RtfProtection.generateHash(pwd))) {
  	    		if(!setProtectionLevel(level)) {
  	    			result = false;
  	    		}
  	    		else
  	    		{
  		    		protectionHash = RtfProtection.generateHash(pwd);
  		    		result = true;
  	    		}
  	    	}
      	}
      	return result;
      }
docs: Author: Howard Shank (hgshank@yahoo.com)
  @param level Document protecton level
  @param pwd Document password - clear text
  @since 2.1.1