public abstract class AS400CertificateUtil
extends java.lang.Object
implements java.io.Serializable
// Get certificates from the local system AS400 as400 = new AS400(); // Local variables AS400Certificate as400certificate; AS400Certificate[] certs; Vector certVector = new Vector(); byte[] handle; int numberCerts; String userName; try { AS400CertificateUserProfileUtil usrprf = new AS400CertificateUserProfileUtil(as400, "/QSYS.LIB/MYNAME.USRPRF"); AS400CertificateVldlUtil vldl = new AS400CertificateVldlUtil(as400, "/QSYS.LIB/MYLIB.LIB/TEST.VLDL"); AS400CertificateAttribute[] certAttribute = new AS400CertificateAttribute[2]; // Copy certificates that belong to both "US" and "myname". certAttribute[0] = new AS400CertificateAttribute(AS400CertificateAttribute.SUBJECT_COUNTRY, "US"); certAttribute[1] = new AS400CertificateAttribute(AS400CertificateAttribute.SUBJECT_COMMON_NAME, "myname"); // Copy matching certificates from the user profile to user space, MYSPACE. numberCerts = usrprf.listCertificates(certAttribute, "/QSYS.LIB/MYLIB.LIB/MYSPACE.USRSPC"); System.out.println("Number of certificates found = " + numberCerts); // Start reading certificates from the user space into AS400Certificate[]. // All complete certificates in the 8 Kbyte buffer will be returned. certs = usrprf.getCertificates("/QSYS.LIB/MYLIB.LIB/MYSPACE.USRSPC", 0, 8); // Continue to read the entire user space using 8 Kbyte buffer while (null != certs) { // Gather certificates in a vector for (int i = 0; i < certs.length; ++i) { certVector.addElement(certs[i]); } certs = usrprf.getNextCertificates(8); } // Add all the certificates to validation list object for (int i = 0; i < certVector.size(); ++i) { as400certificate = (AS400Certificate)certVector.elementAt(i); vldl.addCertificate(as400certificate.getEncoded()); } // Delete first certificate added to vldl using its handle as400certificate = (AS400Certificate)certVector.elementAt(0); handle = usrprf.getCertificateHandle(as400certificate.getEncoded()); vldl.deleteCertificateByHandle(handle); // Delete 2nd certificate added to vldl using entire ASN.1 certificate as400certificate = (AS400Certificate)certVector.elementAt(1); vldl.deleteCertificate(as400certificate.getEncoded()); // Display user profile name associated with the 1st certificate userName = usrprf.findCertificateUserByHandle(handle); System.out.println("User profile name = " + userName); } catch (Exception e) { System.out.println(e.toString()); }
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
Recommended buffer size in kilobytes.
|
static int |
MAX_BUFFER_SIZE
Maximum buffer size in kilobytes.
|
static int |
MIN_BUFFER_SIZE
Minimum buffer size in kilobytes.
|
Constructor and Description |
---|
AS400CertificateUtil()
Constructs an AS400CertificateUtil object.
|
AS400CertificateUtil(AS400 system,
java.lang.String path)
Constructs an AS400CertificateUtil object.
|
Modifier and Type | Method and Description |
---|---|
void |
addAS400CertificateListener(AS400CertificateListener listener)
Adds an AS400Certificate listener to receive AS400Certificate events.
|
abstract void |
addCertificate(byte[] certificate)
Adds the certificate to the repository.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener l)
Adds the VetoableChangeListener.
|
abstract void |
deleteCertificate(byte[] certificate)
Deletes the certificate from the repository.
|
abstract void |
deleteCertificateByHandle(byte[] certificatehandle)
Deletes the certificate from the repository.
|
byte[] |
getCertificateHandle(byte[] certificate)
Returns the IBM i certificate handle which uniquely identifies this certificate.
|
AS400Certificate[] |
getCertificates(java.lang.String userSpaceName,
int firstCertificateToReturn,
int buffSize)
Retrieves the certificate placed in a user space by listCertificates.
|
AS400Certificate[] |
getFirstCertificates(java.lang.String userSpaceName,
int buffSize)
Retrieves certificates placed in the user space by listCertificates starting at the first certificate in the user space.
|
java.lang.String |
getName()
Returns the name of the IBM i certificate repository.
|
AS400Certificate[] |
getNextCertificates(int buffSize)
Retrieves the next certificates placed in a user space by listCertificates.
|
java.lang.String |
getObjectInfo()
Returns free form object info.
|
java.lang.String |
getPath()
Returns the integrated file system path name of the IBM i certificate repository.
|
AS400 |
getSystem()
Returns the system object.
|
abstract int |
listCertificates(AS400CertificateAttribute[] certificateAttributes,
java.lang.String userSpaceName)
Returns certificates which match the specified attributes in the specified existing user space.
|
void |
removeAS400CertificateListener(AS400CertificateListener l)
Removes this listener.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes this property change listener.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener l)
Removes this vetoable change listener.
|
void |
setObjectInfo(java.lang.String information)
Set free form object information
|
abstract void |
setPath(java.lang.String path)
Sets the path for the user space.
|
void |
setSystem(AS400 system)
Sets the system on which the certificate repository exists.
|
public static final int DEFAULT_BUFFER_SIZE
public static final int MAX_BUFFER_SIZE
public static final int MIN_BUFFER_SIZE
public AS400CertificateUtil()
public AS400CertificateUtil(AS400 system, java.lang.String path)
system
- The system on which the certificate repository exists.path
- The fully qualified integrated file system path name of the validation list or user profile. For example, /QSYS.LIB/MYLIB.LIB/MYVLDL.VLDL or /QSYS.LIB/MYPROFILE.USRPRF.public abstract void addCertificate(byte[] certificate) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalArgumentException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
certificate
- The ASN.1 Certificate to be added to the repository.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIllegalArgumentException
- If invalid certificate.ExtendedIOException
- If certificate already added and other IBM i certificate access errors.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.public void addAS400CertificateListener(AS400CertificateListener listener)
listener
- The object listener.removeAS400CertificateListener(com.ibm.as400.access.AS400CertificateListener)
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
l
- The property change listener.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addVetoableChangeListener(java.beans.VetoableChangeListener l)
l
- The VetoableChangeListener.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public abstract void deleteCertificate(byte[] certificate) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalArgumentException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
certificate
- The ASN.1 Certificate to be deleted from the repository.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIllegalArgumentException
- If invalid certificate.ExtendedIOException
- If certificate not found and other IBM i certificate access errors.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.public abstract void deleteCertificateByHandle(byte[] certificatehandle) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalArgumentException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
certificatehandle
- The IBM i certificate handle of the certificate to be deleted from the repository.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIllegalArgumentException
- If invalid certificate handle.ExtendedIOException
- If certificate not found and other IBM i certificate access errors.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.public AS400Certificate[] getCertificates(java.lang.String userSpaceName, int firstCertificateToReturn, int buffSize) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalArgumentException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
userSpaceName
- The fully qualified integrated file system path name of the user space to get the certificates, for example, /QSYS.LIB/MYLIB.LIB/MYUSRSPC.USRSPC. The ten character AS4/00 library of the user space may also be specified as %CURLIB% or %LIBL%.
See QSYSObjectPathName
firstCertificateToReturn
- The first certificate in the user space to return. The first certificate in the user space is at location 0.buffSize
- The number of kilobytes allocated for the returned certificates. Increasing this value for remote invocations will require more client memory and longer transmission times. The recommended default buffer size is 128 kilobytes. The minimum buffer size allowed is 8 kilobytes.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIllegalArgumentException
- If buffer size out of range or too small for one certificate, firstCertificateToReturn set to more than the total number of certificates in user space, and other invalid input parameters.ExtendedIOException
- If no certificate returned, user space certificates not stored in format "CERT0100", and other IBM i certificate access errors.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.public byte[] getCertificateHandle(byte[] certificate) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
certificate
- The ASN.1 Certificate used to generate the handle.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIOException
- If invalid certificate and other IBM i certificate access errors.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.public AS400Certificate[] getFirstCertificates(java.lang.String userSpaceName, int buffSize) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalArgumentException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
userSpaceName
- The fully qualified integrated file system path name of the user space to get the certificates, for example, /QSYS.LIB/MYLIB.LIB/MYUSRSPC.USRSPC. The ten character library of the user space may also be specified as %CURLIB% or %LIBL%.
See QSYSObjectPathName
buffSize
- The number of kilobytes allocated for the returned certificates.
Increasing this value for remote invocations will require more client memory and longer transmission times. The recommended default buffer size is 128 kilobytes. The minimum buffer size allowed is 8 kilobytes.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIllegalArgumentException
- If buffer size out of range or too small for one certificate and other invalid input parameters.ExtendedIOException
- If no certificate returned, user space certificates not stored in format "CERT0100", and other IBM i certificate access errors.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.public java.lang.String getName()
public AS400Certificate[] getNextCertificates(int buffSize) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalArgumentException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
buffSize
- The number of kiloBytes allocated for the returned certificates. Increasing this value for remote invocations will require more client memory and longer transmission times. The minimum buffer size allowed is 8 kilobytes.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIllegalArgumentException
- If buffer size out of range or too small for one certificate.ExtendedIOException
- If certificates are not in "CERT0100" format in the user space, user space and initial certificate to return are not set by calling getCertificates or getFirstCertificates, and other IBM i certificate access errors.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.listCertificates(com.ibm.as400.access.AS400CertificateAttribute[], java.lang.String)
public java.lang.String getObjectInfo()
public java.lang.String getPath()
public AS400 getSystem()
public abstract int listCertificates(AS400CertificateAttribute[] certificateAttributes, java.lang.String userSpaceName) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalArgumentException, ExtendedIOException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
certificateAttributes
- The list of attributes the certificate must match.
A value of null places all certificates from the repository into the user space.
An empty String or empty byte array search attribute will search for certificates
that do not have this attribute. For example, SUBJECT_ORGANIZATION = new String("") will
search for certificates without the subject organization field.
Null search attributes are ignored.userSpaceName
- The fully qualified integrated file system path name of the user space to put the list results, for example, /QSYS.LIB/MYLIB.LIB/MYUSRSPC.USRSPC. The ten character library of the user space may also be specified as %CURLIB% or %LIBL%.
See QSYSObjectPathName
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.ExtendedIllegalArgumentException
- If invalid search attributes or input parameter.ExtendedIOException
- If IBM i certificate access error.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the IBM i object does not exist.public void removeAS400CertificateListener(AS400CertificateListener l)
l
- The AS400CertificateListener.addAS400CertificateListener(com.ibm.as400.access.AS400CertificateListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
l
- The property change listener.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void removeVetoableChangeListener(java.beans.VetoableChangeListener l)
l
- The VetoableChangeListener.addVetoableChangeListener(java.beans.VetoableChangeListener)
public void setObjectInfo(java.lang.String information)
information
- The free form info.public abstract void setPath(java.lang.String path) throws java.beans.PropertyVetoException
path
- The fully qualified integrated file system path name.java.beans.PropertyVetoException
- If the change is vetoed.public void setSystem(AS400 system) throws java.beans.PropertyVetoException
system
- The system on which the repository exists.java.beans.PropertyVetoException
- If the change is vetoed.