spartime.code
Class EncodeurSpartimeService

java.lang.Object
  extended by spartime.code.EncodeurSpartimeService

public class EncodeurSpartimeService
extends java.lang.Object

This class is a wrapper allowing the computation of all supported codes in PersoCode system, in an homogeneous manner. It's aimed to be packaged as a library for software integrators or as a web service.


Constructor Summary
EncodeurSpartimeService()
           
 
Method Summary
 boolean addCodeQR(int serial, java.lang.String code)
          Adds a code to the list of codes aimed to be stored in a QRCode
 boolean dropCodesQR()
          Deletes all the codes from the list aimed to be stored into a QRCode
 java.lang.String getCodeDateADate(java.lang.String ISOStart, java.lang.String ISOEnd, boolean unique, int command, java.lang.String... userName)
          Computes a "Date to Date" code
 java.lang.String getCodeFonctionAddCreneau(int activite, int start, int end, java.lang.String... userName)
          Computes a function code allowing the appending of a time interval for an activity
 java.lang.String getCodeFonctionAddOpposition(java.lang.String code, java.lang.String... userName)
          Computes a "function code" allowing a "code stop"
 java.lang.String getCodeFonctionAddPerso(java.lang.String code, int command, java.lang.String... userName)
          Computes a function code allowing the appending of a personal code
 java.lang.String getCodeFonctionDelActivite(int activite, java.lang.String... userName)
          Computes a function code allowing the removal of an activity (Multi-Activity)
 java.lang.String getCodeFonctionDelCreneau(int creneau, java.lang.String... userName)
          Computes a function code allowing the removal of a time interval from an activity
 java.lang.String getCodeFonctionDelOpposition(java.lang.String code, java.lang.String... userName)
          Computes a function code allowing the removal of a code stop
 java.lang.String getCodeFonctionDelPerso(java.lang.String code, java.lang.String... userName)
          Computes a function code allowing the removal of a personal code
 java.lang.String getCodeFonctionModCreneau(int creneau, int start, int end, java.lang.String... userName)
          Computes a function code allowing the modification of a yet existing time interval
 java.lang.String getCodeFonctionSetDateTime(java.lang.String ISODate, java.lang.String... userName)
          Computes a function code allowing the gate-keeper's clock to be set
 java.lang.String getCodeGestionnaire(java.lang.String... userName)
          Computes adminitrator's code
 java.lang.String getCodeHeure(java.lang.String ISODateStart, java.lang.String ISODateEnd, int user, boolean unique, int command, java.lang.String... userName)
          Computes an hour-code (valid from 1 hour up to 24 hours - allowed durations depends on the profile)
 java.lang.String getCodeInstallateur(java.lang.String ISODate, java.lang.String... userName)
          Computes the installator's code for the specified day
 java.lang.String getCodeInstantane(java.lang.String ISODate, int delta, boolean unique, int command, java.lang.String... userName)
          Computes an instantaneous code
 java.lang.String getCodeJour(java.lang.String ISODateStart, java.lang.String ISODateEnd, int user, boolean unique, int command, java.lang.String... userName)
          Computes a day-code (valid from half a day up to 31 days - allowed durations depends on the profile)
 java.lang.String getCodeMois(java.lang.String ISODateStart, int nbMonth, int user, boolean unique, int command, java.lang.String... userName)
          Computes a month-code (valid 1, 2, 3, 4, 6, or 12 months)
 java.lang.String getCodePeriodiqueHebdo(int user, java.lang.String ISOStart, int duration, boolean unique, int command, java.lang.String... userName)
          Computes a weekly periodical code.
 java.lang.String getCodePeriodiqueJourV2(int user, java.lang.String ISOStart, int duration, int nbTrimestres, int joursActifs, int command, java.lang.String... userName)
          Computes a daily periodical code, version 2.
 java.lang.String[] getCryptoParametersFromShortKey(java.lang.String shortKey)
          Extracts crypto parameters from short key of a gate keeper
 java.lang.String getQRCode(java.lang.String... userName)
          Computes and returns a QRCode formatted in such a manner it can be interpreted by the "facilitacces" gate-keepers familly
 int getSerialFromCryptog(java.lang.String cryptogramme)
          Retreives the serial number of a gate-keeper, given the cryptogramme which is a value displayed on the screen when pressing COR key twice
 boolean setCryptoParameters(java.lang.String key, int iv, java.lang.String profil, int base)
          Initialises the encoder with ciphering and coding parameters This method *MUST* be called before any other
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodeurSpartimeService

public EncodeurSpartimeService()
Method Detail

getCryptoParametersFromShortKey

public java.lang.String[] getCryptoParametersFromShortKey(java.lang.String shortKey)
                                                   throws spartime.code.EncodeurSpartimeException
Extracts crypto parameters from short key of a gate keeper

