Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.acl
Class ACL

    java.lang.Object
      com.knowgate.acl.ACL

    public final class ACL

extends java.lang.Object

Top Level User Authentication and Access Control List Functions.

Field Summary
`static short` | `ACCOUNT_CANCELLED`
`static short` | `ACCOUNT_DEACTIVATED`
`static short` | `CAPTCHA_MISMATCH`
`static short` | `CAPTCHA_TIMEOUT`
`static short` | `DOMAIN_NOT_FOUND`
`static short` | `INTERNAL_ERROR`
`static short` | `INVALID_PASSWORD`
`static short` | `PASSWORD_EXPIRED`
`static int` | `PERMISSION_ADD`
`static int` | `PERMISSION_DELETE`
`static int` | `PERMISSION_FULL_CONTROL`
`static int` | `PERMISSION_GRANT`
`static int` | `PERMISSION_LIST`
`static int` | `PERMISSION_MODERATE`
`static int` | `PERMISSION_MODIFY`
`static int` | `PERMISSION_READ`
`static int` | `PERMISSION_SEND`
`static int` | `PWD_CLEAR_TEXT`
`static int` | `PWD_DTIP_RC4`
`static int` | `PWD_DTIP_RC4_64`
`static int` | `ROLE_ADMIN`
`static int` | `ROLE_GUEST`
`static int` | `ROLE_NONE`
`static int` | `ROLE_POWERUSER`
`static int` | `ROLE_USER`
`static short` | `SESSION_EXPIRED`
`static short` | `USER_NOT_FOUND`
`static short` | `WORKAREA_ACCESS_DENIED`
`static short` | `WORKAREA_NOT_FOUND`
`static short` | `WORKAREA_NOT_SET`

Constructor Summary
`ACL()` Default Constructor

Method Summary
`static short` | `autenticate(JDCConnection oConn, java.lang.String sUserId, java.lang.String sAuthStr, int iFlags)` Checks whether or not password is valid for given user.
`static short` | `autenticate(JDCConnection oConn, java.lang.String sUserId, java.lang.String sAuthStr, int iFlags, long lTimestamp, long lTimeout, java.lang.String sPlainCaptcha, java.lang.String sPlainCaptchaMD5)` Checks password and captcha for a given user This method calls k_sp_autenticate stored procedure witch looks up tx_pwd field at k_users table and see if it is the same as sAuthStr parameter.
`static short` | `checkCaptcha(long lTimestamp, long lTimeout, java.lang.String sPlainCaptcha, java.lang.String sPlainCaptchaMD5)` Check if a captcha matches its signature and it has not expired
`static java.lang.String` | `decript(java.lang.String sStr, int iFlags)` Decrypt String
`static java.lang.String` | `encript(java.lang.String sStr, int iFlags)` Encrypt String
`static java.lang.String` | `getErrorMessage(short iErrCode)`
`static java.lang.String` | `getLocalizedMaskName(int iACLMask, java.lang.String sLanguage)` Gets permissions mask descriptive name for given language
`static java.lang.String` | `getRC4key()` Get RC4 default key for encryption Since version 4.0, the RC4 key may be readed from file acl.cnf instead of being just hardwired inside ACL Java class as a private static variable.
`static java.lang.String` | `getUserIdFromNick(JDCConnection oConn, java.lang.String sNickName, int iDomain)` Get user unique id given its nickname.
`static java.lang.String` | `RC4EnDeCrypt(java.lang.String sTxt)` Encrypt text using RC4 algorithm and a default encryption key
`static java.lang.String` | `RC4EnDeCrypt(java.lang.String sTxt, java.lang.String sKey)` Encrypt text using RC4 algorithm
`static void` | `setRC4key(java.lang.String sKey)` Set RC4 default key for encryption

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PERMISSION_LIST

    public static final int PERMISSION_LIST

See Also:
  Constant Field Values

### PERMISSION_READ

    public static final int PERMISSION_READ

See Also:
  Constant Field Values

### PERMISSION_ADD

    public static final int PERMISSION_ADD

See Also:
  Constant Field Values

