com.softlayer.api.service.network.contentdelivery.authentication.Token Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of softlayer-api-client Show documentation
Show all versions of softlayer-api-client Show documentation
API client for accessing the SoftLayer API
package com.softlayer.api.service.network.contentdelivery.authentication;
import com.softlayer.api.ApiClient;
import com.softlayer.api.ResponseHandler;
import com.softlayer.api.annotation.ApiMethod;
import com.softlayer.api.annotation.ApiProperty;
import com.softlayer.api.annotation.ApiType;
import com.softlayer.api.service.Entity;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.concurrent.Future;
/**
* The SoftLayer_Network_ContentDelivery_Authentication_Address data type models an individual IP address that CDN allow or deny access from.
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token
*/
@ApiType("SoftLayer_Network_ContentDelivery_Authentication_Token")
public class Token extends Entity {
/**
* The internal identifier of a CDN account
*/
@ApiProperty(canBeNullOrNotSet = true)
protected Long cdnAccountId;
public Long getCdnAccountId() {
return cdnAccountId;
}
public void setCdnAccountId(Long cdnAccountId) {
cdnAccountIdSpecified = true;
this.cdnAccountId = cdnAccountId;
}
protected boolean cdnAccountIdSpecified;
public boolean isCdnAccountIdSpecified() {
return cdnAccountIdSpecified;
}
public void unsetCdnAccountId() {
cdnAccountId = null;
cdnAccountIdSpecified = false;
}
/**
* The client IP address. This is optional.
*/
@ApiProperty(canBeNullOrNotSet = true)
protected String clientIp;
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
clientIpSpecified = true;
this.clientIp = clientIp;
}
protected boolean clientIpSpecified;
public boolean isClientIpSpecified() {
return clientIpSpecified;
}
public void unsetClientIp() {
clientIp = null;
clientIpSpecified = false;
}
/**
* The created date
*/
@ApiProperty(canBeNullOrNotSet = true)
protected GregorianCalendar createDate;
public GregorianCalendar getCreateDate() {
return createDate;
}
public void setCreateDate(GregorianCalendar createDate) {
createDateSpecified = true;
this.createDate = createDate;
}
protected boolean createDateSpecified;
public boolean isCreateDateSpecified() {
return createDateSpecified;
}
public void unsetCreateDate() {
createDate = null;
createDateSpecified = false;
}
/**
* The customer id. You can use this optional value to tie a user id to an authentication token.
*/
@ApiProperty(canBeNullOrNotSet = true)
protected String name;
public String getName() {
return name;
}
public void setName(String name) {
nameSpecified = true;
this.name = name;
}
protected boolean nameSpecified;
public boolean isNameSpecified() {
return nameSpecified;
}
public void unsetName() {
name = null;
nameSpecified = false;
}
/**
* The referrer information. This is optional.
*/
@ApiProperty(canBeNullOrNotSet = true)
protected String referrer;
public String getReferrer() {
return referrer;
}
public void setReferrer(String referrer) {
referrerSpecified = true;
this.referrer = referrer;
}
protected boolean referrerSpecified;
public boolean isReferrerSpecified() {
return referrerSpecified;
}
public void unsetReferrer() {
referrer = null;
referrerSpecified = false;
}
/**
* The managed token string
*/
@ApiProperty(canBeNullOrNotSet = true)
protected String token;
public String getToken() {
return token;
}
public void setToken(String token) {
tokenSpecified = true;
this.token = token;
}
protected boolean tokenSpecified;
public boolean isTokenSpecified() {
return tokenSpecified;
}
public void unsetToken() {
token = null;
tokenSpecified = false;
}
public static Service service(ApiClient client) {
return client.createService(Service.class, null);
}
/**
* CDN's content authentication service is the technology that allows only authorized user to access your content. It performs a token based authentication before delivering content. An authentication token can be obtained from the SoftLayer customer portal or API and it needs to be appended to the CDN URL. When an end-user requests a file, CDN server will check the validity of the token passed via HTTP GET string. Then the content will be delivered if the token is validated otherwise the connection will be rejected.
*
* There are several scenarios where this authentication capability could be useful. If a website doesn't require authentication, it runs the risk of other sites hot-linking to its images. Content owners can prevent others sites from passing HTTP links to images by requiring authentication in order to view a site's contents. Leverage the API to add this additional layer of security through our Content Authentication service.
*
* To begin using the Content Authentication service, define secure directions using the [[SoftLayer_Network_ContentDelivery_Account::createTokenAuthenticationDirectory|createTokenAuthenticationDirectory]] method. Refer to the table below for examples of token authentication URLs.
*
* {| cellspacing="5" style="width: 90%; border: 0px; margin-left: auto; margin-right: auto; padding: 10px;"
* |-
* |style="background: #d2d2d2; padding: 10px; text-align: center;"|'''Media Type'''
* |style="background: #d2d2d2; padding: 10px; text-align: center;"|'''Token Auth Directory'''
* |style="background: #d2d2d2; padding: 10px; text-align: center;"|'''CDN URL Type'''
* |style="background: #d2d2d2; padding: 10px; text-align: center;"|'''Example URL'''
* |-
* |style="background: #e7e7e7; text-align: center;"|HTTP
* |style="background: #e7e7e7; text-align: center;"|(FTP) /securehttp
* |style="background: #e7e7e7; text-align: center;"|Default
* |style="background: #e7e7e7"|http://(CDN_NAME).http.cdn.softlayer.net/00(CDN_NAME)/securehttp/example.jpg?ramdomTokenString
* |-
* |style="background: #e7e7e7; text-align: center;"|HTTP
* |style="background: #e7e7e7; text-align: center;"|(Customer Origin) http://myorigin.com/securehttp
* |style="background: #e7e7e7; text-align: center;"|Default
* |style="background: #e7e7e7"|http://(CDN_NAME).http.cdn.softlayer.net/80(CDN_NAME)/myorigin.com/securehttp/example.jpg?ramdomTokenString
* |-
* |style="background: #e7e7e7; text-align: center;"|HTTP
* |style="background: #e7e7e7; text-align: center;"|(FTP or Custom Origin)
* |style="background: #e7e7e7; text-align: center;"|CNAME
* |style="background: #e7e7e7"|http://cdn.mydomain.com/example.jpg?ramdomTokenString
* |-
* |style="background: #e7e7e7; text-align: center;"|Streaming Flash
* |style="background: #e7e7e7; text-align: center;"|(FTP) /secureflash
* |style="background: #e7e7e7; text-align: center;"|Default
* |style="background: #e7e7e7"|rtmp://(CDN_NAME).flash.cdn.softlayer.net/00(CDN_NAME)/secureflash/example.flv?ramdomTokenString
* |-
* |style="background: #e7e7e7; text-align: center;"|Streaming Flash
* |style="background: #e7e7e7; text-align: center;"|(Customer Origin) http://myorigin.com/secureflash
* |style="background: #e7e7e7; text-align: center;"|Default
* |style="background: #e7e7e7"|rtmp://(CDN_NAME).flash.cdn.softlayer.net/80(CDN_NAME)/myorigin.com/secureflash/example.flv?ramdomTokenString
* |-
* |style="background: #e7e7e7; text-align: center;"|Streaming Flash
* |style="background: #e7e7e7; text-align: center;"|(FTP or Custom Origin)
* |style="background: #e7e7e7; text-align: center;"|CNAME
* |style="background: #e7e7e7"|rtmp://flash.mydomain.com/example.flv?ramdomTokenString
* |-
* |style="background: #e7e7e7; text-align: center;"|Streaming Windows Media
* |style="background: #e7e7e7; text-align: center;"|(FTP) /securewm
* |style="background: #e7e7e7; text-align: center;"|Default
* |style="background: #e7e7e7"| mms://(CDN_NAME).flash.cdn.softlayer.net/00(CDN_NAME)/securewm/example.wmv?ramdomTokenString
* |-
* |}
*
*
* Note. Windows Media does not support customer origin. Token authentication can be ordered as a CDN add-on item.
*
* '''Authentication Token'''
*
* Authentication tokens expire after the specified time (in seconds) has elapsed. Set a token's expiration time by passing the number of seconds the token should remain active to the [[SoftLayer_Network_ContentDelivery_Authentication_Token::getTimedToken|getTimedToken]] method. For example, if you pass 3600 for the token life to the [[SoftLayer_Network_ContentDelivery_Authentication_Token::getTimedToken|getTimedToken]] method, it will return a token that will expire after an hour of its creation. There is no way to revoke a timed token. To create a timed token, use the [[SoftLayer_Network_ContentDelivery_Authentication_Token::getTimedToken|getTimedToken]] method and it takes 3 parameters:
*
* - '''Token Life (required)'''
- This value is defined in seconds and outlines the amount of time a token remains valid. To create a token that expires in an hour, pass a Token Life of 3600. The minimum value for Token Life is 60 seconds and the maximum value is 604800 seconds, or one week.
*
* - '''Client IP (optional)'''
- If set, the token validation process will match the client IP address. A valid IP address should be an IPv4 format or an IP block. If you want to block access from IP 211.37.0.0/16, you can enter "211.37." instead. IP blocks can be specified in the manner of "8bit times n".
*
* - '''Referring domain (optional)'''
- The referrer or referring page is the URL of the previous webpage from which a link was followed. You can further restrict access to your contents by matching referrer information. Set this value only if you are certain about referrer you're expecting. You can only set a domain or an IP address without a path or a file name in it. This can be a part of your domain. If you want to grant access from any of your subdomains, set the root domain as a referring domain.
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token
*/
@com.softlayer.api.annotation.ApiService("SoftLayer_Network_ContentDelivery_Authentication_Token")
public static interface Service extends com.softlayer.api.Service {
public ServiceAsync asAsync();
public Mask withNewMask();
public Mask withMask();
public void setMask(Mask mask);
/**
* This method is deprecated! Use the [[SoftLayer_Network_ContentDelivery_Authentication_Token::getTimedToken|getTimedToken]] method.
*
* This method creates a managed authentication token. When passing a parameter, the only required value is your CDN account id which can be obtained from the [[SoftLayer_Account::getCdnAccounts|getCdnAccounts]] method. There are 3 optional parameters you can pass:
*
*
* * name - This helps you keep track of managed tokens.
* * referrer - If set, the token validation will check the client's referrer. Keep in mind, if a client doesn't have the referrer information, the token validation will fail.
* * clientIp - If set, the token validation will check the client's IP address.
*
*
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::createObject
*/
@ApiMethod
public Token createObject(Token templateObject);
/**
* This method is deprecated!
*
* This method returns all managed tokens for a CDN account.
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::getAllManagedTokens
*/
@ApiMethod
public List getAllManagedTokens(Long cdnAccountId);
/**
* This method is deprecated!
*
* getObject retrieves the SoftLayer_Network_ContentDelivery_Authentication_Token object whose ID number corresponds to the ID number of the initial parameter passed to the SoftLayer_Network_ContentDelivery_Authentication_Token service. You can only retrieve managed tokens assigned to one of your CDN account.
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::getObject
*/
@ApiMethod(instanceRequired = true)
public Token getObject();
/**
* This method returns an authentication token that expires after the seconds you specify. You can provide number of seconds to manage the token life. This parameter sets the expiration time for a token. A valid life time must be an integer between 60 and 604800 (1 week). A customer can also provide client ip and (or) referrer information. If used, a client from the same IP and referrer can view the protected contents.
*
* A valid IP address must be an IPv4 format or an IP block. if you want to block access from IP 211.37.0.0/16, you can enter "211.37." instead. IP blocks can be specified in the manner of "8bit times n".
*
* The referrer is the URL of the previous webpage from which a link was followed. A referrer should not include "http://" prefix and it can be maximum of 30 characters.
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::getTimedToken
*/
@ApiMethod
public String getTimedToken(Long cdnAccountId, Long tokenLife, String clientIp, String referrer, String mediaType);
/**
* This method is deprecated!
*
* This method revokes all managed tokens belong to a CDN account.
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::revokeAllManagedTokens
*/
@ApiMethod
public Boolean revokeAllManagedTokens(Long cdnAccountId);
/**
* This method revokes all tokens belong to a CDN account. Valid media types are "HTTP", "FLASH" and "WM".
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::revokeAllTokens
*/
@ApiMethod
public Boolean revokeAllTokens(Long cdnAccountId, String mediaType);
/**
* This method is deprecated!
*
* Revokes a managed token. If you revoke a token, the token will be removed from SoftLayer's system but it will not remove your content on CDN FTP. The content that requires token validation will not be available to the visitor who is using a revoked token.
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::revokeManagedToken
*/
@ApiMethod
public Boolean revokeManagedToken(Long cdnAccountId, String token);
/**
* This method is deprecated!
*
* Deletes multiple managed tokens
*
* @see SoftLayer_Network_ContentDelivery_Authentication_Token::revokeManagedTokens
*/
@ApiMethod
public Boolean revokeManagedTokens(List templateObjects);
}
public static interface ServiceAsync extends com.softlayer.api.ServiceAsync {
public Mask withNewMask();
public Mask withMask();
public void setMask(Mask mask);
/**
* Async version of {@link Service#createObject}
*/
public Future createObject(Token templateObject);
public Future> createObject(Token templateObject, ResponseHandler callback);
/**
* Async version of {@link Service#getAllManagedTokens}
*/
public Future> getAllManagedTokens(Long cdnAccountId);
public Future> getAllManagedTokens(Long cdnAccountId, ResponseHandler> callback);
/**
* Async version of {@link Service#getObject}
*/
public Future getObject();
public Future> getObject(ResponseHandler callback);
/**
* Async version of {@link Service#getTimedToken}
*/
public Future getTimedToken(Long cdnAccountId, Long tokenLife, String clientIp, String referrer, String mediaType);
public Future> getTimedToken(Long cdnAccountId, Long tokenLife, String clientIp, String referrer, String mediaType, ResponseHandler callback);
/**
* Async version of {@link Service#revokeAllManagedTokens}
*/
public Future revokeAllManagedTokens(Long cdnAccountId);
public Future> revokeAllManagedTokens(Long cdnAccountId, ResponseHandler callback);
/**
* Async version of {@link Service#revokeAllTokens}
*/
public Future revokeAllTokens(Long cdnAccountId, String mediaType);
public Future> revokeAllTokens(Long cdnAccountId, String mediaType, ResponseHandler callback);
/**
* Async version of {@link Service#revokeManagedToken}
*/
public Future revokeManagedToken(Long cdnAccountId, String token);
public Future> revokeManagedToken(Long cdnAccountId, String token, ResponseHandler callback);
/**
* Async version of {@link Service#revokeManagedTokens}
*/
public Future revokeManagedTokens(List templateObjects);
public Future> revokeManagedTokens(List templateObjects, ResponseHandler callback);
}
public static class Mask extends com.softlayer.api.service.Entity.Mask {
public Mask cdnAccountId() {
withLocalProperty("cdnAccountId");
return this;
}
public Mask clientIp() {
withLocalProperty("clientIp");
return this;
}
public Mask createDate() {
withLocalProperty("createDate");
return this;
}
public Mask name() {
withLocalProperty("name");
return this;
}
public Mask referrer() {
withLocalProperty("referrer");
return this;
}
public Mask token() {
withLocalProperty("token");
return this;
}
}
}