Search in sources :

Example 6 with DataEncryptionContext

use of io.apiman.common.util.crypt.DataEncryptionContext in project apiman by apiman.

the class PolicyBean method encryptData.

@PrePersist
@PreUpdate
protected void encryptData() {
    // Encrypt the endpoint properties.
    EntityType entityType = EntityType.Api;
    if (type == PolicyType.Client) {
        entityType = EntityType.ClientApp;
    } else if (type == PolicyType.Plan) {
        entityType = EntityType.Plan;
    }
    DataEncryptionContext ctx = new DataEncryptionContext(organizationId, entityId, entityVersion, entityType);
    configuration = CurrentDataEncrypter.instance.encrypt(configuration, ctx);
}
Also used : EntityType(io.apiman.common.util.crypt.DataEncryptionContext.EntityType) DataEncryptionContext(io.apiman.common.util.crypt.DataEncryptionContext) PrePersist(javax.persistence.PrePersist) PreUpdate(javax.persistence.PreUpdate)

Example 7 with DataEncryptionContext

use of io.apiman.common.util.crypt.DataEncryptionContext in project apiman by apiman.

the class PolicyBean method decryptData.

@PostPersist
@PostUpdate
@PostLoad
protected void decryptData() {
    // Decrypt the endpoint properties.
    EntityType entityType = EntityType.Api;
    if (type == PolicyType.Client) {
        entityType = EntityType.ClientApp;
    } else if (type == PolicyType.Plan) {
        entityType = EntityType.Plan;
    }
    DataEncryptionContext ctx = new DataEncryptionContext(organizationId, entityId, entityVersion, entityType);
    configuration = CurrentDataEncrypter.instance.decrypt(configuration, ctx);
}
Also used : EntityType(io.apiman.common.util.crypt.DataEncryptionContext.EntityType) DataEncryptionContext(io.apiman.common.util.crypt.DataEncryptionContext) PostLoad(javax.persistence.PostLoad) PostUpdate(javax.persistence.PostUpdate) PostPersist(javax.persistence.PostPersist)

Example 8 with DataEncryptionContext

use of io.apiman.common.util.crypt.DataEncryptionContext in project apiman by apiman.

the class SecureRegistryWrapper method encryptPolicies.

/**
 * @param entityType
 * @param entityVersion
 * @param entityId
 * @param orgId
 * @param entityType
 * @param policies
 */
protected void encryptPolicies(String orgId, String entityId, String entityVersion, EntityType entityType, List<Policy> policies) {
    if (policies != null) {
        DataEncryptionContext ctx = new DataEncryptionContext(orgId, entityId, entityVersion, entityType);
        for (Policy policy : policies) {
            String jsonConfig = policy.getPolicyJsonConfig();
            policy.setPolicyJsonConfig(encrypter.encrypt(jsonConfig, ctx));
        }
    }
}
Also used : Policy(io.apiman.gateway.engine.beans.Policy) DataEncryptionContext(io.apiman.common.util.crypt.DataEncryptionContext)

Example 9 with DataEncryptionContext

use of io.apiman.common.util.crypt.DataEncryptionContext in project apiman by apiman.

the class ApiService method decryptEndpointProperties.

/**
 * Decrypt the endpoint properties
 */
public void decryptEndpointProperties(ApiVersionBean versionBean) {
    Map<String, String> endpointProperties = versionBean.getEndpointProperties();
    if (endpointProperties != null) {
        for (Entry<String, String> entry : endpointProperties.entrySet()) {
            DataEncryptionContext ctx = new DataEncryptionContext(versionBean.getApi().getOrganization().getId(), versionBean.getApi().getId(), versionBean.getVersion(), EntityType.Api);
            entry.setValue(encrypter.decrypt(entry.getValue(), ctx));
        }
    }
}
Also used : DataEncryptionContext(io.apiman.common.util.crypt.DataEncryptionContext)

Example 10 with DataEncryptionContext

use of io.apiman.common.util.crypt.DataEncryptionContext in project apiman by apiman.

the class ApiService method encryptEndpointProperties.

/**
 * Encrypt the endpoint properties
 */
private void encryptEndpointProperties(ApiVersionBean versionBean) {
    Map<String, String> endpointProperties = versionBean.getEndpointProperties();
    if (endpointProperties != null) {
        for (Entry<String, String> entry : endpointProperties.entrySet()) {
            DataEncryptionContext ctx = new DataEncryptionContext(versionBean.getApi().getOrganization().getId(), versionBean.getApi().getId(), versionBean.getVersion(), EntityType.Api);
            entry.setValue(encrypter.encrypt(entry.getValue(), ctx));
        }
    }
}
Also used : DataEncryptionContext(io.apiman.common.util.crypt.DataEncryptionContext)

Aggregations

DataEncryptionContext (io.apiman.common.util.crypt.DataEncryptionContext)11 EntityType (io.apiman.common.util.crypt.DataEncryptionContext.EntityType)3 Policy (io.apiman.gateway.engine.beans.Policy)2 RestGatewayConfigBean (io.apiman.manager.api.beans.gateways.RestGatewayConfigBean)2 StorageException (io.apiman.manager.api.core.exceptions.StorageException)2 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)2 AbstractRestException (io.apiman.manager.api.rest.exceptions.AbstractRestException)2 GatewayAlreadyExistsException (io.apiman.manager.api.rest.exceptions.GatewayAlreadyExistsException)2 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)2 NotAuthorizedException (io.apiman.manager.api.rest.exceptions.NotAuthorizedException)2 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)2 PolicyDefinitionBean (io.apiman.manager.api.beans.policies.PolicyDefinitionBean)1 PolicyDefinitionTemplateBean (io.apiman.manager.api.beans.policies.PolicyDefinitionTemplateBean)1 PostLoad (javax.persistence.PostLoad)1 PostPersist (javax.persistence.PostPersist)1 PostUpdate (javax.persistence.PostUpdate)1 PrePersist (javax.persistence.PrePersist)1 PreUpdate (javax.persistence.PreUpdate)1 CompiledTemplate (org.mvel2.templates.CompiledTemplate)1