### PERMISSION_DELETE

    public static final int PERMISSION_DELETE

See Also:
  Constant Field Values

### PERMISSION_MODIFY

    public static final int PERMISSION_MODIFY

See Also:
  Constant Field Values

### PERMISSION_MODERATE

    public static final int PERMISSION_MODERATE

See Also:
  Constant Field Values

### PERMISSION_SEND

    public static final int PERMISSION_SEND

See Also:
  Constant Field Values

### PERMISSION_GRANT

    public static final int PERMISSION_GRANT

See Also:
  Constant Field Values

### PERMISSION_FULL_CONTROL

    public static final int PERMISSION_FULL_CONTROL

See Also:
  Constant Field Values

### ROLE_NONE

    public static final int ROLE_NONE

See Also:
  Constant Field Values

### ROLE_ADMIN

    public static final int ROLE_ADMIN

See Also:
  Constant Field Values

### ROLE_POWERUSER

    public static final int ROLE_POWERUSER

See Also:
  Constant Field Values

### ROLE_USER

    public static final int ROLE_USER

See Also:
  Constant Field Values

### ROLE_GUEST

    public static final int ROLE_GUEST

See Also:
  Constant Field Values

### PWD_CLEAR_TEXT

    public static final int PWD_CLEAR_TEXT

See Also:
  Constant Field Values

### PWD_DTIP_RC4

    public static final int PWD_DTIP_RC4

See Also:
  Constant Field Values

### PWD_DTIP_RC4_64

    public static final int PWD_DTIP_RC4_64

See Also:
  Constant Field Values

### USER_NOT_FOUND

    public static final short USER_NOT_FOUND

See Also:
  Constant Field Values

### INVALID_PASSWORD

    public static final short INVALID_PASSWORD

See Also:
  Constant Field Values

### ACCOUNT_DEACTIVATED

    public static final short ACCOUNT_DEACTIVATED

See Also:
  Constant Field Values

### SESSION_EXPIRED

    public static final short SESSION_EXPIRED

See Also:
  Constant Field Values

### DOMAIN_NOT_FOUND

    public static final short DOMAIN_NOT_FOUND

See Also:
  Constant Field Values

### WORKAREA_NOT_FOUND

    public static final short WORKAREA_NOT_FOUND

See Also:
  Constant Field Values

### WORKAREA_NOT_SET

    public static final short WORKAREA_NOT_SET

See Also:
  Constant Field Values

### ACCOUNT_CANCELLED

    public static final short ACCOUNT_CANCELLED

See Also:
  Constant Field Values

### PASSWORD_EXPIRED

    public static final short PASSWORD_EXPIRED

See Also:
  Constant Field Values

### CAPTCHA_MISMATCH

    public static final short CAPTCHA_MISMATCH

See Also:
  Constant Field Values

### CAPTCHA_TIMEOUT

    public static final short CAPTCHA_TIMEOUT

See Also:
  Constant Field Values

### WORKAREA_ACCESS_DENIED

    public static final short WORKAREA_ACCESS_DENIED

See Also:
  Constant Field Values

### INTERNAL_ERROR

    public static final short INTERNAL_ERROR

See Also:
  Constant Field Values

Constructor Detail

### ACL

    public ACL()

  Default Constructor

Method Detail

### checkCaptcha

    public static short checkCaptcha(long lTimestamp,
                                     long lTimeout,
                                     java.lang.String sPlainCaptcha,
                                     java.lang.String sPlainCaptchaMD5)

  Check if a captcha matches its signature and it has not expired

  Parameters:
    `lTimestamp` - Timestamp (in miliseconds) when sPlainCaptcha was generated
    `lTimemout` - Number of miliseconds after which sPlainCaptcha expires
    `sPlainCaptcha` - Captcha plain text
    `sPlainCaptchaMD5` - Precomputed MD5 hash for String sPlainCaptcha+ACL.getRC4key()
  Returns:
    - 0 (zero) means that the given key correspond to the captcha text and that it has not expired
    - ACL.CAPTCHA_MISMATCH The computed MD5 hash for sPlainCaptcha+lTimestamp does not match sTimeCaptchaMD5
    - ACL.CAPTCHA_TIMEOUT lTimestamp+lTimeout is before current datetime
  Since:
    4.0

