|
IP*Works! SSL V9 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectipworksssl.Oauth
public class Oauth
The OAuth bean is used to authorize a client and provide an authorization string used in future requests.
The OAuth bean provides an easy way to obtain an authorization string for future requests to a service. The bean implements an OAuth 2.0 client.
To begin using the bean you will first need to register your application with the service you want to use. During
this process you should obtain a ClientId and ClientSecret as well as the ServerAuthURL and ServerTokenURL for the authorization server. Then set ClientProfile to the client type that best
describes your situation and call GetAuthorization .
The following client types are currently supported by the bean:
First, set ClientProfile to cfApplication. This defines the client type the bean will use.
Set the ClientId , ClientSecret , ServerAuthURL , and ServerTokenURL to the values you
obtained when registering your application.
Next, call GetAuthorization to begin the authorization process. When GetAuthorization is called
the bean will build the URL to which the user will be directed and fire the LaunchBrowser event.
The bean will then launch the browser using the command and URL shown in the LaunchBrowser event.
The user will authenticate to the service, and then be redirected back to an embedded web server that was automatically
started when GetAuthorization was called. At this time the ReturnURL event will fire. This event provides
an opportunity to provide a custom response to your user that they will see in their browser.
The bean will then automatically exchange the grant that was returned by the authorization server for the
access token using the HTTP endpoint specified in ServerTokenURL .
The authorization is now complete and the GetAuthorization method will return the authorization string.
To use the authorization string with any of our beans simply pass this value to the Authorization property
before making the request.
A simple example is shown below.
OAuth.ClientId = "MyId";
OAuth.ClientSecret = "MyPassword";
OAuth.ServerAuthURL = "https://accounts.google.com/o/oauth2/auth";
OAuth.ServerTokenURL = "https://accounts.google.com/o/oauth2/token";
HTTP.Authorization = OAuth.GetAuthorization();
HTTP.Get("https://www.googleapis.com/oauth2/v1/userinfo");
WebServer Client Type
The WebServer client type is applicable to applications that are run on the server side where the user uses the application from a web browser. To authorize your application (client) using this client type follow the steps below.
First, set ClientProfile to cfWebServer. This defines the client type the component will use. Set the ClientId , ClientSecret , ServerAuthURL , and ServerTokenURL to the values you obtained when registering
your application. Set ReturnURL to the page on your site that will be the endpoint the user is redirected back to
after authentication.
Next, call GetAuthorizationURL . This will return a URL to which the user should be redirected. Redirect the user
to this URL.
After the user authenticates and is returned to the page on your site specified by ReturnURL , parse the "code"
query string parameter from the incoming request. Set AuthorizationCode to this value.
Call GetAuthorization to exchange the code specified in AuthorizationCode for a token from the server
specified by ServerTokenURL . GetAuthorization returns the authorization string.
To use the authorization string with any of our components simply pass this value to the Authorization property
before making the request.
Device Client Type
The Device client type is applicable to applications that are run on devices where no web browser can be used. For instance a game console would use the device client type. To authorize your application (client) using the device client type follow the steps below.
First, set ClientProfile to cfDevice. This defines the client type the bean will use. Set the ClientId , ClientSecret , ServerAuthURL , and ServerTokenURL to the values you obtained when registering
your application. Do not set ReturnURL .
Next, call GetAuthorizationURL . The bean will automatically make a request to ServerAuthURL to obtain
a user code for the device. The GetAuthorizationURL method will return the URL your user must visit from another
device or computer that has web browser support. The GetAuthorizationURL method will also populate ipworksssl.Oauth#config . This device user code must also be provided to the user.
The user will enter the code at the URL returned by {@link ipworksssl.Oauth#getAuthorizationURL GetAuthorizationURL} .
At this time, call {@link ipworksssl.Oauth#getAuthorization GetAuthorization} . The bean will begin polling the server specified in {@link ipworksssl.Oauth#getServerTokenURL ServerTokenURL} . The polling interval is specified (in seconds) by the {@link ipworksssl.Oauth#config setting.
After the user has authenticated, the {@link ipworksssl.Oauth#getAuthorization GetAuthorization} method will return the authorization string. To use the authorization string with any of our components simply pass this value to the Authorization property before making the request.
Mobile Client Type
The Mobile client type is applicable to applications that are run on devices where a web browser can be used. For instance a mobile phone or tablet. The behavior when using this client type is very similar to the Application client type. The only difference between the Mobile and Application client types is the way the browser is launched, when set to Mobile the {@link ipworksssl.OauthLaunchBrowserEvent LaunchBrowser} event will fire but the bean will not attempt to launch the browser automatically. The browser must be launched manually from code. This behavior is the only difference between the Mobile and Application client type. Please read the steps above for the Application client type for a more detailed look at the process.
| Field Summary | |
|---|---|
static int |
cfApplication
|
static int |
cfBrowser
|
static int |
cfDevice
|
static int |
cfMobile
|
static int |
cfWebServer
|
static int |
frAlways
|
static int |
frNever
|
static int |
frSameScheme
|
| Constructor Summary | |
|---|---|
Oauth()
Creates an instance of Oauth Bean. |
|
Oauth(java.lang.String runtimeLicense)
Creates an instance of Oauth Bean with specified run-time license. |
|
| Method Summary | |
|---|---|
void |
addCookie(java.lang.String cookieName,
java.lang.String cookieValue)
Adds a cookie and the corresponding value to the outgoing request headers. |
void |
addOauthEventListener(OauthEventListener l)
|
void |
addParam(java.lang.String paramName,
java.lang.String paramValue)
Adds a name-value pair to the query string parameters of outgoing request. |
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a {@link ipworksssl.Oauth#config configuration setting. |
void |
doEvents()
Processes events from the internal message queue. |
java.lang.String |
getAccept()
A list of acceptable MIME types for the request. |
java.lang.String |
getAccessToken()
The access token returned by the authorization server. |
java.lang.String |
getAuthorization()
Gets the authorization string required to access the protected resource. |
java.lang.String |
getAuthorizationCode()
The authorization code that is exchanged for an access token. |
java.lang.String |
getAuthorizationScope()
The scope request or response parameter used during authorization. |
java.lang.String |
getAuthorizationURL()
Builds and returns the URL to which the user should be re-directed for authorization. |
java.lang.String |
getClientId()
The id of the client assigned when registering the application. |
int |
getClientProfile()
The type of client that is requesting authorization. |
java.lang.String |
getClientSecret()
The secret value for the client assigned when registering the application. |
java.lang.String |
getContentType()
Content type for posts and puts. |
HTTPCookieList |
getCookies()
Collection of cookies. |
Firewall |
getFirewall()
A set of properties related to firewall access. |
int |
getFollowRedirects()
Determines what happens when the server issues a redirect. |
java.lang.String |
getFrom()
The email address of the HTTP agent (optional). |
java.lang.String |
getHTTPMethod()
The HTTP method used for the request. |
java.lang.String |
getIfModifiedSince()
A date determining the maximum age of the desired document. |
java.lang.String |
getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
java.lang.String |
getOtherHeaders()
Other headers as determined by the user (optional). |
OAuthParamList |
getParams()
The parameters to be included in the request to the authorization server, or received in the response. |
HeaderList |
getParsedHeaders()
Collection of headers returned from the last request. |
byte[] |
getPostData()
The data to post with the URL if the POST method is used. |
java.lang.String |
getPragma()
A browser/server specific header line (optional). |
Proxy |
getProxy()
A set of properties related to proxy access. |
java.lang.String |
getRange()
The byte-range to be sent to the server. |
java.lang.String |
getReferer()
Referer URL/document (optional). |
java.lang.String |
getRefreshToken()
Specifies the refresh token received from or sent to the authorization server. |
java.lang.String |
getReturnURL()
The URL where the user (browser) returns after authenticating. |
java.lang.String |
getServerAuthURL()
The URL of the authorization server. |
java.lang.String |
getServerTokenURL()
The URL used to obtain the access token. |
Certificate |
getSSLAcceptServerCert()
Instructs the bean to unconditionally accept the server certificate that matches the supplied certificate. |
Certificate |
getSSLCert()
The certificate to be used during SSL negotiation. |
Certificate |
getSSLServerCert()
The server certificate for the last established connection. |
java.lang.String |
getStatusLine()
The first line of the last server response. |
int |
getTimeout()
A timeout for the bean. |
byte[] |
getTransferredData()
The contents of the last response from the server. |
long |
getTransferredDataLimit()
The maximum of data to be transferred. |
java.lang.String |
getTransferredHeaders()
The full set of headers as received from the server. |
void |
interrupt()
Interrupt the current method. |
boolean |
isAllowHTTPCompression()
Enables HTTP compression for receiving data. |
boolean |
isConnected()
Shows whether the bean is connected. |
boolean |
isIdle()
The current status of the component. |
void |
removeOauthEventListener(OauthEventListener l)
|
void |
reset()
Reset the bean. |
void |
setAccept(java.lang.String accept)
A list of acceptable MIME types for the request. |
void |
setAccessToken(java.lang.String accessToken)
The access token returned by the authorization server. |
void |
setAllowHTTPCompression(boolean allowHTTPCompression)
Enables HTTP compression for receiving data. |
void |
setAuthorizationCode(java.lang.String authorizationCode)
The authorization code that is exchanged for an access token. |
void |
setAuthorizationScope(java.lang.String authorizationScope)
The scope request or response parameter used during authorization. |
void |
setClientId(java.lang.String clientId)
The id of the client assigned when registering the application. |
void |
setClientProfile(int clientProfile)
The type of client that is requesting authorization. |
void |
setClientSecret(java.lang.String clientSecret)
The secret value for the client assigned when registering the application. |
void |
setConnected(boolean connected)
Shows whether the bean is connected. |
void |
setContentType(java.lang.String contentType)
Content type for posts and puts. |
void |
setFirewall(Firewall firewall)
A set of properties related to firewall access. |
void |
setFollowRedirects(int followRedirects)
Determines what happens when the server issues a redirect. |
void |
setFrom(java.lang.String from)
The email address of the HTTP agent (optional). |
void |
setHTTPMethod(java.lang.String HTTPMethod)
The HTTP method used for the request. |
void |
setIfModifiedSince(java.lang.String ifModifiedSince)
A date determining the maximum age of the desired document. |
void |
setLocalHost(java.lang.String localHost)
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
void |
setOtherHeaders(java.lang.String otherHeaders)
Other headers as determined by the user (optional). |
void |
setPostData(byte[] postData)
The data to post with the URL if the POST method is used. |
void |
setPragma(java.lang.String pragma)
A browser/server specific header line (optional). |
void |
setProxy(Proxy proxy)
A set of properties related to proxy access. |
void |
setRange(java.lang.String range)
The byte-range to be sent to the server. |
void |
setReferer(java.lang.String referer)
Referer URL/document (optional). |
void |
setRefreshToken(java.lang.String refreshToken)
Specifies the refresh token received from or sent to the authorization server. |
void |
setReturnURL(java.lang.String returnURL)
The URL where the user (browser) returns after authenticating. |
void |
setServerAuthURL(java.lang.String serverAuthURL)
The URL of the authorization server. |
void |
setServerTokenURL(java.lang.String serverTokenURL)
The URL used to obtain the access token. |
void |
setSSLAcceptServerCert(Certificate SSLAcceptServerCert)
Instructs the bean to unconditionally accept the server certificate that matches the supplied certificate. |
void |
setSSLCert(Certificate SSLCert)
The certificate to be used during SSL negotiation. |
void |
setTimeout(int timeout)
A timeout for the bean. |
void |
setTransferredDataLimit(long transferredDataLimit)
The maximum of data to be transferred. |
void |
startWebServer()
Starts the embedded web server. |
void |
stopWebServer()
Stops the embedded web server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int cfApplication
public static final int cfWebServer
public static final int cfDevice
public static final int cfMobile
public static final int cfBrowser
public static final int frNever
public static final int frAlways
public static final int frSameScheme
| Constructor Detail |
|---|
public Oauth()
public Oauth(java.lang.String runtimeLicense)
| Method Detail |
|---|
public java.lang.String getAccept()
If this property contains a non-empty string, an HTTP Accept header is added to the request.
The Accept header is used for content negotiation. It provides the server with a comma-separated list of MIME types that are acceptable for its response.
public void setAccept(java.lang.String accept)
throws IPWorksSSLException
If this property contains a non-empty string, an HTTP Accept header is added to the request.
The Accept header is used for content negotiation. It provides the server with a comma-separated list of MIME types that are acceptable for its response.
IPWorksSSLExceptionpublic java.lang.String getAccessToken()
This property will be populated with the access token returned by the authorization server
after a call to GetAuthorization . This will be the raw access token, whereas the return value
from the GetAuthorization method will also include the required data so it can be passed directly
to the Authorization property of the components or added as the value of the Authorization header in
another client implementation.
public void setAccessToken(java.lang.String accessToken)
throws IPWorksSSLException
This property will be populated with the access token returned by the authorization server
after a call to GetAuthorization . This will be the raw access token, whereas the return value
from the GetAuthorization method will also include the required data so it can be passed directly
to the Authorization property of the components or added as the value of the Authorization header in
another client implementation.
IPWorksSSLExceptionpublic boolean isAllowHTTPCompression()
This property enables HTTP compression for receiving data. When set to true, the bean will accept compressed data. It will then uncompress the data it has received. The bean will handle data compressed by both GZIP and Deflate compression algorithms.
When true, the bean adds an "Accept-Encoding" header to the outgoing request. The value for this header can be controlled by the ipworksssl.Oauth#config config. The default value for this header is "gzip, deflate".
{@link ipworksssl.Oauth#getTransferredData TransferredData} will contain the decompressed data received by the server, but the {@link ipworksssl.OauthTransferEvent Transfer} event will report exactly what is received by the server (compressed data).
public void setAllowHTTPCompression(boolean allowHTTPCompression)
throws IPWorksSSLException
This property enables HTTP compression for receiving data. When set to true, the bean will accept compressed data. It will then uncompress the data it has received. The bean will handle data compressed by both GZIP and Deflate compression algorithms.
When true, the bean adds an "Accept-Encoding" header to the outgoing request. The value for this header can be controlled by the ipworksssl.Oauth#config config. The default value for this header is "gzip, deflate".
{@link ipworksssl.Oauth#getTransferredData TransferredData} will contain the decompressed data received by the server, but the {@link ipworksssl.OauthTransferEvent Transfer} event will report exactly what is received by the server (compressed data).
IPWorksSSLExceptionpublic java.lang.String getAuthorizationCode()
When ClientProfile is set to cfWebServer (WebServer flow) the authorization server will return
a code when the user is re-directed from the authorization server back to your website.
This code is returned as a query string parameter and the bean will automatically populate
this property with that value.
Normally this property will only be informational, as the GetAuthorization method will automatically
exchange this code for a token with the authorization server specified in ServerTokenURL .
If this property is set before calling GetAuthorization the bean will attempt to exchange the
code with the authorization server for an access token.
public void setAuthorizationCode(java.lang.String authorizationCode)
throws IPWorksSSLException
When ClientProfile is set to cfWebServer (WebServer flow) the authorization server will return
a code when the user is re-directed from the authorization server back to your website.
This code is returned as a query string parameter and the bean will automatically populate
this property with that value.
Normally this property will only be informational, as the GetAuthorization method will automatically
exchange this code for a token with the authorization server specified in ServerTokenURL .
If this property is set before calling GetAuthorization the bean will attempt to exchange the
code with the authorization server for an access token.
IPWorksSSLExceptionpublic java.lang.String getAuthorizationScope()
If the scope is not set, the authorization server will use the default access scope for your application as determined by the server. To request a specific access scope set this property to a space separated list of strings as defined by the authorization server.
After calling GetAuthorization this property will be updated with the scope sent in the response from the server
and will indicate the scope that was actually granted.
public void setAuthorizationScope(java.lang.String authorizationScope)
throws IPWorksSSLException
If the scope is not set, the authorization server will use the default access scope for your application as determined by the server. To request a specific access scope set this property to a space separated list of strings as defined by the authorization server.
After calling GetAuthorization this property will be updated with the scope sent in the response from the server
and will indicate the scope that was actually granted.
IPWorksSSLExceptionpublic java.lang.String getClientId()
This property holds the id of the client that was assigned when initially registering the application
with the authorization server. This value must be specified before calling GetAuthorization or GetAuthorizationURL .
public void setClientId(java.lang.String clientId)
throws IPWorksSSLException
This property holds the id of the client that was assigned when initially registering the application
with the authorization server. This value must be specified before calling GetAuthorization or GetAuthorizationURL .
IPWorksSSLExceptionpublic int getClientProfile()
This defines the type of client that will be requesting authorization. Set this before calling GetAuthorization to inform the bean to act accordingly. Possible values are:
public void setClientProfile(int clientProfile)
throws IPWorksSSLException
This defines the type of client that will be requesting authorization. Set this before calling GetAuthorization to inform the bean to act accordingly. Possible values are:
IPWorksSSLExceptionpublic java.lang.String getClientSecret()
This property holds the secret of the client that was assigned when initially registering the application
with the authorization server. This value must be specified before calling GetAuthorization or GetAuthorizationURL .
public void setClientSecret(java.lang.String clientSecret)
throws IPWorksSSLException
This property holds the secret of the client that was assigned when initially registering the application
with the authorization server. This value must be specified before calling GetAuthorization or GetAuthorizationURL .
IPWorksSSLExceptionpublic boolean isConnected()
This property is used to determine whether or not the bean is connected to the remote host.
public void setConnected(boolean connected)
throws IPWorksSSLException
This property is used to determine whether or not the bean is connected to the remote host.
IPWorksSSLExceptionpublic java.lang.String getContentType()
If this property contains a non-empty string, a Content-Type HTTP request header is added to the request. The purpose of the header is to show the contents
of the data during a Post or Put to the server.
The most common example is posting of HTML form input data. In that case, this property must be set to "application/x-www-form-urlencoded" .
public void setContentType(java.lang.String contentType)
throws IPWorksSSLException
If this property contains a non-empty string, a Content-Type HTTP request header is added to the request. The purpose of the header is to show the contents
of the data during a Post or Put to the server.
The most common example is posting of HTML form input data. In that case, this property must be set to "application/x-www-form-urlencoded" .
IPWorksSSLExceptionpublic HTTPCookieList getCookies()
This property contains a collection of cookies. To add cookies to outgoing HTTP requests, add cookies (of type httpcookie ) to this collection.
To see cookies that are set by the server, use the SetCookie event, which displays the cookies and their properties as set by the server.
Those cookies are also added to Cookies .
{@link ipworksssl.Oauth#config can be used to control the maximum number of cookies saved.
This collection is indexed from 0 to size - 1.
public Firewall getFirewall()
This is a Firewall type property which
contains fields describing the firewall
through which the bean will attempt to connect.
public void setFirewall(Firewall firewall)
throws IPWorksSSLException
This is a Firewall type property which
contains fields describing the firewall
through which the bean will attempt to connect.
IPWorksSSLExceptionpublic int getFollowRedirects()
This property determines what happens when the server issues a redirect. Normally, the bean returns an error if the server responds
with an "Object Moved" message. If this property is set to frAlways (1), the new URL for the object is retrieved automatically every time.
If this property is set to frSameScheme (2), the new URL is
retrieved automatically only if the URLScheme is the same, otherwise
the bean throws an exception.
Note that following the HTTP specification, unless this property is set to frAlways (1), automatic redirects will be performed only for 'GET' or 'HEAD' requests. Other methods could potentially change the conditions of the initial request and create security vulnerabilities.
Furthermore, if either the new URL server and port are different than
the existing one, User and Password are also reset to empty,
unless this property is set to frAlways (1), in which case
the same credentials are used to connect to the new server.
A Redirect event is fired for every URL the product is redirected
to. In the case of automatic redirections, the Redirect event is
a good place to set properties related to the new connection (e.g. new
authentication parameters).
The default value is frNever (0). In this case, redirects are never followed, and the bean throws an exception instead.
public void setFollowRedirects(int followRedirects)
throws IPWorksSSLException
This property determines what happens when the server issues a redirect. Normally, the bean returns an error if the server responds
with an "Object Moved" message. If this property is set to frAlways (1), the new URL for the object is retrieved automatically every time.
If this property is set to frSameScheme (2), the new URL is
retrieved automatically only if the URLScheme is the same, otherwise
the bean throws an exception.
Note that following the HTTP specification, unless this property is set to frAlways (1), automatic redirects will be performed only for 'GET' or 'HEAD' requests. Other methods could potentially change the conditions of the initial request and create security vulnerabilities.
Furthermore, if either the new URL server and port are different than
the existing one, User and Password are also reset to empty,
unless this property is set to frAlways (1), in which case
the same credentials are used to connect to the new server.
A Redirect event is fired for every URL the product is redirected
to. In the case of automatic redirections, the Redirect event is
a good place to set properties related to the new connection (e.g. new
authentication parameters).
The default value is frNever (0). In this case, redirects are never followed, and the bean throws an exception instead.
IPWorksSSLExceptionpublic java.lang.String getFrom()
This property contains the email address of the HTTP agent (optional). If it contains a non-empty string, an HTTP From: header is added to the request. This header generally gives the email address of the requester of the document.
public void setFrom(java.lang.String from)
throws IPWorksSSLException
This property contains the email address of the HTTP agent (optional). If it contains a non-empty string, an HTTP From: header is added to the request. This header generally gives the email address of the requester of the document.
IPWorksSSLExceptionpublic java.lang.String getHTTPMethod()
This property contains the HTTP method used for the request. If an empty string is provided, the HTTPMethod is determined automatically by the method being called. You may change it to a custom value if you require an HTTP method other than what is provided by the bean.
public void setHTTPMethod(java.lang.String HTTPMethod)
throws IPWorksSSLException
This property contains the HTTP method used for the request. If an empty string is provided, the HTTPMethod is determined automatically by the method being called. You may change it to a custom value if you require an HTTP method other than what is provided by the bean.
IPWorksSSLExceptionpublic boolean isIdle()
Idle will be False if the component is currently busy (communicating
and/or waiting for an answer), and True at all other times.
public java.lang.String getIfModifiedSince()
If this property contains a non-empty string, an If-Modified-Since HTTP header is added to the request. The value of this header is used to make the HTTP request conditional: if the requested documented has not been modified since the time specified in the field, a copy of the document will not be returned from the server; instead, a 304 (not modified) response will be returned by the server and the bean throws an exception
The format of the date value for IfModifiedSince is detailed
in the HTTP specs. An example is Sat, 29 Oct 1994 19:43:31 GMT.
public void setIfModifiedSince(java.lang.String ifModifiedSince)
throws IPWorksSSLException
If this property contains a non-empty string, an If-Modified-Since HTTP header is added to the request. The value of this header is used to make the HTTP request conditional: if the requested documented has not been modified since the time specified in the field, a copy of the document will not be returned from the server; instead, a 304 (not modified) response will be returned by the server and the bean throws an exception
The format of the date value for IfModifiedSince is detailed
in the HTTP specs. An example is Sat, 29 Oct 1994 19:43:31 GMT.
IPWorksSSLExceptionpublic java.lang.String getLocalHost()
The LocalHost property contains the name of the local host
as obtained by the gethostname() system call, or if the
user has assigned an IP address, the value of that address.
In multi-homed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.
If the bean is connected, the LocalHost property shows
the IP address of the interface through which the connection
is made in internet dotted format (aaa.bbb.ccc.ddd). In most
cases, this is the address of the local host, except for multi-homed
hosts (machines with more than one IP interface).
NOTE: LocalHost is not persistent. You must always set it in
code, and never in the property window.
public void setLocalHost(java.lang.String localHost)
throws IPWorksSSLException
The LocalHost property contains the name of the local host
as obtained by the gethostname() system call, or if the
user has assigned an IP address, the value of that address.
In multi-homed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.
If the bean is connected, the LocalHost property shows
the IP address of the interface through which the connection
is made in internet dotted format (aaa.bbb.ccc.ddd). In most
cases, this is the address of the local host, except for multi-homed
hosts (machines with more than one IP interface).
NOTE: LocalHost is not persistent. You must always set it in
code, and never in the property window.
IPWorksSSLExceptionpublic java.lang.String getOtherHeaders()
This property can be set to a string of headers to be appended to the HTTP request headers created from other properties like ContentType , From , etc.
The headers must be of the format "header: value" as described in the HTTP specifications. Header lines should be separated by CRLF ("\r\ n") .
Use this property with caution. If this property contains invalid headers, HTTP requests may fail.
This property is useful for extending the functionality of the bean beyond what is provided.
public void setOtherHeaders(java.lang.String otherHeaders)
throws IPWorksSSLException
This property can be set to a string of headers to be appended to the HTTP request headers created from other properties like ContentType , From , etc.
The headers must be of the format "header: value" as described in the HTTP specifications. Header lines should be separated by CRLF ("\r\ n") .
Use this property with caution. If this property contains invalid headers, HTTP requests may fail.
This property is useful for extending the functionality of the bean beyond what is provided.
IPWorksSSLExceptionpublic OAuthParamList getParams()
This is a collection of query string parameters to be added in the request when creating the authorization URL. This will also hold the parameters returned in the response.
public HeaderList getParsedHeaders()
This property contains a collection of headers returned from the last request. Whenever headers are returned from the server, the headers are
parsed into a collection of headers. Each header in this collection contains information describing that header.
{@link ipworksssl.Oauth#config can be used to control the maximum number of headers saved.
This collection is indexed from 0 to size - 1.
public byte[] getPostData()
If this method is a non-empty string, then if the HTTP Post method is used. The contents of this property are appended to the HTTP request after the HTTP headers.
An HTTP 'Content-Length' header is also added to the request. Its value is the length of the string in PostData , or, if the AttachedFile property has been set, the cumulative length of the string and the file. See the description of the AttachedFile property for details.
If the goal is to upload a file or binary form data to a receiving script, the postdata must be MIME encoded. The WebUpload component is specifically designed for this and will perform all of the MIME encoding for you automatically. The WebForm component can be used for any form data posting.
The most common example is posting of HTML form input data. In that case, the ContentType property must be set to "application/x-www-form-urlencoded".
Example (Performing a Post)
HTTPControl.ContentType = "application/x-www-form-urlencoded"
HTTPControl.PostData = "firstname=Tom&lastname=Thompson&country=US"
HTTPControl.Post(myurl)
public void setPostData(byte[] postData)
throws IPWorksSSLException
If this method is a non-empty string, then if the HTTP Post method is used. The contents of this property are appended to the HTTP request after the HTTP headers.
An HTTP 'Content-Length' header is also added to the request. Its value is the length of the string in PostData , or, if the AttachedFile property has been set, the cumulative length of the string and the file. See the description of the AttachedFile property for details.
If the goal is to upload a file or binary form data to a receiving script, the postdata must be MIME encoded. The WebUpload component is specifically designed for this and will perform all of the MIME encoding for you automatically. The WebForm component can be used for any form data posting.
The most common example is posting of HTML form input data. In that case, the ContentType property must be set to "application/x-www-form-urlencoded".
Example (Performing a Post)
HTTPControl.ContentType = "application/x-www-form-urlencoded"
HTTPControl.PostData = "firstname=Tom&lastname=Thompson&country=US"
HTTPControl.Post(myurl)
IPWorksSSLExceptionpublic java.lang.String getPragma()
If this property contains a non-empty string, a Pragma HTTP request header is added to the request. The meaning of the header depends on the implementation and can be used to send/receive proprietary information to/from the server.
public void setPragma(java.lang.String pragma)
throws IPWorksSSLException
If this property contains a non-empty string, a Pragma HTTP request header is added to the request. The meaning of the header depends on the implementation and can be used to send/receive proprietary information to/from the server.
IPWorksSSLExceptionpublic Proxy getProxy()
This property contains fields describing the proxy through which the bean will attempt to connect.
public void setProxy(Proxy proxy)
throws IPWorksSSLException
This property contains fields describing the proxy through which the bean will attempt to connect.
IPWorksSSLExceptionpublic java.lang.String getRange()
If this property contains a non-empty string, a Range HTTP request header is added to the request. This header tells the server to only send a certain range of bytes.
The format of this property consists of a range of bytes specified by two numbers separated by '-' (e.g. "0-499")
For example:
public void setRange(java.lang.String range)
throws IPWorksSSLException
If this property contains a non-empty string, a Range HTTP request header is added to the request. This header tells the server to only send a certain range of bytes.
The format of this property consists of a range of bytes specified by two numbers separated by '-' (e.g. "0-499")
For example:
IPWorksSSLExceptionpublic java.lang.String getReferer()
If this property contains a non-empty string, a Referer HTTP request header is added to the request. The purpose of the header is to show the document referring the requested URL.
public void setReferer(java.lang.String referer)
throws IPWorksSSLException
If this property contains a non-empty string, a Referer HTTP request header is added to the request. The purpose of the header is to show the document referring the requested URL.
IPWorksSSLExceptionpublic java.lang.String getRefreshToken()
When GetAuthorization is called if the authorization server returns a refresh token along with the access token,
this property will hold the refresh token. Save this value for later use.
When your access token expires, set this property to the corresponding refresh token. Then call GetAuthorization and the bean will use this token to retrieve a new access token. The new
authorization string will be returned by the GetAuthorization method.
No user interaction is required when refreshing an access token.
public void setRefreshToken(java.lang.String refreshToken)
throws IPWorksSSLException
When GetAuthorization is called if the authorization server returns a refresh token along with the access token,
this property will hold the refresh token. Save this value for later use.
When your access token expires, set this property to the corresponding refresh token. Then call GetAuthorization and the bean will use this token to retrieve a new access token. The new
authorization string will be returned by the GetAuthorization method.
No user interaction is required when refreshing an access token.
IPWorksSSLExceptionpublic java.lang.String getReturnURL()
When ClientProfile is set to cfApplication this will be automatically set to the address of the
local embedded web server. In that case this property can be inspected to determine the URL
where the user will be redirected, but does not need to be set.
When calling GetAuthorizationURL , which is common when ClientProfile is set to cfWebBrowser,
set this property to the URL on your server where the user will be redirected after authenticating
with the authorization server.
public void setReturnURL(java.lang.String returnURL)
throws IPWorksSSLException
When ClientProfile is set to cfApplication this will be automatically set to the address of the
local embedded web server. In that case this property can be inspected to determine the URL
where the user will be redirected, but does not need to be set.
When calling GetAuthorizationURL , which is common when ClientProfile is set to cfWebBrowser,
set this property to the URL on your server where the user will be redirected after authenticating
with the authorization server.
IPWorksSSLExceptionpublic java.lang.String getServerAuthURL()
Specifies the URL of the authorization server used when GetAuthorization is called. This value
is used when constructing the URL to which the user will be redirected to authenticate and grant
access.
This should be specified before calling GetAuthorization .
When this is set, it will clear any value specified in {@link ipworksssl.Oauth#config .
public void setServerAuthURL(java.lang.String serverAuthURL)
throws IPWorksSSLException
Specifies the URL of the authorization server used when GetAuthorization is called. This value
is used when constructing the URL to which the user will be redirected to authenticate and grant
access.
This should be specified before calling GetAuthorization .
When this is set, it will clear any value specified in {@link ipworksssl.Oauth#config .
IPWorksSSLExceptionpublic java.lang.String getServerTokenURL()
Specifies the URL where the grant will be exchanged for the access token. This is typically a separate HTTP endpoint on the authorization server.
This must be set before calling GetAuthorization .
public void setServerTokenURL(java.lang.String serverTokenURL)
throws IPWorksSSLException
Specifies the URL where the grant will be exchanged for the access token. This is typically a separate HTTP endpoint on the authorization server.
This must be set before calling GetAuthorization .
IPWorksSSLExceptionpublic Certificate getSSLAcceptServerCert()
If it finds any issues with the certificate presented by the server, the bean will normally terminate the connection with an error.
You may override this behavior by supplying a value for SSLAcceptServerCert .
If the certificate supplied in SSLAcceptServerCert is the same as the
certificate presented by the server, then the server
certificate is accepted unconditionally, and the connection will continue
normally.
Please note that this functionality is provided only for cases where you otherwise know that you are communicating with the right server. If used improperly, this property may create a security breach. Use it at your own risk.
public void setSSLAcceptServerCert(Certificate SSLAcceptServerCert)
throws IPWorksSSLException
If it finds any issues with the certificate presented by the server, the bean will normally terminate the connection with an error.
You may override this behavior by supplying a value for SSLAcceptServerCert .
If the certificate supplied in SSLAcceptServerCert is the same as the
certificate presented by the server, then the server
certificate is accepted unconditionally, and the connection will continue
normally.
Please note that this functionality is provided only for cases where you otherwise know that you are communicating with the right server. If used improperly, this property may create a security breach. Use it at your own risk.
IPWorksSSLExceptionpublic Certificate getSSLCert()
The digital certificate that the bean will use
during SSL negotiation. Set this property to a valid
certificate before starting SSL negotiation. To set
a certificate, you may set the Encoded field to
the encoded certificate. To select a certificate, use
the store and subject fields.
public void setSSLCert(Certificate SSLCert)
throws IPWorksSSLException
The digital certificate that the bean will use
during SSL negotiation. Set this property to a valid
certificate before starting SSL negotiation. To set
a certificate, you may set the Encoded field to
the encoded certificate. To select a certificate, use
the store and subject fields.
IPWorksSSLExceptionpublic Certificate getSSLServerCert()
SSLServerCert contains the server certificate for the
last established connection.
SSLServerCert is reset every time a new connection is attempted.
public java.lang.String getStatusLine()
This property contains the first line of the last server response. This value can be used for diagnostic purposes. If an HTTP error is returned when calling a method of the bean, the error string is the same as the StatusLine property.
The HTTP protocol specifies the structure of the StatusLine as: [HTTP version] [Result Code] [Description].
public int getTimeout()
If the Timeout property is set to 0, all operations
will run uninterrupted until successful completion or an error condition
is encountered.
If Timeout is set to a positive value, the bean will
wait for the operation to complete before returning control.
The bean will use DoEvents to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If Timeout expires, and the operation is not yet complete,
the bean throws an exception.
Please note that by default, all timeouts are inactivity timeouts ,
i.e. the timeout period is extended by Timeout seconds when
any amount of data is successfully sent or received.
Optionally, the behavior of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum
of Timeout seconds since the beginning of the operation, without
extending the timeout period during communications.
This behavior is controlled by the ipworksssl.Oauth#config configuration setting.
The default value for the {@link ipworksssl.Oauth#getTimeout Timeout} property is 60 (seconds).
public void setTimeout(int timeout)
throws IPWorksSSLException
If the Timeout property is set to 0, all operations
will run uninterrupted until successful completion or an error condition
is encountered.
If Timeout is set to a positive value, the bean will
wait for the operation to complete before returning control.
The bean will use DoEvents to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If Timeout expires, and the operation is not yet complete,
the bean throws an exception.
Please note that by default, all timeouts are inactivity timeouts ,
i.e. the timeout period is extended by Timeout seconds when
any amount of data is successfully sent or received.
Optionally, the behavior of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum
of Timeout seconds since the beginning of the operation, without
extending the timeout period during communications.
This behavior is controlled by the ipworksssl.Oauth#config configuration setting.
The default value for the {@link ipworksssl.Oauth#getTimeout Timeout} property is 60 (seconds).
IPWorksSSLExceptionpublic byte[] getTransferredData()
This property contains the contents of the last response from the server. If the LocalFile is empty, the data is accumulated in TransferredData , and can also be received in the Transfer event. Otherwise, this property returns an empty string.
TransferredDataLimit controls the maximum amount of data accumulated in TransferredData (by default there is no limit).
public long getTransferredDataLimit()
This property contains the maximum of data to be transferred. The default value is 0, which will not impose any limits on the amount of data accumulated in the TransferredData property.
public void setTransferredDataLimit(long transferredDataLimit)
throws IPWorksSSLException
This property contains the maximum of data to be transferred. The default value is 0, which will not impose any limits on the amount of data accumulated in the TransferredData property.
IPWorksSSLExceptionpublic java.lang.String getTransferredHeaders()
This property returns the complete set of raw headers as received from the server.
The Header event shows the individual headers as parsed by the bean.
public void addCookie(java.lang.String cookieName,
java.lang.String cookieValue)
throws IPWorksSSLException
This property adds a cookie and the corresponding value to the outgoing request headers.
Please refer to the Cookies property for more information on cookies and how they are managed.
IPWorksSSLException
public void addParam(java.lang.String paramName,
java.lang.String paramValue)
throws IPWorksSSLException
This method can be used to add query string parameters to the outgoing request. One common
use for this method would be to add the "state" parameter to the request, which can be used
when the ClientProfile is cfWebServer to add user defined data. The authorization server
will include the "state" parameter in the response and will be available in the post back to
your server which will allow you to maintain state in your application.
IPWorksSSLException
public java.lang.String config(java.lang.String configurationString)
throws IPWorksSSLException
{@link ipworksssl.Oauth#config Config} is a generic method available in every bean. It is used to set and retrieve {@link ipworksssl.Oauth#config configuration settingsfor the bean.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the bean, access to these internal properties is provided through the {@link ipworksssl.Oauth#config Config} method.
To set a configuration setting named PROPERTY , you must call Config("PROPERTY=VALUE") , where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a {@link ipworksssl.Oauth#config configuration setting, you must call Config("PROPERTY") . The value will be returned as a string.
The bean accepts one or more of the following configuration settings . Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the bean, access to these internal properties is provided through the {@link ipworksssl.Oauth#config Config} method.
{@link ipworksssl.Oauth#config is used in conjunction with the {@link ipworksssl.Oauth#config field in order to specify client certificates.
Designations of certificate stores are platform-dependent.
The following are designations of the most common User and Machine certificate stores in Windows:
In Java, the certificate store normally is a file containing certificates and optional private keys.
When the certificate store type is PFXFile, this property must be set to the name of the file. When the type is PFXBlob, the property must be set to the binary contents of a PFX file (i.e. PKCS12 certificate store).
If the provider is OpenSSL, the certificate store is a file containing a certificate and a private key. This property must be set to the name of the file.
Note: This is only applicable when {@link ipworksssl.Oauth#config is set to True.
The certificate subject is a comma separated list of distinguished name fields and values. For instance "CN=www.server.com, OU=test, C=US, E=support@nsoftware.com". Common fields and their meanings are displayed below.
If a field value contains a comma it must be quoted.
Note: This is only applicable when {@link ipworksssl.Oauth#config is set to True.
The {@link ipworksssl.Oauth#getAuthScheme AuthScheme} property defines the authentication scheme used. In the case of HTTP Basic Authentication (default), every time {@link ipworksssl.Oauth#getUser User} and {@link ipworksssl.Oauth#getPassword Password} are set, they are Base64 encoded, and the result is put in the Authorization property in the form "Basic [encoded-user-password]".
Note that following the HTTP specification, unless this option is set to 1 (Always), automatic redirects will be performed only for 'GET' or 'HEAD' requests. Other methods could potentially change the conditions of the initial request and create security vulnerabilities.
Furthermore, if either the new URL server and port are different than the existing one, {@link ipworksssl.Oauth#getUser User} and {@link ipworksssl.Oauth#getPassword Password} are also reset to empty, unless this property is set to 1 (Always), in which case the same credentials are used to connect to the new server.
A {@link ipworksssl.OauthRedirectEvent Redirect} event is fired for every URL the product is redirected to. In the case of automatic redirections, the {@link ipworksssl.OauthRedirectEvent Redirect} event is a good place to set properties related to the new connection (e.g. new authentication parameters).
The default value is 0 (Never). In this case, redirects are never followed, and the bean throws an exception instead.
Valid options are:
NOTE: This functionality is only available in Java and .NET.
NOTE: This functionality is only available in Java and .NET.
Use this configuration option with caution. If this configuration option contains invalid headers, HTTP requests may fail.
This configuration option is useful for extending the functionality of the bean beyond what is provided.
NOTE: This is the same as Host . This setting is provided for use by beans that do not directly expose Firewall properties.
{@link ipworksssl.Oauth#getRemotePort RemotePort} is the port in which the firewall will listen to. If set to 0, the firewall will select a random port. The binding (address and port) is provided through the {@link ipworksssl.OauthConnectionStatusEvent ConnectionStatus} event.
The connection to the firewall is made by calling the {@link ipworksssl.Oauth#connect Connect} method.
In the second scenario, {@link ipworksssl.Oauth#config is a positive value, the system will attempt to send pending data until the specified {@link ipworksssl.Oauth#config is reached. If this attempt fails, then the system will reset the connection.
The default behavior (which is also the default mode for stream sockets) might result in a long delay in closing the connection. Although the bean returns control immediately, the system could hold system resources until all pending data is sent (even after your application closes).
Setting this property to False forces an immediate disconnection. If you know that the other side has received all the data you sent (by a client acknowledgment, for example), setting this property to False might be the appropriate course of action.
If the bean is connected, the {@link ipworksssl.Oauth#getLocalHost LocalHost} setting shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multi-homed hosts (machines with more than one IP interface).
{@link ipworksssl.Oauth#getLocalPort LocalPort} cannot be changed once a connection is made. Any attempt to set this when a connection is active will generate an error.
This; setting is useful when trying to connect to services that require a trusted port in the client side. An example is the remote shell (rsh) service in UNIX systems.
If no {@link ipworksssl.Oauth#getEOL EOL} is found, and {@link ipworksssl.Oauth#config bytes are accumulated in the buffer, the {@link ipworksssl.OauthDataInEvent DataIn} event is fired with the EOL parameter set to False, and the buffer is reset.
The minimum value for {@link ipworksssl.Oauth#config is 256 bytes. The default value is 2048 bytes. The maximum value is 65536 bytes.
Use this setting with caution. Requesting a lower cipher strength than necessary could potentially cause serious security vulnerabilities in your application.
When the provider is OpenSSL, SSLCipherStrength is currently not supported. This functionality is instead made available through the {@link ipworksssl.Oauth#config config setting.
When the provider is OpenSSL, SSLCipherStrength is currently not supported. This functionality is instead made available through the {@link ipworksssl.Oauth#config config setting.
TLS 1.1 and TLS1.2 support are only available starting with Windows 7.
The special value "*" (default) picks the default SSL provider defined in the system.
Note: On Windows systems, the default SSL Provider is "Microsoft Unified Security Protocol Provider" and cannot be changed.
The special value "*" means that the component will pick all of the supported cipher suites. If SSLEnabledCipherSuites is set to any other value, only the specified cipher suites will be considered.
Multiple cipher suites are separated by semicolons.
Example values:
obj.config("SSLEnabledCipherSuites=*");
obj.config("SSLEnabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA");
obj.config("SSLEnabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA; SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA"); Possible values include:
SSLEnabledCipherSuites is used together with SSLCipherStrength .
Note: This configuration setting is available only in .NET and Java.
obj.Config("SSLEnabledProtocols=3072"); // TLS1.2 (supports SHA_256)
obj.Config("SSLAlgorithmList=CALG_SHA_256;CALG_MD5"); Possible values include:
This option is only valid in Windows.
IPWorksSSLException
public void doEvents()
throws IPWorksSSLException
When DoEvents is called, the bean processes any
available events. If no events are available, it waits for a
preset period of time, and then returns.
IPWorksSSLException
public java.lang.String getAuthorization()
throws IPWorksSSLException
This method performs several operations automatically depending on the value of ClientProfile .
Please see the introduction section for the OAUTH bean for a detailed overview
of the typical scenarios.
After authorization is completed this method will return the authorization string which can be passed directly to the Authorization property of any other component. This can also be passed as the value of the HTTP Authorization header to other implementations that access the protected resource as well.
IPWorksSSLException
public java.lang.String getAuthorizationURL()
throws IPWorksSSLException
When this method is called, the bean will return the URL used for authorization. The bean
will not make any connections itself, but instead return the URL to you so that you may re-direct the user
to this location. This is useful when ClientProfile is set to cfWebServer.
Before calling this method set:
ClientId ClientSecret ReturnURL AuthorizationScope (optional)
IPWorksSSLException
public void interrupt()
throws IPWorksSSLException
If there is no method in progress, Interrupt simply returns, doing nothing.
IPWorksSSLException
public void reset()
throws IPWorksSSLException
This method will reset the bean properties to their default value when called.
IPWorksSSLException
public void startWebServer()
throws IPWorksSSLException
Starts the embedded web server. This method can be used to manually start the embedded web server.
Under normal circumstances this is not needed as the component will automatically start and stop
the web server when GetAuthorization is called. However, you may decide to start the web server
manually before calling GetAuthorization . When called this method will also populate ReturnURL with the address of the embedded server.
IPWorksSSLException
public void stopWebServer()
throws IPWorksSSLException
Stops the embedded web server. Under normal circumstances the web server will be stopped automatically
during the authorization process when GetAuthorization is called. If {@link ipworksssl.Oauth#config is set to true the server will not be automatically stopped, and this method must be called to
stop the embedded web server.
IPWorksSSLException
public void addOauthEventListener(OauthEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removeOauthEventListener(OauthEventListener l)
|
IP*Works! SSL V9 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||