java.lang.Object
com.orientechnologies.orient.core.record.ORecordAbstract
com.orientechnologies.orient.core.record.impl.ODocument
org.gcube.informationsystem.resourceregistry.persistence.orientdb.utils.EncryptedOrient
All Implemented Interfaces:
com.orientechnologies.orient.core.db.record.ODetachable, com.orientechnologies.orient.core.db.record.OIdentifiable, com.orientechnologies.orient.core.db.record.ORecordElement, com.orientechnologies.orient.core.record.OElement, com.orientechnologies.orient.core.record.ORecord, com.orientechnologies.orient.core.record.ORecordSchemaAware, com.orientechnologies.orient.core.serialization.OSerializableStream, Externalizable, Serializable, Comparable<com.orientechnologies.orient.core.db.record.OIdentifiable>, Iterable<Map.Entry<String,Object>>, Comparator<com.orientechnologies.orient.core.db.record.OIdentifiable>, org.gcube.informationsystem.base.reference.Element, org.gcube.informationsystem.base.reference.properties.PropertyElement, org.gcube.informationsystem.base.reference.SchemaMixedElement, org.gcube.informationsystem.model.reference.ModelElement, org.gcube.informationsystem.model.reference.properties.Encrypted, org.gcube.informationsystem.model.reference.properties.Property

public class EncryptedOrient extends com.orientechnologies.orient.core.record.impl.ODocument implements org.gcube.informationsystem.model.reference.properties.Encrypted
The EncryptedOrient class extends ODocument and implements the Encrypted interface. It provides functionality for handling encrypted values within an OrientDB document.

This class includes methods for setting and getting encrypted and decrypted values, as well as methods for encrypting values using database and context keys.

Fields:

  • NAME - The name of the encrypted document type.
  • VALUE - The field name for the encrypted value.
  • decryptedValue - The decrypted value of the document.
  • dbEncryptedValue - The value encrypted with the database key.
  • contextEncryptedValue - The value encrypted with the context key.

Constructors:

  • EncryptedOrient() - Default constructor initializing the document with the encrypted type name.
  • EncryptedOrient(String iClassName) - Protected constructor initializing the document with a specified class name.

Methods:

  • getTypeName() - Returns the type name of the class.
  • getSupertypes() - Returns a list of super types for the class.
  • getExpectedtype() - Returns the expected type (currently returns null).
  • getEncryptedValue() - Returns the encrypted value from the document field.
  • setEncryptedValue(String encryptedValue) - Sets the encrypted value in the document field.
  • getDecryptedValue() - Returns the decrypted value.
  • getDbEncryptedValue() - Returns the value encrypted with the database key.
  • getContextEncryptedValue() - Returns the value encrypted with the context key.
  • setDecryptedValue(String decryptedValue, boolean setEncryptedForContext) - Sets the decrypted value and encrypts it using both database and context keys. Optionally sets the encrypted value for the context.
  • getAdditionalProperties() - Returns additional properties (currently returns null).
  • setAdditionalProperties(Map<String, Object> additionalProperties) - Sets additional properties (currently does nothing).
  • getAdditionalProperty(String key) - Returns an additional property by key (currently returns null).
  • setAdditionalProperty(String key, Object value) - Sets an additional property by key (currently does nothing).
  • getValue() - Returns the encrypted value.
  • setValue(String value) - Sets the encrypted value.
  • toJSON(String iFormat) - Converts the document to a JSON string and replaces the type using OrientDBUtility.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.record.ORecordElement

    com.orientechnologies.orient.core.db.record.ORecordElement.STATUS
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The value encrypted using the context-specific key.
    protected String
    The value encrypted using the database symmetric key.
    protected String
    The decrypted plain text value.
    static final String
    The schema type name of the encrypted property vertex.
    static final String
    The database field property name containing the encrypted value string.

    Fields inherited from class com.orientechnologies.orient.core.record.impl.ODocument

    _allowChainedAccess, _fields, _fieldSize, _lazyLoad, _ordered, _owners, _schema, _trackingChanges, EMPTY_STRINGS, RECORD_TYPE

    Fields inherited from class com.orientechnologies.orient.core.record.ORecordAbstract

    _contentChanged, _dirty, _dirtyManager, _listeners, _recordFormat, _recordId, _recordVersion, _size, _source, _status

    Fields inherited from interface org.gcube.informationsystem.base.reference.Element

    DATETIME_PATTERN, REDACTED, TYPE_PROPERTY, UNKNOWN_USER

    Fields inherited from interface org.gcube.informationsystem.model.reference.ModelElement

    EXPECTED_TYPE_PROPERTY, SUPERTYPES_PROPERTY
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Default constructor initializing the document with the encrypted type class name.
    protected
    EncryptedOrient(String iClassName)
    Protected constructor initializing the document with a specified class name.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    Returns the value encrypted using the context-specific key.
    Returns the value encrypted using the database symmetric key.
    Returns the decrypted plain text value.
    Returns the encrypted value from the document.
     
     
     
     
    void
    setAdditionalProperties(Map<String,Object> additionalProperties)
     
    void
     
    void
    setDecryptedValue(String decryptedValue, boolean setEncryptedForContext)
    Sets the decrypted value and encrypts it using both the database key and the context key.
    void
    setEncryptedValue(String encryptedValue)
    Sets the encrypted value in the document.
    void
     
    toJSON(String iFormat)
     

    Methods inherited from class com.orientechnologies.orient.core.record.impl.ODocument

    addOwner, asEdge, asVertex, autoConvertFieldsToClass, autoConvertValues, checkClass, checkFieldName, checkForFields, clear, clearSource, clearTrackData, containsField, convertAllMultiValuesToTrackedVersions, copy, copyTo, deserializeFields, detach, equals, eval, eval, field, field, field, field, field, fieldNames, fields, fields, fields, fieldType, fieldValues, fill, fill, fillClassIfNeed, fromJSON, fromJSON, fromJSON, fromJSON, fromMap, fromStream, fromString, getClassName, getCollectionTimeLine, getDirtyFields, getGlobalPropertyById, getImmutableSchemaClass, getImmutableSchemaClass, getOrCreate, getOriginalValue, getOwner, getOwners, getProperty, getPropertyNames, getRawEntries, getRawProperty, getRecordType, getSchemaClass, getSchemaType, hashCode, hasOwners, hasSameContentOf, internalReset, isAllowChainedAccess, isEdge, isEmbedded, isEmpty, isLazyLoad, isOrdered, isTrackingChanges, isVertex, iterator, load, load, load, merge, merge, mergeMap, placeholder, rawContainsField, rawField, rawField, readExternal, reload, removeField, removeOwner, removeProperty, reset, save, save, save, setAllowChainedAccess, setClass, setClassName, setClassNameIfExists, setDirty, setDirtyNoChanged, setFieldType, setLazyLoad, setOrdered, setProperty, setProperty, setTrackingChanges, setup, toMap, toStream, toStream, toString, toString, track, undo, undo, unload, unTrack, validate, validateEmbedded, validateField, validateLink, validateLinkCollection, validateType, writeExternal

    Methods inherited from class com.orientechnologies.orient.core.record.ORecordAbstract

    addIdentityChangeListener, addListener, checkForLoading, compare, compareTo, delete, flatCopy, getDatabase, getDatabaseIfDefined, getDatabaseIfDefinedInternal, getDatabaseInternal, getDirtyManager, getIdentity, getInternalStatus, getRecord, getSize, getVersion, invokeListenerEvent, isContentChanged, isDirty, isLocked, load, lock, lockingStrategy, onAfterIdentityChanged, onBeforeIdentityChanged, reload, reload, reload, removeIdentityChangeListener, removeListener, save, setContentChanged, setDirtyManager, setIdentity, setIdentity, setInternalStatus, setVersion, toJSON, toJSON, toJSON, unlock, unsetDirty

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface com.orientechnologies.orient.core.db.record.OIdentifiable

    getRecord, isLocked, lock, lockingStrategy, unlock

    Methods inherited from interface com.orientechnologies.orient.core.record.ORecord

    delete, getDatabase, getIdentity, getSize, getVersion, isDirty, load, reload, reload, save, toJSON

    Methods inherited from interface com.orientechnologies.orient.core.db.record.ORecordElement

    getInternalStatus, setInternalStatus
  • Field Details

    • NAME

      public static final String NAME
      The schema type name of the encrypted property vertex.
      See Also:
    • VALUE

      public static final String VALUE
      The database field property name containing the encrypted value string.
      See Also:
    • decryptedValue

      protected String decryptedValue
      The decrypted plain text value.
    • dbEncryptedValue

      protected String dbEncryptedValue
      The value encrypted using the database symmetric key.
    • contextEncryptedValue

      protected String contextEncryptedValue
      The value encrypted using the context-specific key.
  • Constructor Details

    • EncryptedOrient

      public EncryptedOrient()
      Default constructor initializing the document with the encrypted type class name.
    • EncryptedOrient

      protected EncryptedOrient(String iClassName)
      Protected constructor initializing the document with a specified class name.
      Parameters:
      iClassName - the OrientDB class name
  • Method Details

    • getTypeName

      public String getTypeName()
      Specified by:
      getTypeName in interface org.gcube.informationsystem.base.reference.Element
    • getSupertypes

      public List<String> getSupertypes()
      Specified by:
      getSupertypes in interface org.gcube.informationsystem.model.reference.ModelElement
    • getExpectedtype

      public String getExpectedtype()
      Specified by:
      getExpectedtype in interface org.gcube.informationsystem.model.reference.ModelElement
    • getEncryptedValue

      public String getEncryptedValue()
      Returns the encrypted value from the document.
      Returns:
      the encrypted value string
    • setEncryptedValue

      public void setEncryptedValue(String encryptedValue)
      Sets the encrypted value in the document.
      Parameters:
      encryptedValue - the encrypted value string to set
    • getDecryptedValue

      public String getDecryptedValue()
      Returns the decrypted plain text value.
      Returns:
      the decrypted plain text string
    • getDbEncryptedValue

      public String getDbEncryptedValue()
      Returns the value encrypted using the database symmetric key.
      Returns:
      the database-encrypted value string
    • getContextEncryptedValue

      public String getContextEncryptedValue()
      Returns the value encrypted using the context-specific key.
      Returns:
      the context-encrypted value string
    • setDecryptedValue

      public void setDecryptedValue(String decryptedValue, boolean setEncryptedForContext) throws Exception
      Sets the decrypted value and encrypts it using both the database key and the context key. Depending on the value of the setEncryptedForContext parameter, it sets the encrypted value to either the context-encrypted value or the database-encrypted value.
      Parameters:
      decryptedValue - the decrypted value to be set and encrypted
      setEncryptedForContext - if true, sets the encrypted value to the context-encrypted value; otherwise, sets it to the database-encrypted value
      Throws:
      Exception - if an error occurs during encryption
    • getAdditionalProperties

      public Map<String,Object> getAdditionalProperties()
      Specified by:
      getAdditionalProperties in interface org.gcube.informationsystem.model.reference.properties.Property
      Specified by:
      getAdditionalProperties in interface org.gcube.informationsystem.base.reference.SchemaMixedElement
    • setAdditionalProperties

      public void setAdditionalProperties(Map<String,Object> additionalProperties)
      Specified by:
      setAdditionalProperties in interface org.gcube.informationsystem.model.reference.properties.Property
      Specified by:
      setAdditionalProperties in interface org.gcube.informationsystem.base.reference.SchemaMixedElement
    • getAdditionalProperty

      public Object getAdditionalProperty(String key)
      Specified by:
      getAdditionalProperty in interface org.gcube.informationsystem.model.reference.properties.Property
      Specified by:
      getAdditionalProperty in interface org.gcube.informationsystem.base.reference.SchemaMixedElement
    • setAdditionalProperty

      public void setAdditionalProperty(String key, Object value)
      Specified by:
      setAdditionalProperty in interface org.gcube.informationsystem.model.reference.properties.Property
      Specified by:
      setAdditionalProperty in interface org.gcube.informationsystem.base.reference.SchemaMixedElement
    • getValue

      public String getValue()
      Specified by:
      getValue in interface org.gcube.informationsystem.model.reference.properties.Encrypted
    • setValue

      public void setValue(String value)
      Specified by:
      setValue in interface org.gcube.informationsystem.model.reference.properties.Encrypted
    • toJSON

      public String toJSON(String iFormat)
      Specified by:
      toJSON in interface com.orientechnologies.orient.core.record.ORecord
      Overrides:
      toJSON in class com.orientechnologies.orient.core.record.ORecordAbstract