### autenticate

    public static short autenticate(JDCConnection oConn,
                                    java.lang.String sUserId,
                                    java.lang.String sAuthStr,
                                    int iFlags)
                             throws java.sql.SQLException,
                                    java.lang.UnsupportedOperationException

  Checks whether or not password is valid for given user.

  This method calls k_sp_autenticate stored procedure witch looks up tx_pwd field at k_users table and see if it is the same as sAuthStr parameter.

  Parameters:
    `oConn` - Opened Database Connection
    `sUserId` - User GUID
    `sAuthStr` - Authentication String (password)
    `iFlags` - Authentication String Flags
    - ACL.PWD_CLEAR_TEXT Authentication String is passed as clear text (no encryption)
    - ACL.PWD_DTIP_RC4 Authentication String is given encrypted using RC4 algorithm
    - ACL.PWD_DTIP_RC4_64 Authentication String is given encrypted using RC4 algorithm and base64 encoded
  Returns:
    - ACL.USER_NOT_FOUND sUserId not found at gu_user field from k_users table
    - ACL.INVALID_PASSWORD sAuthStr parameter does not match tx_pwd field from k_users for sUserId
    - ACL.PASSWORD_EXPIRED Password has expired (dt_pwd_expires field value is before current date)
    - ACL.ACCOUNT_DEACTIVATED User account as been deactivated (field bo_active from k_users table set to zero)
    - ACL.ACCOUNT_CANCELLED User account as been cancelled (field dt_cancel from k_users table set to date before now)
    - ACL.INTERNAL_ERROR Internal error while trying to autenticate user
  Throws:
    `java.sql.SQLException`
    `java.lang.UnsupportedOperationException` - If k_sp_autenticate stored procedure is not found

### autenticate

    public static short autenticate(JDCConnection oConn,
                                    java.lang.String sUserId,
                                    java.lang.String sAuthStr,
                                    int iFlags,
                                    long lTimestamp,
                                    long lTimeout,
                                    java.lang.String sPlainCaptcha,
                                    java.lang.String sPlainCaptchaMD5)
                             throws java.sql.SQLException,
                                    java.lang.UnsupportedOperationException

  Checks password and captcha for a given user

  This method calls k_sp_autenticate stored procedure witch looks up tx_pwd field at k_users table and see if it is the same as sAuthStr parameter.

  Also it checks that the given captcha text corresponds to its signature and that it has not expired.

  Parameters:
    `oConn` - Opened Database Connection
    `sUserId` - User GUID
    `sAuthStr` - Authentication String (password)
    `iFlags` - Authentication String Flags
    `lTimestamp` - Timestamp (in miliseconds) when sPlainCaptcha was generated
    `lTimemout` - Number of miliseconds after which sPlainCaptcha expires
    `sPlainCaptcha` - Captcha plain text
    `sPlainCaptchaMD5` - Precomputed MD5 hash for String sPlainCaptcha+ACL.getRC4key()
  Returns:
    This method returns the same values as autenticate(JDCConnection,String,String,int) and also
    - ACL.CAPTCHA_MISMATCH The computed MD5 hash for sPlainCaptcha+lTimestamp does not match sTimeCaptchaMD5
    - ACL.CAPTCHA_TIMEOUT lTimestamp+lTimeout is before current datetime
  Throws:
    `java.sql.SQLException`
    `java.lang.UnsupportedOperationException` - If k_sp_autenticate stored procedure is not found
  Since:
    2.2