Parameters:
shortKey - the short key (looks like 16549A75C000001P61 for example)
Returns:
a String array in which:
  • First element is the serial number (in a 10 based format) of the gate keeper
  • Second element is the long key of the gate keeper, as expected by setCryptoParameters
  • Third element is the profile of the gate keeper, as expected by setCryptoParameters
Throws:
spartime.code.EncodeurSpartimeException

setCryptoParameters

public boolean setCryptoParameters(java.lang.String key,
                                   int iv,
                                   java.lang.String profil,
                                   int base)
                            throws spartime.code.EncodeurSpartimeException
Initialises the encoder with ciphering and coding parameters This method *MUST* be called before any other

Parameters:
key - The key used for ciphering, expressed as an hexadecimal String
iv - The Initial Value used for ciphering. Usually equals to the serial number of the "gate-keeper".
profil - Gate-Keeper profile, i.e. the number of distinct equivalent codes that can be obtained for each of the 62 different durations (one year, six months,..., one hour)
base - The base in which codes are expressed. Base 14 by default (16 keys keypads)
Returns:
true. This method allays return a dummy "true" boolean value otherwise SOAP exception couldn't be thrown
Throws:
spartime.code.EncodeurSpartimeException - if something goes wrong (more details in the message)

getSerialFromCryptog

public int getSerialFromCryptog(java.lang.String cryptogramme)
                         throws spartime.code.EncodeurSpartimeException
Retreives the serial number of a gate-keeper, given the cryptogramme which is a value displayed on the screen when pressing COR key twice

Parameters:
cryptogramme - the number displayed on the gate-keeper
Returns:
the serial number of the gate keeper
Throws:
spartime.code.EncodeurSpartimeException

getCodeGestionnaire

public java.lang.String getCodeGestionnaire(java.lang.String... userName)
                                     throws spartime.code.EncodeurSpartimeException
Computes adminitrator's code

Parameters:
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
Adminitrator's code
Throws:
spartime.code.EncodeurSpartimeException

getCodeInstallateur

public java.lang.String getCodeInstallateur(java.lang.String ISODate,
                                            java.lang.String... userName)
                                     throws spartime.code.EncodeurSpartimeException
Computes the installator's code for the specified day

Parameters:
ISODate - The day the code should be valid, expressed as ISO8601 on 13 digits (e.g.:20081231T0000).
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
Installator's code for the specified day
Throws:
spartime.code.EncodeurSpartimeException

getCodeDateADate

public java.lang.String getCodeDateADate(java.lang.String ISOStart,
                                         java.lang.String ISOEnd,
                                         boolean unique,
                                         int command,
                                         java.lang.String... userName)
                                  throws spartime.code.EncodeurSpartimeException
Computes a "Date to Date" code

Parameters:
ISOStart - Date since which the code is valid (included) expressed as ISO8601 on 13 to 15 digits (e.g.:20081231T0000)
ISOEnd - Date until which the code is valid (included) expressed as ISO8601 on 13 to 15 digits (e.g.:20081231T0000)
unique - True if the code as to be limited in it's number of utilisations (the number depends on the gate-keeper configuration)
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The "Date to Date" code as a String
Note: Hour and minute in the ISOStart and ISOEnd date can be whatever, but these values aren't part of the code. Only the number of days between end and start is taken into account. Real Hour and minute validity for the starting and the ending days are configured in each gate keeper and are the same for every Date to Date code for a particular gate keeper. By default, they're 0h00 for both days.
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionAddOpposition

public java.lang.String getCodeFonctionAddOpposition(java.lang.String code,
                                                     java.lang.String... userName)
                                              throws spartime.code.EncodeurSpartimeException
Computes a "function code" allowing a "code stop"

Parameters:
code - The code to be stopped
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing a code stop
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionDelOpposition

public java.lang.String getCodeFonctionDelOpposition(java.lang.String code,
                                                     java.lang.String... userName)
                                              throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the removal of a code stop

Parameters:
code - The code on which a stop has to be removed
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the removal of the code stop
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionAddPerso

public java.lang.String getCodeFonctionAddPerso(java.lang.String code,
                                                int command,
                                                java.lang.String... userName)
                                         throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the appending of a personal code

Parameters:
code - The personal code to be appended
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the appending of a personal code
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionDelPerso

public java.lang.String getCodeFonctionDelPerso(java.lang.String code,
                                                java.lang.String... userName)
                                         throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the removal of a personal code

Parameters:
code - The personal code to be removed
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the removal of a personal code
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionDelActivite

public java.lang.String getCodeFonctionDelActivite(int activite,
                                                   java.lang.String... userName)
                                            throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the removal of an activity (Multi-Activity)

Parameters:
activite - The number of the activity to be removed in the TAG
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the removal of an activity
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionAddCreneau

public java.lang.String getCodeFonctionAddCreneau(int activite,
                                                  int start,
                                                  int end,
                                                  java.lang.String... userName)
                                           throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the appending of a time interval for an activity

Parameters:
activite - The number of the activity the time interval has to be appended
start - The start of the time interval, expressed as the number of quarters of an hour since the Monday at 00:00 (from 0 to 671)
end - The end of the time interval, expressed as the number of quarters of an hour since the Monday at 00:00 (from 0 to 671)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the appending of a time interval for an activity
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionModCreneau

public java.lang.String getCodeFonctionModCreneau(int creneau,
                                                  int start,
                                                  int end,
                                                  java.lang.String... userName)
                                           throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the modification of a yet existing time interval

Parameters:
creneau - The number of the time interval to be modified
start - The new start of the time interval, expressed as the number of quarters of an hour since the Monday at 00:00 (from 0 to 671)
end - The new end of the time interval, expressed as the number of quarters of an hour since the Monday at 00:00 (from 0 to 671)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the modification of a yet existing time interval
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionDelCreneau

public java.lang.String getCodeFonctionDelCreneau(int creneau,
                                                  java.lang.String... userName)
                                           throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the removal of a time interval from an activity

Parameters:
creneau - The number of the time interval to be removed
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the removal of a time interval from an activity
Throws:
spartime.code.EncodeurSpartimeException

getCodeFonctionSetDateTime

public java.lang.String getCodeFonctionSetDateTime(java.lang.String ISODate,
                                                   java.lang.String... userName)
                                            throws spartime.code.EncodeurSpartimeException
Computes a function code allowing the gate-keeper's clock to be set

Parameters:
ISODate - The date/time at which the gate-keeper's clock as to be set, expressed as ISO8601 on 13 digits (e.g.:20081231T0000). The minutes of the date must be a multiple of 10 modulo 60 (i.e.: 0,10,20,30,40 or 50).
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The function code allowing the gate-keeper's clock to be set
Throws:
spartime.code.EncodeurSpartimeException

getCodePeriodiqueJourV2

public java.lang.String getCodePeriodiqueJourV2(int user,
                                                java.lang.String ISOStart,
                                                int duration,
                                                int nbTrimestres,
                                                int joursActifs,
                                                int command,
                                                java.lang.String... userName)
                                         throws spartime.code.EncodeurSpartimeException
Computes a daily periodical code, version 2.

Parameters:
user - User's unique number for the given period (0 to 63)
ISOStart - The code's validity's start expressed as ISO8601. Only YEAR and HOUR are used as this type of codes necessarily starts on January, 1st, on an entire hour, and on valid days (see bellow)
duration - Code's validity's duration for each valid day, expressed as a number of hours minus one (from 0 to 15, meaning from 1h to 16h)
nbTrimestres - The number of quarters (of a year) the code has to be valid (from 0 to 3, meaning 1 quarter to 4 quarters)
joursActifs - Valid week's days: 0 is Monday to Saturday; 1 is Saturday and Sunday; 2 is Monday to Friday; 3 is Monday to Sunday.
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The daily periodical code, version 2, corresponding to the specified parameters
Throws:
spartime.code.EncodeurSpartimeException

getCodePeriodiqueHebdo

public java.lang.String getCodePeriodiqueHebdo(int user,
                                               java.lang.String ISOStart,
                                               int duration,
                                               boolean unique,
                                               int command,
                                               java.lang.String... userName)
                                        throws spartime.code.EncodeurSpartimeException
Computes a weekly periodical code.

Parameters:
user - User's unique number for the given period (0 or 1)
ISOStart - The code's validity's start expressed as ISO8601. Only YEAR, DAY OF WEEK and HOUR are used as this type of codes necessarily starts on the first "DAY OF WEEK" in January, on an entire hour, and longs all the year
duration - Code's validity's duration for each valid day, expressed as a number of hours minus one (from 0 to 15, meaning from 1h to 16h)
unique - True if the code as to be limited in it's number of utilisations (the number depends on the gate-keeper configuration)
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The weekly periodical code corresponding to the specified parameters
Throws:
spartime.code.EncodeurSpartimeException

getCodeInstantane

public java.lang.String getCodeInstantane(java.lang.String ISODate,
                                          int delta,
                                          boolean unique,
                                          int command,
                                          java.lang.String... userName)
                                   throws spartime.code.EncodeurSpartimeException
Computes an instantaneous code

Parameters:
ISODate - Code's validity's start, expressed as ISO8601 on 13 digits (e.g.:20081231T0000)
delta - An offset, in number of minutes, to be applied to the gate-keeper's clock when the code is typed (from -8 to +8)
unique - True if the code as to be limited in it's number of utilisations (the number depends on the gate-keeper configuration)
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The corresponding instantaneous code
Throws:
spartime.code.EncodeurSpartimeException

