Moving micasa 1.5 trunk to Novell forge.
This commit is contained in:
		
							
								
								
									
										86
									
								
								c_jwrapper/src/com/novell/casa/MiCasa.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								c_jwrapper/src/com/novell/casa/MiCasa.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,86 @@ | ||||
| /** | ||||
|  * Created by IntelliJ IDEA. | ||||
|  * User: jnorman@novell.com | ||||
|  * Date: Apr 19, 2005 | ||||
|  * Time: 9:45:02 AM | ||||
|  * To change this template use Options | File Templates. | ||||
|  */ | ||||
| package com.novell.casa; | ||||
|  | ||||
| public class MiCasa { | ||||
|  | ||||
|     public static int USERNAME_TYPE_CN_F			 = 0x00000000; | ||||
|     public static int USERNAME_TYPE_NDS_DN_F		 = 0x00000001; | ||||
|     public static int USERNAME_TYPE_NDS_FDN_F		 = 0x00000002; | ||||
|     public static int USERNAME_TYPE_LDAP_DN_F		 = 0x00000004; | ||||
|     public static int USERNAME_TYPE_EMAIL_F			 = 0x00000008; | ||||
|     public static int USERNAME_TYPE_OTHER_F			 = 0x00000010; | ||||
|  | ||||
|     public static native int jmiCASASetCredential( | ||||
|             int iSSFlags, | ||||
|             String sAppSecretID, | ||||
|             String sSharedSecretID, | ||||
|             int unFlag, | ||||
|             String sUsername, | ||||
|             String sPassword | ||||
|             ); | ||||
|  | ||||
|     public static native int jmiCASAGetCredential( | ||||
|             int iSSFlags, | ||||
|             String sAppSecretID, | ||||
|             String sSharedSecretID, | ||||
|             int unFlag, | ||||
|             NetCredential credential | ||||
|             ); | ||||
|  | ||||
|     public static native int jmiCASARemoveCredential( | ||||
|             int iSSFlags, | ||||
|             String sAppSecretID, | ||||
|             String sSharedSecretID | ||||
|             ); | ||||
|  | ||||
|     // ********************************************************************************************** | ||||
|     static { | ||||
|         System.loadLibrary("jmicasa"); | ||||
|     } | ||||
|  | ||||
|     public static void setCredential(int iSSFlags, | ||||
|                                      String sAppSecretID, | ||||
|                                      String sSharedSecretID, | ||||
|                                      int iUserFlag, | ||||
|                                      String sUsername, | ||||
|                                      String sPassword) throws Exception { | ||||
|  | ||||
|         int rcode = 0; | ||||
|         rcode = jmiCASASetCredential(iSSFlags, sAppSecretID, sSharedSecretID, iUserFlag, sUsername, sPassword); | ||||
|         if (rcode != 0) { | ||||
|             throw new MiCasaException(rcode); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static NetCredential getCredential(int iSSFlags, | ||||
|                                               String sAppSecretID, | ||||
|                                               String sSharedSecretID, | ||||
|                                               int iUserFlag) throws Exception { | ||||
|         int rcode = 0; | ||||
|         NetCredential netCred = new NetCredential(); | ||||
|         rcode = jmiCASAGetCredential(iSSFlags, sAppSecretID, sSharedSecretID, iUserFlag, netCred); | ||||
|         if (rcode != 0) { | ||||
|             throw new MiCasaException(rcode); | ||||
|         } | ||||
|  | ||||
|         return netCred; | ||||
|     } | ||||
|  | ||||
|     public static void removeCredential(int iSSFlags, | ||||
|                                         String sAppSecretID, | ||||
|                                         String sSharedSecretID) throws Exception { | ||||
|         int rcode = 0; | ||||
|         rcode = jmiCASARemoveCredential(iSSFlags, sAppSecretID, sSharedSecretID); | ||||
|         if (rcode != 0) { | ||||
|             throw new MiCasaException(rcode); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										805
									
								
								c_jwrapper/src/com/novell/casa/MiCasaException.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										805
									
								
								c_jwrapper/src/com/novell/casa/MiCasaException.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,805 @@ | ||||
| /** | ||||
|  * Created by IntelliJ IDEA. | ||||
|  * User: admin | ||||
|  * Date: Jun 7, 2005 | ||||
|  * Time: 4:25:07 PM | ||||
|  * To change this template use Options | File Templates. | ||||
|  */ | ||||
| package com.novell.casa; | ||||
|  | ||||
| public class MiCasaException extends RuntimeException | ||||
| { | ||||
|    /** | ||||
|     * Can't find the target object DN in NDS. | ||||
|     * | ||||
|     * @since 3.0 | ||||
|     */ | ||||
|    public static final short NSSCS_E_OBJECT_NOT_FOUND = 0xFFFFFCE0; /* -800 */ | ||||
|  | ||||
|    /** | ||||
|     * NICI operations have failed. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NICI_FAILURE = 0xFFFFFCDF; /* -801 */ | ||||
|  | ||||
|    /** | ||||
|     * Secret ID is not in the User Secret Store. | ||||
|     */ | ||||
|    public static final short NSSCS_E_INVALID_SECRET_ID = 0xFFFFFCDE; /* -802 */ | ||||
|  | ||||
|    /** | ||||
|     * Some internal operating system services have not been available. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SYSTEM_FAILURE = 0xFFFFFCDD; /* -803 */ | ||||
|  | ||||
|    /** | ||||
|     * Access to the target SecretStore has been denied. | ||||
|     */ | ||||
|    public static final short NSSCS_E_ACCESS_DENIED = 0xFFFFFCDC; /* -804 */ | ||||
|  | ||||
|    /** | ||||
|     * Some internal NDS services have not been available. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NDS_INTERNAL_FAILURE = 0xFFFFFCDB; /* -805 */ | ||||
|  | ||||
|    /** | ||||
|     * Secret has not been initialized with a write. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SECRET_UNINITIALIZED = 0xFFFFFCDA; /* -806 */ | ||||
|  | ||||
|    /** | ||||
|     * Size of the buffer is not in a nominal range between minimum and maximum. | ||||
|     */ | ||||
|    public static final short NSSCS_E_BUFFER_LEN = 0xFFFFFCD9; /* -807 */ | ||||
|  | ||||
|    /** | ||||
|     * Client and server components are not of the compatible versions. | ||||
|     */ | ||||
|    public static final short NSSCS_E_INCOMPATIBLE_VERSION = 0xFFFFFCD8; /* -808 */ | ||||
|  | ||||
|    /** | ||||
|     * SecretStore data on the server has been corrupted. | ||||
|     */ | ||||
|    public static final short NSSCS_E_CORRUPTED_STORE = 0xFFFFFCD7; /* -809 */ | ||||
|  | ||||
|    /** | ||||
|     * Secret ID already exists in the Secret Store. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SECRET_ID_EXISTS = 0xFFFFFCD6; /* -810 */ | ||||
|  | ||||
|    /** | ||||
|     * User NDS password has been changed by the administrator. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NDS_PWORD_CHANGED = 0xFFFFFCD5; /* -811 */ | ||||
|  | ||||
|    /** | ||||
|     * Target NDS User object not found. | ||||
|     */ | ||||
|    public static final short NSSCS_E_INVALID_TARGET_OBJECT = 0xFFFFFCD4; /* -812 */ | ||||
|  | ||||
|    /** | ||||
|     * Target NDS User object does not have a SecretStore. | ||||
|     */ | ||||
|    public static final short NSSCS_E_STORE_NOT_FOUND = 0xFFFFFCD3; /* -813 */ | ||||
|  | ||||
|    /** | ||||
|     * SecretStore not on the Network. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SERVICE_NOT_FOUND = 0xFFFFFCD2; /* -814 */ | ||||
|  | ||||
|    /** | ||||
|     * Length of the Secret ID buffer exceeds the limit. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SECRET_ID_TOO_LONG = 0xFFFFFCD1; /* -815 */ | ||||
|  | ||||
|    /** | ||||
|     * User not authenticated. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NOT_AUTHENTICATED = 0xFFFFFCCF; /* -817 */ | ||||
|  | ||||
|    /** | ||||
|     * Not supported operations. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NOT_SUPPORTED = 0xFFFFFCCE; /* -818 */ | ||||
|  | ||||
|    /** | ||||
|     * Typed in NDS password not valid. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NDS_PWORD_INVALID = 0xFFFFFCCD; /* -819 */ | ||||
|  | ||||
|    /** | ||||
|     * Length of the Enumeration buffer too short. | ||||
|     */ | ||||
|    public static final short NSSCS_E_ENUM_BUFF_TOO_SHORT = 0xFFFFFCD0; /* -816 */ | ||||
|  | ||||
|    /** | ||||
|     * Session keys of the client and server NICI are out of sync. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NICI_OUTOF_SYNC = 0xFFFFFCCC; /* -820 */ | ||||
|  | ||||
|    /** | ||||
|     * Requested service not supported yet. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SERVICE_NOT_SUPPORTED = 0xFFFFFCCB; /* -821 */ | ||||
|  | ||||
|    /** | ||||
|     * NDS authentication type not supported. | ||||
|     */ | ||||
|    public static final short NSSCS_E_TOKEN_NOT_SUPPORTED = 0xFFFFFCCA; /* -822 */ | ||||
|  | ||||
|    /** | ||||
|     * Unicode text conversion operation failed. | ||||
|     */ | ||||
|    public static final short NSSCS_E_UNICODE_OP_FAILURE = 0xFFFFFCC9; /* -823 */ | ||||
|  | ||||
|    /** | ||||
|     * Connection to server is lost. | ||||
|     */ | ||||
|    public static final short NSSCS_E_TRANSPORT_FAILURE = 0xFFFFFCC8; /* -824 */ | ||||
|  | ||||
|    /** | ||||
|     * Cryptographic operation failed. | ||||
|     */ | ||||
|    public static final short NSSCS_E_CRYPTO_OP_FAILURE = 0xFFFFFCC7; /* -825 */ | ||||
|  | ||||
|    /** | ||||
|     * Opening a connection to the server failed. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SERVER_CONN_FAILURE = 0xFFFFFCC6; /* -826 */ | ||||
|  | ||||
|    /** | ||||
|     * Access to server connection failed. | ||||
|     */ | ||||
|    public static final short NSSCS_E_CONN_ACCESS_FAILURE = 0xFFFFFCC5; /* -827 */ | ||||
|  | ||||
|    /** | ||||
|     * Size of the enumeration buffer exceeds the limit. | ||||
|     */ | ||||
|    public static final short NSSCS_E_ENUM_BUFF_TOO_LONG = 0xFFFFFCC4; /* -828 */ | ||||
|  | ||||
|    /** | ||||
|     * Size of the Secret buffer exceeds the limit. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SECRET_BUFF_TOO_LONG = 0xFFFFFCC3; /* -829 */ | ||||
|  | ||||
|    /** | ||||
|     * Length of the Secret ID should be greater than zero. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SECRET_ID_TOO_SHORT = 0xFFFFFCC2; /* -830 */ | ||||
|  | ||||
|    /** | ||||
|     * Protocol data corrupted on the wire. | ||||
|     */ | ||||
|    public static final short NSSCS_E_CORRUPTED_PACKET_DATA = 0xFFFFFCC1; /* -831 */ | ||||
|  | ||||
|    /** | ||||
|     * EP password validation failed. Access to the secret denied! | ||||
|     */ | ||||
|    public static final short NSSCS_E_EP_ACCESS_DENIED = 0xFFFFFCC0; /* -832 */ | ||||
|  | ||||
|    /** | ||||
|     * Schema is not extended to support SecreStore on the target tree. | ||||
|     */ | ||||
|    public static final short NSSCS_E_SCHEMA_NOT_EXTENDED = 0xFFFFFCBF; /* -833 */ | ||||
|  | ||||
|    /** | ||||
|     * One of the optional service attributes is not instantiated. | ||||
|     */ | ||||
|    public static final short NSSCS_E_ATTR_NOT_FOUND = 0xFFFFFCBE; /* -834 */ | ||||
|  | ||||
|    /** | ||||
|     * Server has been upgraded and user SecretStore should be updated. | ||||
|     */ | ||||
|    public static final short NSSCS_E_MIGRATION_NEEDED = 0xFFFFFCBD; /* -835 */ | ||||
|  | ||||
|    /** | ||||
|     * Master password could not be verified to read or unlock the secrets. | ||||
|     */ | ||||
|    public static final short NSSCS_E_MP_PWORD_INVALID = 0xFFFFFCBC; /* -836 */ | ||||
|  | ||||
|    /** | ||||
|     * Master password has not been set on the SecretStore. | ||||
|     */ | ||||
|    public static final short NSSCS_E_MP_PWORD_NOT_SET = 0xFFFFFCBB; /* -837 */ | ||||
|  | ||||
|    /** | ||||
|     * Ability to use master password has been disabled. | ||||
|     */ | ||||
|    public static final short NSSCS_E_MP_PWORD_NOT_ALLOWED = 0xFFFFFCBA; /* -838 */ | ||||
|  | ||||
|    /** | ||||
|     * Not a writeable replica of NDS. | ||||
|     */ | ||||
|    public static final short NSSCS_E_WRONG_REPLICA_TYPE = 0xFFFFFCB9; /* -839 */ | ||||
|  | ||||
|    /** | ||||
|     * Target attribute is not instantiated in NDS. | ||||
|     * | ||||
|     * @since 3.0 | ||||
|     */ | ||||
|    public static final short NSSCS_E_ATTR_VAL_NOT_FOUND = 0xFFFFFCB8; /* -840 */ | ||||
|  | ||||
|    /** | ||||
|     * API parameter is not initialized. | ||||
|     * | ||||
|     * @since 3.0 | ||||
|     */ | ||||
|    public static final short NSSCS_E_INVALID_PARAM = 0xFFFFFCB7; /* -841 */ | ||||
|  | ||||
|    /** | ||||
|     * Connection to SecretStore needs to be over SSL. | ||||
|     * | ||||
|     * @since 3.0 | ||||
|     */ | ||||
|    public static final short NSSCS_E_NEED_SECURE_CHANNEL = 0xFFFFFCB6; /* -842 */ | ||||
|  | ||||
|    /** | ||||
|     * No server to support the given override configuration is found. | ||||
|     * | ||||
|     * @since 3.02 | ||||
|     */ | ||||
|    public static final short NSSCS_E_CONFIG_NOT_SUPPORTED = 0xFFFFFCB5; /* -843 */ | ||||
|  | ||||
|    /** | ||||
|     * Attempt to unlock SecretStore failed because the store is not locked. | ||||
|     * | ||||
|     * @since 3.02 | ||||
|     */ | ||||
|    public static final short NSSCS_E_STORE_NOT_LOCKED = 0xFFFFFCB4; /* -844 */ | ||||
|  | ||||
|    /** | ||||
|     * NDS Replica on the server that holds SecretStore is out of sync with the replica ring. | ||||
|     * | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public static final short NSSCS_E_TIME_OUT_OF_SYNC = 0xFFFFFCB3; /* -845 */ | ||||
|  | ||||
|    /** | ||||
|     * Versions of the client dlls don't match. | ||||
|     * | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public static final short NSSCS_E_VERSION_MISMATCH = 0xFFFFFCB2; /* -846 */ | ||||
|  | ||||
|    /** | ||||
|     * Buffer supplied for the secret is too short. | ||||
|     * | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public static final short NSSCS_E_SECRET_BUFF_TOO_SHORT = 0xFFFFFCB1; /* -847 */ | ||||
|  | ||||
|    /** | ||||
|     * Shared Secret processing and operations failed. | ||||
|     * | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public static final short NSSCS_E_SH_SECRET_FAILURE = 0xFFFFFCB0; /* -848 */ | ||||
|  | ||||
|    /** | ||||
|     * Shared Secret parser operations failed. | ||||
|     * | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public static final short NSSCS_E_PARSER_FAILURE = 0xFFFFFCAF; /* -849 */ | ||||
|  | ||||
|    /** | ||||
|     * Utf8 string operations failed. | ||||
|     * | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public static final short NSSCS_E_UTF8_OP_FAILURE = 0xFFFFFCAE; /* -850 */ | ||||
|  | ||||
|    /** | ||||
|     * Contextless name for LDAP bind does not resolve to a unique DN. | ||||
|     * | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public static final short NSSCS_E_CTX_LESS_CN_NOT_UNIQUE = 0xFFFFFCAD; /* -851 */ | ||||
|  | ||||
|    /** | ||||
|     * Feature not implemented yet. | ||||
|     */ | ||||
|    public static final short NSSCS_E_NOT_IMPLEMENTED = 0xFFFFFC88; /* -888 */ | ||||
|  | ||||
|    /** | ||||
|     * Product's BETA life has expired! Official release copy should be purchased. | ||||
|     */ | ||||
|    public static final short NSSCS_E_BETA_EXPIRED = 0xFFFFFC7D; /* -899 */ | ||||
|  | ||||
|    /** | ||||
|     * The error code. | ||||
|     */ | ||||
|    protected int err; | ||||
|  | ||||
|    /** | ||||
|     * Determines if this object has a root exception. | ||||
|     */ | ||||
|    protected boolean hasRoot; | ||||
|  | ||||
|    /** | ||||
|     * The root Throwable. | ||||
|     */ | ||||
|    protected Throwable root; | ||||
|  | ||||
|    /** | ||||
|     * Constructs an empty SSException object. The error code is set to | ||||
|     * the 0. | ||||
|     */ | ||||
|    public MiCasaException() | ||||
|    { | ||||
|       super(""); | ||||
|       err = 0; | ||||
|       root = this; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Constructs a SSException according to the error code. | ||||
|     * | ||||
|     * @param errCode The error code. | ||||
|     */ | ||||
|    public MiCasaException(int errCode) | ||||
|    { | ||||
|       super(generateMessage(errCode)); | ||||
|       err = errCode; | ||||
|       root = this; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Generates a SSException with the specified message. | ||||
|     * | ||||
|     * @param errCode The SecretStore error code. | ||||
|     * @param message The exception message. | ||||
|     */ | ||||
|    public MiCasaException(int errCode, String message) | ||||
|    { | ||||
|       super(message); | ||||
|       err = errCode; | ||||
|       root = this; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Generates a SSException object that encapsulates the specified exception. | ||||
|     * The error code is set to 0. The message from the | ||||
|     * encapsulated exception is set as the message for this object. | ||||
|     * | ||||
|     * @param root The Throwable that is encapsulated in this object as the root. | ||||
|     */ | ||||
|    public MiCasaException(Throwable root) | ||||
|    { | ||||
|       this(0, root.getMessage()); | ||||
|       hasRoot = true; | ||||
|       this.root = root; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Generates a SSException object that encapsulates the specified exception as | ||||
|     * its root. The error code is set to 0. The message from the root exception | ||||
|     * is set as the message for this object. The additional message is appended to | ||||
|     * the end of the encapsulated exception's message with a whitspace seperating | ||||
|     * them. | ||||
|     * | ||||
|     * @param root The Throwable that is encapsulated in this object as the root. | ||||
|     * @param message An additional message. | ||||
|     */ | ||||
|    public MiCasaException(Throwable root, String message) | ||||
|    { | ||||
|       this(0, message + " " + root.getMessage()); | ||||
|       hasRoot = true; | ||||
|       this.root = root; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Generates a SSException object that encapsulates the specified exception as | ||||
|     * its root. The message from the root exception | ||||
|     * is set as the message for this object. The root message is appended to | ||||
|     * the end of the message with a whitspace seperating them. | ||||
|     * | ||||
|     * @param errCode The SecretStore error code. | ||||
|     * @param root The Throwable that is encapsulated in this object as the root. | ||||
|     * @param errCode An additional message. | ||||
|     * @since 3.2 | ||||
|     */ | ||||
|    public MiCasaException(int errCode, Throwable root) | ||||
|    { | ||||
|       this(errCode, generateMessage(errCode) + " " + root.getMessage()); | ||||
|       err = errCode; | ||||
|       hasRoot = true; | ||||
|       this.root = root; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Returns the message associated with the error code. Note that the returned | ||||
|     * value is not translated. | ||||
|     * | ||||
|     * @param errCode The Error Code. | ||||
|     * @return String The message. | ||||
|     */ | ||||
|    public static final String generateMessage(int errCode) | ||||
|    { | ||||
|       switch (errCode) | ||||
|       { | ||||
|          case NSSCS_E_OBJECT_NOT_FOUND: | ||||
|             return "Can't find the target object DN in NDS"; | ||||
|  | ||||
|          case NSSCS_E_NICI_FAILURE: | ||||
|             return "NICI operations have failed"; | ||||
|  | ||||
|          case NSSCS_E_INVALID_SECRET_ID: | ||||
|             return "Secret ID is not in the User Secret Store"; | ||||
|  | ||||
|          case NSSCS_E_SYSTEM_FAILURE: | ||||
|             return "Some internal operating system services have not been available"; | ||||
|  | ||||
|          case NSSCS_E_ACCESS_DENIED: | ||||
|             return "Access to the target SecretStore has been denied"; | ||||
|  | ||||
|          case NSSCS_E_NDS_INTERNAL_FAILURE: | ||||
|             return "Some internal NDS services have not been available"; | ||||
|  | ||||
|          case NSSCS_E_SECRET_UNINITIALIZED: | ||||
|             return "Secret has not been initialized with a write"; | ||||
|  | ||||
|          case NSSCS_E_BUFFER_LEN: | ||||
|             return "Size of the buffer is not in a nominal range between minimum and maximum"; | ||||
|  | ||||
|          case NSSCS_E_INCOMPATIBLE_VERSION: | ||||
|             return "Client and server components are not of the compatible versions"; | ||||
|  | ||||
|          case NSSCS_E_CORRUPTED_STORE: | ||||
|             return "SecretStore data on the server has been corrupted"; | ||||
|  | ||||
|          case NSSCS_E_SECRET_ID_EXISTS: | ||||
|             return "Secret ID is already in SecretStore"; | ||||
|  | ||||
|          case NSSCS_E_NDS_PWORD_CHANGED: | ||||
|             return "User NDS password has been changed by the administrator"; | ||||
|  | ||||
|          case NSSCS_E_INVALID_TARGET_OBJECT: | ||||
|             return "Target NDS User object not found"; | ||||
|  | ||||
|          case NSSCS_E_STORE_NOT_FOUND: | ||||
|             return "Target NDS User object does not have a SecretStore"; | ||||
|  | ||||
|          case NSSCS_E_SERVICE_NOT_FOUND: | ||||
|             return "SecretStore not on the Network"; | ||||
|  | ||||
|          case NSSCS_E_SECRET_ID_TOO_LONG: | ||||
|             return "Length of the Secret ID buffer exceeds the limit"; | ||||
|  | ||||
|          case NSSCS_E_ENUM_BUFF_TOO_SHORT: | ||||
|             return "Length of the Enumeration buffer too short"; | ||||
|  | ||||
|          case NSSCS_E_NOT_AUTHENTICATED: | ||||
|             return "User not authenticated"; | ||||
|  | ||||
|          case NSSCS_E_NOT_SUPPORTED: | ||||
|             return "Not supported operations"; | ||||
|  | ||||
|          case NSSCS_E_NDS_PWORD_INVALID: | ||||
|             return "Typed in NDS password not valid"; | ||||
|  | ||||
|          case NSSCS_E_NICI_OUTOF_SYNC: | ||||
|             return "Session keys of the client and server NICI are out of sync"; | ||||
|  | ||||
|          case NSSCS_E_SERVICE_NOT_SUPPORTED: | ||||
|             return "Requested service not supported yet"; | ||||
|  | ||||
|          case NSSCS_E_TOKEN_NOT_SUPPORTED: | ||||
|             return "NDS authentication type not supported"; | ||||
|  | ||||
|          case NSSCS_E_UNICODE_OP_FAILURE: | ||||
|             return "Unicode text conversion operation failed"; | ||||
|  | ||||
|          case NSSCS_E_TRANSPORT_FAILURE: | ||||
|             return "Connection to server is lost"; | ||||
|  | ||||
|          case NSSCS_E_CRYPTO_OP_FAILURE: | ||||
|             return "Cryptographic operation failed"; | ||||
|  | ||||
|          case NSSCS_E_SERVER_CONN_FAILURE: | ||||
|             return "Opening a connection to the server failed"; | ||||
|  | ||||
|          case NSSCS_E_CONN_ACCESS_FAILURE: | ||||
|             return "Access to server connection failed"; | ||||
|  | ||||
|          case NSSCS_E_ENUM_BUFF_TOO_LONG: | ||||
|             return "Size of the enumeration buffer exceeds the limit"; | ||||
|  | ||||
|          case NSSCS_E_SECRET_BUFF_TOO_LONG: | ||||
|             return "Size of the Secret buffer exceeds the limit"; | ||||
|  | ||||
|          case NSSCS_E_SECRET_ID_TOO_SHORT: | ||||
|             return "Length of the Secret ID should be greater than zero"; | ||||
|  | ||||
|          case NSSCS_E_CORRUPTED_PACKET_DATA: | ||||
|             return "Protocol data corrupted on the wire"; | ||||
|  | ||||
|          case NSSCS_E_EP_ACCESS_DENIED: | ||||
|             return "EP password validation failed. Access to the secret denied"; | ||||
|  | ||||
|          case NSSCS_E_SCHEMA_NOT_EXTENDED: | ||||
|             return "Schema is not extended to support SecreStore on the target tree"; | ||||
|  | ||||
|          case NSSCS_E_ATTR_NOT_FOUND: | ||||
|             return "One of the optional service attributes is not instantiated"; | ||||
|  | ||||
|          case NSSCS_E_MIGRATION_NEEDED: | ||||
|             return "Server has been upgraded and user SecretStore should be updated"; | ||||
|  | ||||
|          case NSSCS_E_MP_PWORD_INVALID: | ||||
|             return "Master password could not be verified to read or unlock the secrets"; | ||||
|  | ||||
|          case NSSCS_E_MP_PWORD_NOT_SET: | ||||
|             return "Master password has not been set on the SecretStore"; | ||||
|  | ||||
|          case NSSCS_E_MP_PWORD_NOT_ALLOWED: | ||||
|             return "Ability to use master password has been disabled"; | ||||
|  | ||||
|          case NSSCS_E_WRONG_REPLICA_TYPE: | ||||
|             return "Not a writeable replica of NDS"; | ||||
|  | ||||
|          case NSSCS_E_ATTR_VAL_NOT_FOUND: | ||||
|             return "Target attribute is not instantiated in NDS"; | ||||
|  | ||||
|          case NSSCS_E_INVALID_PARAM: | ||||
|             return "API parameter is not initialized"; | ||||
|  | ||||
|          case NSSCS_E_NEED_SECURE_CHANNEL: | ||||
|             return "Connection to SecretStore needs to be over SSL"; | ||||
|  | ||||
|          case NSSCS_E_CONFIG_NOT_SUPPORTED: | ||||
|             return "No server to support the given override configuration is found"; | ||||
|  | ||||
|          case NSSCS_E_STORE_NOT_LOCKED: | ||||
|             return "Attempt to unlock SecretStore failed because the store is not locked"; | ||||
|  | ||||
|          case NSSCS_E_TIME_OUT_OF_SYNC: | ||||
|             return "NDS Replica on the server that holds SecretStore is out of sync with the replica ring"; | ||||
|  | ||||
|          case NSSCS_E_VERSION_MISMATCH: | ||||
|             return "Versions of the client dlls don't match"; | ||||
|  | ||||
|          case NSSCS_E_SECRET_BUFF_TOO_SHORT: | ||||
|             return "Buffer supplied for the secret is too short"; | ||||
|  | ||||
|          case NSSCS_E_SH_SECRET_FAILURE: | ||||
|             return "Shared Secret processing and operations failed"; | ||||
|  | ||||
|          case NSSCS_E_PARSER_FAILURE: | ||||
|             return "Shared Secret parser operations failed"; | ||||
|  | ||||
|          case NSSCS_E_UTF8_OP_FAILURE: | ||||
|             return "Utf8 string operations failed"; | ||||
|  | ||||
|          case NSSCS_E_CTX_LESS_CN_NOT_UNIQUE: | ||||
|             return "Contextless name for LDAP bind does not resolve to a unique DN"; | ||||
|  | ||||
|          case NSSCS_E_NOT_IMPLEMENTED: | ||||
|             return "Feature not implemented yet"; | ||||
|  | ||||
|          case NSSCS_E_BETA_EXPIRED: | ||||
|             return "Product's BETA life has expired! Official release copy should be purchased"; | ||||
|       } | ||||
|  | ||||
|       return ""; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Returns the error code. | ||||
|     * | ||||
|     * @return int - The error code. | ||||
|     */ | ||||
|    public int getErrorCode() | ||||
|    { | ||||
|       return err; | ||||
|    } | ||||
|  | ||||
|     /* | ||||
|    public String getLocalizedMessage() | ||||
|    { | ||||
|       try | ||||
|       { | ||||
|          if (SecretStore.resourceBundle != null) | ||||
|          { | ||||
|             switch (err) | ||||
|             { | ||||
|                case NSSCS_E_OBJECT_NOT_FOUND: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_OBJECT_NOT_FOUND"); | ||||
|  | ||||
|                case NSSCS_E_NICI_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NICI_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_INVALID_SECRET_ID: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_INVALID_SECRET_ID"); | ||||
|  | ||||
|                case NSSCS_E_SYSTEM_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SYSTEM_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_ACCESS_DENIED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_ACCESS_DENIED"); | ||||
|  | ||||
|                case NSSCS_E_NDS_INTERNAL_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NDS_INTERNAL_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_SECRET_UNINITIALIZED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SECRET_UNINITIALIZED"); | ||||
|  | ||||
|                case NSSCS_E_BUFFER_LEN: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_BUFFER_LEN"); | ||||
|  | ||||
|                case NSSCS_E_INCOMPATIBLE_VERSION: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_INCOMPATIBLE_VERSION"); | ||||
|  | ||||
|                case NSSCS_E_CORRUPTED_STORE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_CORRUPTED_STORE"); | ||||
|  | ||||
|                case NSSCS_E_SECRET_ID_EXISTS: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SECRET_ID_EXISTS"); | ||||
|  | ||||
|                case NSSCS_E_NDS_PWORD_CHANGED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NDS_PWORD_CHANGED"); | ||||
|  | ||||
|                case NSSCS_E_INVALID_TARGET_OBJECT: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_INVALID_TARGET_OBJECT"); | ||||
|  | ||||
|                case NSSCS_E_STORE_NOT_FOUND: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_STORE_NOT_FOUND"); | ||||
|  | ||||
|                case NSSCS_E_SERVICE_NOT_FOUND: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SERVICE_NOT_FOUND"); | ||||
|  | ||||
|                case NSSCS_E_SECRET_ID_TOO_LONG: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SECRET_ID_TOO_LONG"); | ||||
|  | ||||
|                case NSSCS_E_ENUM_BUFF_TOO_SHORT: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_ENUM_BUFF_TOO_SHORT"); | ||||
|  | ||||
|                case NSSCS_E_NOT_AUTHENTICATED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NOT_AUTHENTICATED"); | ||||
|  | ||||
|                case NSSCS_E_NOT_SUPPORTED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NOT_SUPPORTED"); | ||||
|  | ||||
|                case NSSCS_E_NDS_PWORD_INVALID: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NDS_PWORD_INVALID"); | ||||
|  | ||||
|                case NSSCS_E_NICI_OUTOF_SYNC: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NICI_OUTOF_SYNC"); | ||||
|  | ||||
|                case NSSCS_E_SERVICE_NOT_SUPPORTED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SERVICE_NOT_SUPPORTED"); | ||||
|  | ||||
|                case NSSCS_E_TOKEN_NOT_SUPPORTED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_TOKEN_NOT_SUPPORTED"); | ||||
|  | ||||
|                case NSSCS_E_UNICODE_OP_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_UNICODE_OP_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_TRANSPORT_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_TRANSPORT_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_CRYPTO_OP_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_CRYPTO_OP_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_SERVER_CONN_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SERVER_CONN_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_CONN_ACCESS_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_CONN_ACCESS_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_ENUM_BUFF_TOO_LONG: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_ENUM_BUFF_TOO_LONG"); | ||||
|  | ||||
|                case NSSCS_E_SECRET_BUFF_TOO_LONG: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SECRET_BUFF_TOO_LONG"); | ||||
|  | ||||
|                case NSSCS_E_SECRET_ID_TOO_SHORT: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SECRET_ID_TOO_SHORT"); | ||||
|  | ||||
|                case NSSCS_E_CORRUPTED_PACKET_DATA: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_CORRUPTED_PACKET_DATA"); | ||||
|  | ||||
|                case NSSCS_E_EP_ACCESS_DENIED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_EP_ACCESS_DENIED"); | ||||
|  | ||||
|                case NSSCS_E_SCHEMA_NOT_EXTENDED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SCHEMA_NOT_EXTENDED"); | ||||
|  | ||||
|                case NSSCS_E_ATTR_NOT_FOUND: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_ATTR_NOT_FOUND"); | ||||
|  | ||||
|                case NSSCS_E_MIGRATION_NEEDED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_MIGRATION_NEEDED"); | ||||
|  | ||||
|                case NSSCS_E_MP_PWORD_INVALID: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_MP_PWORD_INVALID"); | ||||
|  | ||||
|                case NSSCS_E_MP_PWORD_NOT_SET: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_MP_PWORD_NOT_SET"); | ||||
|  | ||||
|                case NSSCS_E_MP_PWORD_NOT_ALLOWED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_MP_PWORD_NOT_ALLOWED"); | ||||
|  | ||||
|                case NSSCS_E_WRONG_REPLICA_TYPE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_WRONG_REPLICA_TYPE"); | ||||
|  | ||||
|                case NSSCS_E_ATTR_VAL_NOT_FOUND: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_NSSCS_E_ATTR_VAL_NOT_FOUND"); | ||||
|  | ||||
|                case NSSCS_E_INVALID_PARAM: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_NSSCS_E_INVALID_PARAM"); | ||||
|  | ||||
|                case NSSCS_E_NEED_SECURE_CHANNEL: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NEED_SECURE_CHANNEL"); | ||||
|  | ||||
|                case NSSCS_E_CONFIG_NOT_SUPPORTED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_CONFIG_NOT_SUPPORTED"); | ||||
|  | ||||
|                case NSSCS_E_STORE_NOT_LOCKED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_STORE_NOT_LOCKED"); | ||||
|  | ||||
|                case NSSCS_E_TIME_OUT_OF_SYNC: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_TIME_OUT_OF_SYNC"); | ||||
|  | ||||
|                case NSSCS_E_VERSION_MISMATCH: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_VERSION_MISMATCH"); | ||||
|  | ||||
|                case NSSCS_E_SECRET_BUFF_TOO_SHORT: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SECRET_BUFF_TOO_SHORT"); | ||||
|  | ||||
|                case NSSCS_E_SH_SECRET_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_SH_SECRET_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_PARSER_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_PARSER_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_UTF8_OP_FAILURE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_UTF8_OP_FAILURE"); | ||||
|  | ||||
|                case NSSCS_E_CTX_LESS_CN_NOT_UNIQUE: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_CTX_LESS_CN_NOT_UNIQUE"); | ||||
|  | ||||
|                case NSSCS_E_NOT_IMPLEMENTED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_NOT_IMPLEMENTED"); | ||||
|  | ||||
|                case NSSCS_E_BETA_EXPIRED: | ||||
|                   return SecretStore.resourceBundle.getString("NSSCS_E_BETA_EXPIRED"); | ||||
|             } | ||||
|          } | ||||
|       } | ||||
|       catch (Exception e) | ||||
|       { | ||||
|          //do nothing | ||||
|       } | ||||
|  | ||||
|       return getMessage(); | ||||
|    } | ||||
|    */ | ||||
|  | ||||
|    /** | ||||
|     * Returns the root exception of this object. Objects of this type may not | ||||
|     * always have a root exception. This method will return this object if | ||||
|     * this object does not have a root exception. Use the method | ||||
|     * hasRoot to determine if objects of this class have | ||||
|     * a root exception. | ||||
|     * | ||||
|     * @return Throwable - The root. | ||||
|     * @see #hasRoot() | ||||
|     */ | ||||
|    public Throwable getRoot() | ||||
|    { | ||||
|       return root; | ||||
|    } | ||||
|  | ||||
|    /** | ||||
|     * Determines if this exception has a root exception. Returns true if it | ||||
|     * has a root exception, false if not. | ||||
|     * | ||||
|     * @return boolean - True if this object has a root exception, false if not. | ||||
|     * @see #getRoot() | ||||
|     */ | ||||
|    public boolean hasRoot() | ||||
|    { | ||||
|       return hasRoot; | ||||
|    } | ||||
|  | ||||
| } | ||||
							
								
								
									
										42
									
								
								c_jwrapper/src/com/novell/casa/MiCasaTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								c_jwrapper/src/com/novell/casa/MiCasaTest.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| /** | ||||
|  * Created by IntelliJ IDEA. | ||||
|  * User: admin | ||||
|  * Date: Apr 19, 2005 | ||||
|  * Time: 9:52:58 AM | ||||
|  * To change this template use Options | File Templates. | ||||
|  */ | ||||
| package com.novell.casa; | ||||
|  | ||||
| public class MiCasaTest { | ||||
|  | ||||
|         public static void main(String[] args) | ||||
|     { | ||||
|         MiCasa store = new MiCasa(); | ||||
|  | ||||
|             try { | ||||
|                 store.setCredential(0, "JavaAppID", null, 0, "javaAppID Username", "javaAppID Password"); | ||||
|                 store.setCredential(0, "JavaAppID", "Network", 0, "javaAppID Username", "javaAppID Password"); | ||||
|                 store.setCredential(0, "Groupwise", null, 0, "groupwise Username", "gw Password"); | ||||
|  | ||||
|                 NetCredential nc = store.getCredential(0, "Groupwise", null, 0); | ||||
|                 System.out.println("Username: "+nc.getUsername()); | ||||
|                 System.out.println("Password: "+nc.getPassword()); | ||||
|  | ||||
|                 store.removeCredential(0, "Groupwise", null); | ||||
|  | ||||
|                 try { | ||||
|                     nc = store.getCredential(0, "Groupwise", null, 0); | ||||
|                 } catch (Exception e) { | ||||
|                     e.printStackTrace();  //To change body of catch statement use Options | File Templates. | ||||
|                 } | ||||
|  | ||||
|  | ||||
|                 nc = store.getCredential(0, "nonexist2", null, 0); | ||||
|                 System.out.println("Username: "+nc.getUsername()); | ||||
|                 System.out.println("Password: "+nc.getPassword()); | ||||
|  | ||||
|             } catch (Exception e) { | ||||
|                 e.printStackTrace();  //To change body of catch statement use Options | File Templates. | ||||
|             } | ||||
|         } | ||||
| } | ||||
							
								
								
									
										46
									
								
								c_jwrapper/src/com/novell/casa/NetCredential.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								c_jwrapper/src/com/novell/casa/NetCredential.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| /** | ||||
|  * Created by IntelliJ IDEA. | ||||
|  * User: admin | ||||
|  * Date: Apr 19, 2005 | ||||
|  * Time: 9:48:14 AM | ||||
|  * To change this template use Options | File Templates. | ||||
|  */ | ||||
| package com.novell.casa; | ||||
|  | ||||
| public class NetCredential { | ||||
|  | ||||
|     private String m_sUsername = ""; | ||||
|     private String m_sPassword = ""; | ||||
|  | ||||
|     public void NetCredential(String username, String password) | ||||
|     { | ||||
|         m_sUsername = username; | ||||
|         m_sPassword = password; | ||||
|     } | ||||
|  | ||||
|     public String getUsername() | ||||
|     { | ||||
|         return m_sUsername; | ||||
|     } | ||||
|  | ||||
|     public String getPassword() | ||||
|     { | ||||
|         return m_sPassword; | ||||
|     } | ||||
|  | ||||
|     public void setUsername(String sUsername) | ||||
|     { | ||||
|         if (sUsername != null) | ||||
|         { | ||||
|             m_sUsername = sUsername; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setPassword(String sPassword) | ||||
|     { | ||||
|         if (sPassword != null) | ||||
|         { | ||||
|             m_sPassword = sPassword; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user