com.sap.cloud.sdk.services.blockchain.multichain.model.MultichainPermission Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blockchain Show documentation
Show all versions of blockchain Show documentation
Service integration of blockchain functionality (Beta release, still subject to change - up to discontinuation of module).
/*
* Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
*/
package com.sap.cloud.sdk.services.blockchain.multichain.model;
import org.apache.commons.lang3.StringUtils;
import org.springframework.lang.Nullable;
import com.google.common.annotations.Beta;
/**
* Permissions for streams and global access
*/
@Beta
public class MultichainPermission
{
/**
* Different types of permissions, which are allowed in service
*/
public enum MultichainPermissionType
{
/**
* Only allowed to connect to the network. For information see
* https://www.multichain.com/developers/json-rpc-api/
*/
connect,
/**
* Allowed to send data on the stream. For information see https://www.multichain.com/developers/json-rpc-api/
*/
send,
/**
* For information see https://www.multichain.com/developers/json-rpc-api/
*/
receive,
/**
* Allowed to create streams. For information see https://www.multichain.com/developers/json-rpc-api/
*/
create,
/**
* For information see https://www.multichain.com/developers/json-rpc-api/
*/
issue,
/**
* Allowed to mine. For information see https://www.multichain.com/developers/json-rpc-api/
*/
mine,
/**
* For information see https://www.multichain.com/developers/json-rpc-api/
*/
activate,
/**
* Admin rights of the stream. For information see https://www.multichain.com/developers/json-rpc-api/
*/
admin,
/**
* Write access to the stream. For information see https://www.multichain.com/developers/json-rpc-api/
*/
write,
/**
* For information see https://www.multichain.com/developers/json-rpc-api/
*/
wildcard
}
private String streamName;
private final MultichainPermissionType permissionType;
/**
* Create Instance of MultichainPermission
*
* @param streamName
* name of the stream for the permissions
* @param permissionType
* type of permissions
*/
public MultichainPermission( final String streamName, final MultichainPermissionType permissionType )
{
this.streamName = streamName;
this.permissionType = permissionType;
}
/**
* Create Instance of MultichainPermission
*
* @param permissionType
* type of permission
*/
public MultichainPermission( final MultichainPermissionType permissionType )
{
this.permissionType = permissionType;
}
/**
* Get the permission for the stream
*
* @return permission
*/
@Nullable
public String getPermission()
{
String permissionTypeString = permissionType.toString();
if( permissionType == MultichainPermissionType.wildcard ) {
permissionTypeString = "*";
}
if( !StringUtils.isEmpty(streamName) ) {
return streamName + "." + permissionTypeString;
} else {
return permissionTypeString;
}
}
}