getCodeHeure

public java.lang.String getCodeHeure(java.lang.String ISODateStart,
                                     java.lang.String ISODateEnd,
                                     int user,
                                     boolean unique,
                                     int command,
                                     java.lang.String... userName)
                              throws spartime.code.EncodeurSpartimeException
Computes an hour-code (valid from 1 hour up to 24 hours - allowed durations depends on the profile)

Parameters:
ISODateStart - Code's validity's start (included), expressed as ISO8601 on 13 digits (e.g.:20081231T0000). Must be on an entire hour (e.g. 08h00, 09h00, etc...)
ISODateEnd - Code's validity's end (included), expressed as ISO8601 on 13 digits (e.g.:20081231T0059). Must be on an entire hour minus one minute (e.g. 08h59, 09h59, etc...)
user - User's unique number for the given period (from 0 to the corresponding value in the profile)
unique - True if the code as to be limited in it's number of utilisations (the number depends on the gate-keeper configuration)
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The corresponding hour-code
Throws:
spartime.code.EncodeurSpartimeException

getCodeJour

public java.lang.String getCodeJour(java.lang.String ISODateStart,
                                    java.lang.String ISODateEnd,
                                    int user,
                                    boolean unique,
                                    int command,
                                    java.lang.String... userName)
                             throws spartime.code.EncodeurSpartimeException
Computes a day-code (valid from half a day up to 31 days - allowed durations depends on the profile)

Parameters:
ISODateStart - Code's validity's start (included), expressed as ISO8601 on 13 digits (e.g.:20081231T0000). Must start at 00h00 or 12h00.
ISODateEnd - Code's validity's end (included), expressed as ISO8601 on 13 digits (e.g.:20090101T0000). The number of days between end and start must be an integer, except for the "half-a-day" code.
user - User's unique number for the given period (from 0 to the corresponding value in the profile)
unique - True if the code as to be limited in it's number of utilisations (the number depends on the gate-keeper configuration)
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The corresponding day-code
Throws:
spartime.code.EncodeurSpartimeException

getCodeMois

public java.lang.String getCodeMois(java.lang.String ISODateStart,
                                    int nbMonth,
                                    int user,
                                    boolean unique,
                                    int command,
                                    java.lang.String... userName)
                             throws spartime.code.EncodeurSpartimeException
Computes a month-code (valid 1, 2, 3, 4, 6, or 12 months)

Parameters:
ISODateStart - Code's validity's start (included), expressed as ISO8601 on 13 digits (e.g.:20081231T0000). Must be the first day of the month, at 0h00. Valid months are 1+X*nbMonth where X belongs to {0..12/nbMonth}
nbMonth - The number of month the code's validity have to last. Must be 1, 2, 3, 4, 6, or 12.
user - User's unique number for the given period (from 0 to the corresponding value in the profile)
unique - True if the code as to be limited in it's number of utilisations (the number depends on the gate-keeper configuration)
command -
  • In Standard mode: outputs to be activated (b0=S0, b1=S1, b2=S2)
  • In Extended users mode: (Extension of the) User's unique number for the given period. From 0 to 7.
  • In Gate number mode: The gate number (0 for master gate, 1 to 7 for slaves gates)
userName - the name of the user who's code is computed for. Like "M. Jean DUPONT".
Returns:
The corresponding month-code
Throws:
spartime.code.EncodeurSpartimeException

addCodeQR

public boolean addCodeQR(int serial,
                         java.lang.String code)
                  throws spartime.code.EncodeurSpartimeException
Adds a code to the list of codes aimed to be stored in a QRCode

Parameters:
serial - The serial number of the gateKeeper on which the code works
code - The code to be stored into a QRCode
Returns:
true. This method allays return a dummy "true" boolean value otherwise SOAP exception couldn't be thrown
Throws:
spartime.code.EncodeurSpartimeException

dropCodesQR

public boolean dropCodesQR()
                    throws spartime.code.EncodeurSpartimeException
Deletes all the codes from the list aimed to be stored into a QRCode

Returns:
true. This method allays return a dummy "true" boolean value otherwise SOAP exception couldn't be thrown
Throws:
spartime.code.EncodeurSpartimeException

getQRCode

public java.lang.String getQRCode(java.lang.String... userName)
                           throws spartime.code.EncodeurSpartimeException
Computes and returns a QRCode formatted in such a manner it can be interpreted by the "facilitacces" gate-keepers familly

Parameters:
userName - the name of the user who's QRCode is computed for. Like "M. Jean DUPONT".
Returns:
a String which is the QRCode in a PNG format, base64 encoded. (thus it can be embeded in a HTML page just like: )
Throws:
spartime.code.EncodeurSpartimeException