from kmip.core.factories import attributes from kmip.core import enums from kmip.demos import utils from kmip.pie import client # NOTE: This demo script shows how to set the Sensitive attribute on # the user-specified object. The server must support KMIP 2.0, since # the SetAttribute operation is KMIP 2.0+ only and the Sensitive # attribute is KMIP 1.4+ only. Otherwise, the client call to # set_attribute will fail. if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) parser = utils.build_cli_parser(enums.Operation.SET_ATTRIBUTE) opts, args = parser.parse_args(sys.argv[1:]) if opts.uuid is None: logger.error("No UUID provided, existing early from demo.") sys.exit() factory = attributes.AttributeFactory() with client.ProxyKmipClient(config=opts.config, config_file=opts.config_file, kmip_version=enums.KMIPVersion.KMIP_2_0) as c: try: object_id = c.set_attribute(unique_identifier=opts.uuid, attribute_name="Sensitive", attribute_value=True)
# INFO - Successfully encrypted the message. # INFO - Cipher text: b'49cfacbb62659180c20dfbf9f7553488b3ea9ebeecd70ce2e5c4d4 # ece6def0d4' # INFO - No autogenerated IV expected, since one was provided. # INFO - Autogenerated IV: None # $ python kmip/demos/pie/decrypt.py -c test -i 470 -m b'49cfacbb62659180c20df # bf9f7553488b3ea9ebeecd70ce2e5c4d4ece6def0d4' # INFO - Successfully decrypted the message. # INFO - Plain text: 'My test message.' if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.DECRYPT) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uuid = opts.uuid message = opts.message if not message.startswith("b"): raise ValueError("The message should be a byte string (e.g., b'...').") else: message = binascii.unhexlify(message[1:]) # Build the client and connect to the server with client.ProxyKmipClient(config=config) as client: # Decrypt the cipher text with the encryption key. try: plain_text = client.decrypt(
# under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client from kmip.pie import objects if __name__ == "__main__": logger = utils.build_console_logger(logging.INFO) parser = utils.build_cli_parser() opts, args = parser.parse_args(sys.argv[1:]) config = opts.config algorithm = enums.CryptographicAlgorithm.RSA length = 2048 value = ( b"\x30\x82\x01\x0A\x02\x82\x01\x01\x00\xAB\x7F\x16\x1C\x00\x42\x49" b"\x6C\xCD\x6C\x6D\x4D\xAD\xB9\x19\x97\x34\x35\x35\x77\x76\x00\x3A" b"\xCF\x54\xB7\xAF\x1E\x44\x0A\xFB\x80\xB6\x4A\x87\x55\xF8\x00\x2C" b"\xFE\xBA\x6B\x18\x45\x40\xA2\xD6\x60\x86\xD7\x46\x48\x34\x6D\x75" b"\xB8\xD7\x18\x12\xB2\x05\x38\x7C\x0F\x65\x83\xBC\x4D\x7D\xC7\xEC" b"\x11\x4F\x3B\x17\x6B\x79\x57\xC4\x22\xE7\xD0\x3F\xC6\x26\x7F\xA2" b"\xA6\xF8\x9B\x9B\xEE\x9E\x60\xA1\xD7\xC2\xD8\x33\xE5\xA5\xF4\xBB" b"\x0B\x14\x34\xF4\xE7\x95\xA4\x11\x00\xF8\xAA\x21\x49\x00\xDF\x8B"
# License for the specific language governing permissions and limitations # under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client from kmip.pie import objects if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) parser = utils.build_cli_parser() opts, args = parser.parse_args(sys.argv[1:]) config = opts.config algorithm = enums.CryptographicAlgorithm.RSA length = 2048 value = ( b'\x30\x82\x01\x0A\x02\x82\x01\x01\x00\xAB\x7F\x16\x1C\x00\x42\x49' b'\x6C\xCD\x6C\x6D\x4D\xAD\xB9\x19\x97\x34\x35\x35\x77\x76\x00\x3A' b'\xCF\x54\xB7\xAF\x1E\x44\x0A\xFB\x80\xB6\x4A\x87\x55\xF8\x00\x2C' b'\xFE\xBA\x6B\x18\x45\x40\xA2\xD6\x60\x86\xD7\x46\x48\x34\x6D\x75' b'\xB8\xD7\x18\x12\xB2\x05\x38\x7C\x0F\x65\x83\xBC\x4D\x7D\xC7\xEC' b'\x11\x4F\x3B\x17\x6B\x79\x57\xC4\x22\xE7\xD0\x3F\xC6\x26\x7F\xA2' b'\xA6\xF8\x9B\x9B\xEE\x9E\x60\xA1\xD7\xC2\xD8\x33\xE5\xA5\xF4\xBB' b'\x0B\x14\x34\xF4\xE7\x95\xA4\x11\x00\xF8\xAA\x21\x49\x00\xDF\x8B'
# License for the specific language governing permissions and limitations # under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == "__main__": logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.GET) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uid = opts.uuid # Exit early if the UUID is not specified if uid is None: logger.error("No UUID provided, exiting early from demo") sys.exit() # Build the client and connect to the server with client.ProxyKmipClient(config=config) as client: try: secret = client.get(uid) logger.info("Successfully retrieved secret with ID: {0}".format(uid))
from kmip.core.factories.attributes import AttributeFactory from kmip.core.factories.credentials import CredentialFactory from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import os import sys if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(Operation.DESTROY) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config uuid = opts.uuid # Exit early if the UUID is not specified if uuid is None: logging.debug('No UUID provided, exiting early from demo') sys.exit() # Build and setup logging and needed factories f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'logconfig.ini')
# License for the specific language governing permissions and limitations # under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.DERIVE_KEY) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config # Build the client and connect to the server with client.ProxyKmipClient(config=config) as client: # Create keys to use for derivation try: key_id = client.create( enums.CryptographicAlgorithm.AES, 128, cryptographic_usage_mask=[ enums.CryptographicUsageMask.DERIVE_KEY ] ) logger.info("Successfully created a new derivation key.")
import calendar import logging import sys import time from kmip.core import enums from kmip.core.factories.attributes import AttributeFactory from kmip.core.factories.credentials import CredentialFactory from kmip.demos import utils from kmip.services import kmip_client if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.LOCATE) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config name = opts.name initial_dates = opts.initial_dates state = opts.state object_type = opts.object_type cryptographic_algorithm = opts.cryptographic_algorithm cryptographic_length = opts.cryptographic_length unique_identifier = opts.unique_identifier operation_policy_name = opts.operation_policy_name attribute_factory = AttributeFactory()
# License for the specific language governing permissions and limitations # under the License. import logging import sys import time from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.REVOKE) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uid = opts.uuid # Exit early if the UUID is not specified if uid is None: logger.error('No UUID provided, exiting early from demo') sys.exit() # Build the client and connect to the server with client.ProxyKmipClient(config=config, config_file=opts.config_file) as client: try: client.revoke(enums.RevocationReasonCode.KEY_COMPROMISE,
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.DESTROY) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uid = opts.uuid # Exit early if the UUID is not specified if uid is None: logger.error('No UUID provided, exiting early from demo') sys.exit() # Build the client and connect to the server with client.ProxyKmipClient(config=config) as client: try: client.destroy(uid) logger.info(
from kmip.core.messages.contents import ProtocolVersion from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import sys import re if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.DISCOVER_VERSIONS) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config protocol_versions = list() if opts.protocol_versions is not None: for version in re.split(',| ', opts.protocol_versions): mm = re.split('\.', version) protocol_versions.append(ProtocolVersion(int(mm[0]), int(mm[1]))) # Build the client and connect to the server client = KMIPProxy(config=config) client.open()
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging import os import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.GET_ATTRIBUTE_LIST) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uid = opts.uuid # Exit early if the UUID is not specified if uid is None: logging.debug('No ID provided, exiting early from demo') sys.exit() # Build and setup logging and needed factories f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'logconfig.ini') logging.config.fileConfig(f_log) logger = logging.getLogger(__name__)
# under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client from kmip.pie import objects if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.SIGNATURE_VERIFY) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config # Build the client and connect to the server with client.ProxyKmipClient( config=config, config_file=opts.config_file ) as client: # Create keys to use for derivation try: signing_key_id = client.register( objects.PublicKey( enums.CryptographicAlgorithm.RSA, 1120, (
from kmip.core.enums import Operation from kmip.core.enums import ResultStatus from kmip.core.objects import TemplateAttribute from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import os import sys if __name__ == '__main__': parser = utils.build_cli_parser(Operation.REGISTER) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config object_type = opts.type format_type = opts.format # Exit early if the arguments are not specified object_type = getattr(ObjectType, object_type, None) if object_type is None: logging.error("Invalid object type specified; exiting early from demo") sys.exit() key_format_type = getattr(KeyFormatType, format_type, None)
from kmip.core.messages.contents import ProtocolVersion from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import sys import re if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.DISCOVER_VERSIONS) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config protocol_versions = list() if opts.protocol_versions is not None: for version in re.split(',| ', opts.protocol_versions): mm = re.split('\.', version) protocol_versions.append(ProtocolVersion.create(int(mm[0]), int(mm[1]))) # Build the client and connect to the server client = KMIPProxy(config=config)
# under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.CREATE) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config algorithm = opts.algorithm length = opts.length # Exit early if the arguments are not specified if algorithm is None: logger.error('No algorithm provided, exiting early from demo') sys.exit() if length is None: logger.error("No key length provided, exiting early from demo") sys.exit() algorithm = getattr(enums.CryptographicAlgorithm, algorithm, None)
from kmip.core.factories.credentials import CredentialFactory from kmip.core.misc import KeyFormatType from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import os import sys if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(Operation.GET) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config uuid = opts.uuid format_type = opts.format # Exit early if the UUID is not specified if uuid is None: logging.debug('No UUID provided, exiting early from demo') sys.exit() format_type_enum = None if format_type is not None:
from kmip.core.objects import CommonTemplateAttribute from kmip.core.objects import PrivateKeyTemplateAttribute from kmip.core.objects import PublicKeyTemplateAttribute from kmip.core.objects import Attribute from kmip.services.kmip_client import KMIPProxy import logging import os import sys if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(Operation.CREATE_KEY_PAIR) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config algorithm = opts.algorithm length = opts.length name = opts.name # Exit early if the arguments are not specified if algorithm is None: logging.error('No algorithm provided, exiting early from demo') sys.exit() if length is None: logging.error("No key length provided, exiting early from demo")
from kmip.core.enums import ResultStatus from kmip.core.enums import RevocationReasonCode from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.REVOKE) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uuid = opts.uuid # Exit early if the UUID is not specified if uuid is None: logger.error('No UUID provided, exiting early from demo') sys.exit() # Build the client and connect to the server client = KMIPProxy(config=config) client.open() # Activate the object
from kmip.core.factories.credentials import CredentialFactory from kmip.core.misc import KeyFormatType from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.GET) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config uuid = opts.uuid format_type = opts.format # Exit early if the UUID is not specified if uuid is None: logger.error('No UUID provided, exiting early from demo') sys.exit() format_type_enum = None if format_type is not None:
from kmip.core.attributes import Name from kmip.core.objects import TemplateAttribute from kmip.core.objects import Attribute from kmip.services.kmip_client import KMIPProxy import logging import os import sys if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(Operation.CREATE) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config algorithm = opts.algorithm length = opts.length # Exit early if the arguments are not specified if algorithm is None: logging.debug('No algorithm provided, exiting early from demo') sys.exit() if length is None: logging.debug("No key length provided, exiting early from demo") sys.exit()
# INFO - Successfully activated the encryption key. # INFO - Successfully encrypted the message. # INFO - Cipher text: b'49cfacbb62659180c20dfbf9f7553488b3ea9ebeecd70ce2e5c4d4 # ece6def0d4' # INFO - No autogenerated IV expected, since one was provided. # INFO - Autogenerated IV: None # $ python kmip/demos/pie/decrypt.py -c test -i 470 -m b'49cfacbb62659180c20df # bf9f7553488b3ea9ebeecd70ce2e5c4d4ece6def0d4' # INFO - Successfully decrypted the message. # INFO - Plain text: 'My test message.' if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.DECRYPT) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uuid = opts.uuid message = opts.message if not message.startswith("b"): raise ValueError("The message should be a byte string (e.g., b'...').") else: message = binascii.unhexlify(message[1:]) # Build the client and connect to the server with client.ProxyKmipClient(config=config, config_file=opts.config_file) as client: # Decrypt the cipher text with the encryption key. try:
from kmip.core.attributes import Name from kmip.core.objects import Attribute from kmip.demos import utils from kmip.pie import client import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.LOCATE) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config name = opts.name # Exit early if name is not specified if name is None: logger.error('No name provided, exiting early from demo') sys.exit() # Build name attribute # TODO Push this into the AttributeFactory attribute_name = Attribute.AttributeName('Name') name_value = Name.NameValue(name) name_type = Name.NameType(NameType.UNINTERPRETED_TEXT_STRING)
from kmip.core.objects import CommonTemplateAttribute from kmip.core.objects import PrivateKeyTemplateAttribute from kmip.core.objects import PublicKeyTemplateAttribute from kmip.core.objects import Attribute from kmip.services.kmip_client import KMIPProxy import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.CREATE_KEY_PAIR) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config algorithm = opts.algorithm length = opts.length name = opts.name # Exit early if the arguments are not specified if algorithm is None: logger.error('No algorithm provided, exiting early from demo') sys.exit() if length is None: logger.error("No key length provided, exiting early from demo")
from kmip.core.factories import attributes from kmip.core import enums from kmip.demos import utils from kmip.pie import client # NOTE: This demo script shows how to modify the first Name attribute on # the user-specified object. The object *must* have at least one Name # attribute for attribute modification to work. Otherwise, the client # call to modify_attribute will fail. if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) parser = utils.build_cli_parser(enums.Operation.MODIFY_ATTRIBUTE) opts, args = parser.parse_args(sys.argv[1:]) if opts.uuid is None: logger.error("No UUID provided, existing early from demo.") sys.exit() factory = attributes.AttributeFactory() with client.ProxyKmipClient( config=opts.config, config_file=opts.config_file ) as c: try: object_id, modified_attribute = c.modify_attribute( unique_identifier=opts.uuid,
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.GET_ATTRIBUTE_LIST) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uid = opts.uuid # Exit early if the UUID is not specified if uid is None: logger.error('No ID provided, exiting early from demo') sys.exit() # Build the client and connect to the server with client.ProxyKmipClient(config=config) as client: try: attribute_names = client.get_attribute_list(uid) logger.info("Successfully retrieved {0} attribute names:".format(
from kmip.core.attributes import Name from kmip.core.objects import TemplateAttribute from kmip.core.objects import Attribute from kmip.services.kmip_client import KMIPProxy import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.CREATE) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config algorithm = opts.algorithm length = opts.length # Exit early if the arguments are not specified if algorithm is None: logger.error('No algorithm provided, exiting early from demo') sys.exit() if length is None: logger.error("No key length provided, exiting early from demo") sys.exit()
from kmip.core import enums from kmip.core.enums import Operation from kmip.core.enums import ResultStatus from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.REVOKE) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uuid = opts.uuid # Exit early if the UUID is not specified if uuid is None: logger.error('No UUID provided, exiting early from demo') sys.exit() # Build the client and connect to the server client = KMIPProxy(config=config, config_file=opts.config_file) client.open() # Activate the object
from kmip.core.enums import Operation from kmip.core.enums import ResultStatus from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.ACTIVATE) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uuid = opts.uuid # Exit early if the UUID is not specified if uuid is None: logger.error('No UUID provided, exiting early from demo') sys.exit() # Build the client and connect to the server client = KMIPProxy(config=config, config_file=opts.config_file) client.open() # Activate the object
# under the License. import logging import sys import binascii from kmip.core import enums from kmip.demos import utils from kmip.pie import client if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.MAC) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uid = opts.uuid algorithm = opts.algorithm data = (b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E' b'\x0F') # Exit early if the arguments are not specified if uid is None: logger.error('No UUID provided, exiting early from demo') sys.exit() if algorithm is None: logger.error('No algorithm provided, exiting early from demo')
from kmip.core.enums import Operation from kmip.core.enums import ResultStatus from kmip.core.objects import TemplateAttribute from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import sys if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) parser = utils.build_cli_parser(Operation.REGISTER) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config object_type = opts.type format_type = opts.format # Exit early if the arguments are not specified object_type = getattr(ObjectType, object_type, None) if object_type is None: logger.error("Invalid object type specified; exiting early from demo") sys.exit() key_format_type = getattr(KeyFormatType, format_type, None)
from kmip.core.factories.credentials import CredentialFactory from kmip.core.objects import Attribute from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import os import sys if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(Operation.LOCATE) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config name = opts.name # Exit early if the UUID is not specified if name is None: logging.debug('No name provided, exiting early from demo') sys.exit() # Build and setup logging and needed factories f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'logconfig.ini')
from six.moves import xrange from kmip.core.enums import Operation from kmip.core.enums import QueryFunction as QueryFunctionEnum from kmip.core.enums import ResultStatus from kmip.core.misc import QueryFunction from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(Operation.QUERY) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config # Build and setup logging and needed factories f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'logconfig.ini') logging.config.fileConfig(f_log) logger = logging.getLogger(__name__) # Build query function list. query_functions = list() query_functions.append(
import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client # NOTE: This demo script shows how to delete the first Name attribute from # the user-specified object. The object *must* have at least one Name # attribute for attribute deletion to work. Otherwise, the client # call to delete_attribute will fail. if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) parser = utils.build_cli_parser(enums.Operation.DELETE_ATTRIBUTE) opts, args = parser.parse_args(sys.argv[1:]) if opts.uuid is None: logger.error("No UUID provided, existing early from demo.") sys.exit() with client.ProxyKmipClient(config=opts.config, config_file=opts.config_file) as c: try: object_id, modified_attribute = c.delete_attribute( unique_identifier=opts.uuid, attribute_name="Name", attribute_index=0) logger.info( "Successfully deleted 'Name' attribute from object: {}".format(
from kmip.core.enums import Operation from kmip.core.enums import QueryFunction as QueryFunctionEnum from kmip.core.enums import ResultStatus from kmip.core.misc import QueryFunction from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(Operation.QUERY) opts, args = parser.parse_args(sys.argv[1:]) username = opts.username password = opts.password config = opts.config # Build query function list. query_functions = list() query_functions.append( QueryFunction(QueryFunctionEnum.QUERY_OPERATIONS)) query_functions.append( QueryFunction(QueryFunctionEnum.QUERY_OBJECTS)) query_functions.append( QueryFunction(QueryFunctionEnum.QUERY_SERVER_INFORMATION)) query_functions.append(
from kmip.core.enums import Operation from kmip.core.enums import ResultStatus from kmip.demos import utils from kmip.services.kmip_client import KMIPProxy import logging import os import sys if __name__ == '__main__': # Build and parse arguments parser = utils.build_cli_parser(Operation.ACTIVATE) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config uuid = opts.uuid # Exit early if the UUID is not specified if uuid is None: logging.debug('No UUID provided, exiting early from demo') sys.exit() # Build and setup logging and needed factories f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'logconfig.ini') logging.config.fileConfig(f_log) logger = logging.getLogger(__name__)
# under the License. import logging import sys from kmip.core import enums from kmip.demos import utils from kmip.pie import client from kmip.pie import objects if __name__ == '__main__': logger = utils.build_console_logger(logging.INFO) # Build and parse arguments parser = utils.build_cli_parser(enums.Operation.SIGNATURE_VERIFY) opts, args = parser.parse_args(sys.argv[1:]) config = opts.config # Build the client and connect to the server with client.ProxyKmipClient(config=config) as client: # Create keys to use for derivation try: signing_key_id = client.register( objects.PublicKey( enums.CryptographicAlgorithm.RSA, 1120, ( b'\x30\x81\x89\x02\x81\x81\x00\xac\x13\xd9\xfd\xae\x7b' b'\x73\x35\xb6\x9c\xd9\x85\x67\xe9\x64\x7d\x99\xbf\x37' b'\x3a\x9e\x05\xce\x34\x35\xd6\x64\x65\xf3\x28\xb7\xf7'