public COSCompositeObject popContextObject() {
   COSCompositeObject contextObject = contextStack[stackPtr--];
   // enable encryption when no longer in encryption dict of file id's
   if (contextObject == currentCosEncryption || contextObject == currentCosIDs) {
     enabled = true;
   }
   if (contextObject instanceof COSStream) {
     COSDictionary dict = contextObject.asStream().getDict();
     if (dict != null
         && dict.get(STStreamXRefSection.DK_Type).equals(STStreamXRefSection.CN_Type_XRef)) {
       // /XRef streams are not encrypted
       enabled = true;
     }
   }
   return contextObject;
 }
 public void pushContextObject(COSCompositeObject contextObject) {
   stackPtr++;
   if (stackPtr >= contextStack.length) {
     COSCompositeObject[] tempStack = new COSCompositeObject[contextStack.length + 5];
     System.arraycopy(contextStack, 0, tempStack, 0, contextStack.length);
     contextStack = tempStack;
   }
   contextStack[stackPtr] = contextObject;
   // do not encrypt within encryption dict and file id's
   if (contextObject == currentCosEncryption || contextObject == currentCosIDs) {
     enabled = false;
   }
   if (contextObject instanceof COSStream) {
     COSDictionary dict = contextObject.asStream().getDict();
     if (dict != null
         && dict.get(STStreamXRefSection.DK_Type).equals(STStreamXRefSection.CN_Type_XRef)) {
       // /XRef streams are not encrypted
       enabled = false;
     }
   }
 }