Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

PasswordRev4Record.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hssf.record;
  16. import java.util.Map;
  17. import java.util.function.Supplier;
  18. import org.apache.poi.util.GenericRecordUtil;
  19. import org.apache.poi.util.LittleEndianOutput;
  20. /**
  21. * Protection Revision 4 password Record (0x01BC)<p>
  22. * Stores the (2 byte??!!) encrypted password for a shared workbook
  23. */
  24. public final class PasswordRev4Record extends StandardRecord {
  25. public static final short sid = 0x01BC;
  26. private int field_1_password;
  27. public PasswordRev4Record(int pw) {
  28. field_1_password = pw;
  29. }
  30. public PasswordRev4Record(PasswordRev4Record other) {
  31. super(other);
  32. field_1_password = other.field_1_password;
  33. }
  34. public PasswordRev4Record(RecordInputStream in) {
  35. field_1_password = in.readShort();
  36. }
  37. /**
  38. * set the password
  39. *
  40. * @param pw representing the password
  41. */
  42. public void setPassword(short pw) {
  43. field_1_password = pw;
  44. }
  45. public void serialize(LittleEndianOutput out) {
  46. out.writeShort(field_1_password);
  47. }
  48. protected int getDataSize() {
  49. return 2;
  50. }
  51. public short getSid() {
  52. return sid;
  53. }
  54. @Override
  55. public PasswordRev4Record copy() {
  56. return new PasswordRev4Record(this);
  57. }
  58. @Override
  59. public HSSFRecordTypes getGenericRecordType() {
  60. return HSSFRecordTypes.PASSWORD_REV_4;
  61. }
  62. @Override
  63. public Map<String, Supplier<?>> getGenericProperties() {
  64. return GenericRecordUtil.getGenericProperties("password", () -> field_1_password);
  65. }
  66. }