### decript

    public static java.lang.String decript(java.lang.String sStr,
                                           int iFlags)
                                    throws java.lang.IllegalArgumentException,
                                           java.lang.NullPointerException

  Decrypt String

  Parameters:
    `sStr` - Base64 encoded string to be decriptted
    `iFlags` - Encryption flags
    - ACL.PWD_CLEAR_TEXT Do not encrypt sStr (return as it is given)
    - ACL.PWD_DTIP_RC4 Encrypt using RC4 algorithm
    - ACL.PWD_DTIP_RC4_64 Decrypt by decoding base64 input and then using RC4 algorithm
  Returns:
    Decrypted string
  Throws:
    `java.lang.NullPointerException` - if sStr is null
    `java.lang.IllegalArgumentException` - if iFlags!=PWD_CLEAR_TEXT AND iFlags!=PWD_DTIP_RC4 AND iFlags!=PWD_DTIP_RC4_64
  Since:
    4.0

### encript

    public static java.lang.String encript(java.lang.String sStr,
                                           int iFlags)
                                    throws java.lang.IllegalArgumentException,
                                           java.lang.NullPointerException

  Encrypt String

  Parameters:
    `sStr` - String to be encrypted
    `iFlags` - Encryption flags
    - ACL.PWD_CLEAR_TEXT Do not encrypt sStr (return as it is given)
    - ACL.PWD_DTIP_RC4 Encrypt using RC4 algorithm
    - ACL.PWD_DTIP_RC4_64 Encrypt using RC4 algorithm and then base64 encoding
  Returns:
    Encrypted string
  Throws:
    `java.lang.NullPointerException` - if sStr is null
    `java.lang.IllegalArgumentException` - if iFlags!=PWD_CLEAR_TEXT AND iFlags!=PWD_DTIP_RC4

### getUserIdFromNick

    public static java.lang.String getUserIdFromNick(JDCConnection oConn,
                                                     java.lang.String sNickName,
                                                     int iDomain)
                                              throws java.sql.SQLException

  Get user unique id given its nickname.

  Calls k_get_user_from_nick stored procedure and gets gu_user field from tx_nickname field

  Parameters:
    `oConn` - Database Connection
    `sNickName` - User nickname (tx_nickname from k_users table)
    `iDomain` - Domain Identifier (id_domain from k_users table)
  Returns:
    User Unique Identifier (gu_user from k_users table)
  Throws:
    `java.sql.SQLException`

### getRC4key

    public static java.lang.String getRC4key()

  Get RC4 default key for encryption

  Since version 4.0, the RC4 key may be readed from file acl.cnf instead of being just hardwired inside ACL Java class as a private static variable.

  Returns:
    The value of property RC4PWD from acl.cnf file or a default key if acl.cnf is not found or does not contain a RC4PWD property. If RC4PWD has been changed by calling setRC4key() then the new value is returned until the class is reloaded.

### setRC4key

    public static void setRC4key(java.lang.String sKey)

  Set RC4 default key for encryption

  Parameters:
    `sKey` -

### RC4EnDeCrypt

    public static java.lang.String RC4EnDeCrypt(java.lang.String sTxt)
                                         throws java.lang.NullPointerException

  Encrypt text using RC4 algorithm and a default encryption key

  Parameters:
    `sTxt` - Text to be encrypted
  Returns:
    String Encrypted text
  Throws:
    `java.lang.NullPointerException` - if sTxt is null
  See Also:
    `http://www.clarenceho.net:8123/blog/articles/2005/11/21/rc4-encryption-in-java-april-2003}`

### RC4EnDeCrypt

    public static java.lang.String RC4EnDeCrypt(java.lang.String sTxt,
                                                java.lang.String sKey)

  Encrypt text using RC4 algorithm

  Parameters:
    `sTxt` - Text to be encrypted
    `sKey` - Encryption key
  See Also:
    `http://www.clarenceho.net:8123/blog/articles/2005/11/21/rc4-encryption-in-java-april-2003}`

### getLocalizedMaskName

    public static java.lang.String getLocalizedMaskName(int iACLMask,
                                                        java.lang.String sLanguage)
                                                 throws java.lang.IllegalArgumentException

  Gets permissions mask descriptive name for given language

  Parameters:
    `iACLMask` - Permissions Mask, any combination of ACL.PERMISSION_ constants
    `sLanguage` - Language for localized string {"en", "es"}
  Returns:
  Throws:
    `java.lang.IllegalArgumentException`

### getErrorMessage

    public static java.lang.String getErrorMessage(short iErrCode)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD