Class P3BindSession
- java.lang.Object
-
- com.isode.x400api.Session
-
- com.isode.x400.highlevel.P3BindSession
-
- Direct Known Subclasses:
P7BindSession
public class P3BindSession extends Session
Abstracts the connection used for submission to a P3 channel and/or P7 message store The documentation in the examples here refer to P3 channel. The class MStore extends this class and adds P7 Message Store specific methods, like listing the content of a mailbox, deleting messages, etc.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.concurrent.Semaphore
available
protected boolean
bound
Boolean value that represents if the session is bound or notprotected java.lang.String
credentials
The password for the P3 userprotected boolean
disable_config_requests
Disable configuration requests in MS bind operationsprotected java.lang.String
pa
Presentation Address of the P3 channelprotected boolean
sec_init
Boolean value that represents if the security environment has been initialized or notprotected java.lang.String
user_dn
P3 user DNprotected java.lang.String
user_oraddr
P3 user O/R address
-
Constructor Summary
Constructors Constructor Description P3BindSession(java.lang.String presentation_address, java.lang.String or_addr, java.lang.String passwd)
Create a P3BindSessionP3BindSession(java.lang.String presentation_address, java.lang.String or_addr, java.lang.String passwd, boolean submit_only)
Create a P3BindSession, specifying whether the session should be used for Submission only or not.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
acquireSemaphore()
void
bind()
Bind to the P3 channelSession
getSession()
Retrieve the Session objectboolean
isBound()
Check if this session is bound or not.ReceiveMsg
receiveNextAvailableMessage()
Receive the "next available message" from the Message Storeprotected void
releaseSemaphore()
void
setDisableConfigRequest(boolean b)
Enables or disables the request of configuration from the MTA or Message Store.void
setSecurityEnv(java.lang.String id, java.lang.String id_dn, java.lang.String pass)
Set the session's security environment data.void
setSecurityEnvPKCS12(java.lang.String pkcs12FileName, java.lang.String password, java.lang.String sec_trusted_ca_cert_dir)
Set the session's security environment data.void
setUserDN(java.lang.String my_user_dn)
Set the P3 channel user's DNvoid
unbind()
Unbind from the P3 channel or P7 Message Store.void
unbind(boolean force)
Unbind from the P3 channel or P7 Message Store.int
waitForNewMessages(int seconds)
Wait for a new message the specified number of seconds.-
Methods inherited from class com.isode.x400api.Session
cancelWait, enableWait, GetNumMsgs, GetSummarizeOnBind, SetSummarizeOnBind
-
-
-
-
Field Detail
-
pa
protected java.lang.String pa
Presentation Address of the P3 channel
-
user_oraddr
protected java.lang.String user_oraddr
P3 user O/R address
-
user_dn
protected java.lang.String user_dn
P3 user DN
-
credentials
protected java.lang.String credentials
The password for the P3 user
-
disable_config_requests
protected boolean disable_config_requests
Disable configuration requests in MS bind operations
-
bound
protected boolean bound
Boolean value that represents if the session is bound or not
-
sec_init
protected boolean sec_init
Boolean value that represents if the security environment has been initialized or not
-
available
protected static final java.util.concurrent.Semaphore available
-
-
Constructor Detail
-
P3BindSession
public P3BindSession(java.lang.String presentation_address, java.lang.String or_addr, java.lang.String passwd)
Create a P3BindSession- Parameters:
presentation_address
- the P3 channel's Presentation Address Typical values are "593"/Internet=myserver.mycompany.comor_addr
- the string encoded O/R address of the P3 channel user. For example /"cn=John Smith, o=Address Book, o=Isode, c=GB"passwd
- the P3 channel's password that correspond to the user
-
P3BindSession
public P3BindSession(java.lang.String presentation_address, java.lang.String or_addr, java.lang.String passwd, boolean submit_only)
Create a P3BindSession, specifying whether the session should be used for Submission only or not.- Parameters:
presentation_address
- the P3 channel's Presentation Address Typical values are "593"/Internet=myserver.mycompany.comor_addr
- the string encoded O/R address of the P3 channel user. For example /"cn=John Smith, o=Address Book, o=Isode, c=GB"passwd
- the P3 channel's password that correspond to the usersubmit_only
- Set to true if this session is only to be used for submission
-
-
Method Detail
-
setUserDN
public void setUserDN(java.lang.String my_user_dn) throws BadDNException
Set the P3 channel user's DNThis is the string encoded O/R address of the user. For example /"cn=John Smith, o=Address Book, o=Isode, c=GB"
- Throws:
BadDNException
-
setDisableConfigRequest
public void setDisableConfigRequest(boolean b)
Enables or disables the request of configuration from the MTA or Message Store. This will be needed by some non-Isode Message Stores or MTAs, like the Deutsche Telekom service.- Parameters:
b
-
-
acquireSemaphore
protected void acquireSemaphore() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
releaseSemaphore
protected void releaseSemaphore()
-
bind
public void bind() throws X400APIException
Bind to the P3 channel- Throws:
X400APIException
-
getSession
public Session getSession()
Retrieve the Session object- Returns:
- A Session object. This is the object that is need to, for example, read or create a message
-
isBound
public boolean isBound()
Check if this session is bound or not.This means that the application think it is still bound to the server, but bear in mind that the connection may have been dropped by the server for any number of reasons, and this application won't be informed.
- Returns:
- Returns true if the session bind() was successful and unbind() was not called.
-
unbind
public void unbind() throws X400APIException
Unbind from the P3 channel or P7 Message Store.Closes the connection to the the P3 channel or P7 Message Store. No more messages can be sent or received until a new connection is open.
- Throws:
X400APIException
-
unbind
public void unbind(boolean force) throws X400APIException
Unbind from the P3 channel or P7 Message Store.Closes the connection to the the P3 channel or P7 Message Store. No more messages can be sent or received until a new connection is open.
- Parameters:
force
- ignore InterruptedException when acquiring semaphore- Throws:
X400APIException
-
setSecurityEnv
public void setSecurityEnv(java.lang.String id, java.lang.String id_dn, java.lang.String pass) throws X400APIException
Set the session's security environment data.The information is passed on to the underlying API, but is not checked at this stage. This means that the information may be invalid, but won't be noticed until later on.
- Parameters:
pkcs12file
- - The absolute path of the PKCS#12 file with the user certificatepkcs12password
- - The password for the PKCS#12 user certificatesec_trusted_ca_cert_dir
- - The directory where the trusted certificates for the CAs are kept- Throws:
X400APIException
-
setSecurityEnvPKCS12
public void setSecurityEnvPKCS12(java.lang.String pkcs12FileName, java.lang.String password, java.lang.String sec_trusted_ca_cert_dir) throws X400APIException
Set the session's security environment data.The information is passed on to the underlying API, but is not checked at this stage. This means that the information may be invalid, but won't be noticed until later on.
- Parameters:
pkcs12FileName
- String : The PKCS#12 file that corresponds to this user, containing it's O/R addresspassword
- String : Passphrase to open the PKCS#12 filesec_trusted_ca_cert_dir
- : the directory where the CA's trusted certificates are kept (optional)- Throws:
X400APIException
- Since:
- 15.0
-
receiveNextAvailableMessage
public ReceiveMsg receiveNextAvailableMessage() throws X400APIException
Receive the "next available message" from the Message Store- Throws:
X400APIException
-
waitForNewMessages
public int waitForNewMessages(int seconds) throws X400APIException
Wait for a new message the specified number of seconds. If seconds is 0, then there's no wait. If seconds is negative, then the delay is indefinite.- Parameters:
seconds
-- Returns:
X400_att.X400_E_NOERROR if there were no errors and a message is ready to be read
X400_att.X400_E_TIMED_OUT: if no messages arrived in the specified number of seconds
X400_att.X400_E_NO_MESSAGE: if there are no more messages to read
- Throws:
X400APIException
-
-