votorola.a.register
Class RegistrationC

java.lang.Object
  extended by RegistrationC
All Implemented Interfaces:
Serializable, Cloneable, Registration

@ThreadRestricted(value="touch")
public final class RegistrationC
extends Object
implements Cloneable, Registration

A committable instance of a voter's input to a register. It is writeable, and its changes may be committed to the voter input table.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface Registration
TRUST_DESTINATIONS_MAX, WRITEABLE_ALL_DEFAULT
 
Constructor Summary
RegistrationC(String voterEmail)
          Constructs a RegistrationC with default initial data.
RegistrationC(String voterEmail, String xml)
          Constructs a RegistrationC from the specified initial data.
RegistrationC(String voterEmail, VoterInputTable voterInputTable)
          Constructs a RegistrationC, reading its initial state from the voter input table.
 
Method Summary
 void addTrustDestination(String newDestinationEmail, ElectoralSubserver.UserSession session)
          Adds a new trust destination, if not already present.
 RegistrationC clone()
           
 void commit(VoterInputTable voterInputTable, ElectoralSubserver.UserSession session)
          Writes this registration to the table, if it has uncommitted changes; or removes it, if it is at default.
(package private)  void commit(VoterInputTable voterInputTable, ElectoralSubserver.UserSession session, boolean toForce)
          Writes this registration to the table; or removes it, if it is at default.
 String getLink()
          A Web link in URI format, pointing to general information about the voter.
 String getName()
          The name of the voter.
 String getNote()
          A short note explaining or commenting on this registration.
 String getResidence()
          The primary residential address of the voter.
(package private)  boolean isWriteable(ElectoralSubserver.UserSession session, Register register)
          Returns true if this registration is writeable by the user.
 boolean isWriteableAll()
          Returns true if the simple fields of this registration are generally writeable by other registrants, or false if they are exclusively writeable by the owning registrant.
 void removeTrustDestination(String oldDestinationEmail, ElectoralSubserver.UserSession session)
          Removes a trust destination, if found.
 void setLink(String newLink, ElectoralSubserver.UserSession session, Register register)
          Changes the link.
 void setName(String newName, ElectoralSubserver.UserSession session, Register register)
          Changes the name.
 void setNote(String newNote, ElectoralSubserver.UserSession session, Register register)
          Changes the note.
 void setResidence(String newResidence, ElectoralSubserver.UserSession session, Register register)
          Changes the residential address.
 List<String> trustDestinations()
          Returns the list of voters to whom trust edges are to be extended.
 String voterEmail()
          Identifies the voter (registrant) by email address.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistrationC

public RegistrationC(String voterEmail,
                     VoterInputTable voterInputTable)
              throws SQLException
Constructs a RegistrationC, reading its initial state from the voter input table.

Parameters:
voterEmail - per voterEmail()
voterInputTable - of the register
Throws:
SQLException

RegistrationC

public RegistrationC(String voterEmail,
                     String xml)
              throws XMLStreamException
Constructs a RegistrationC from the specified initial data.

Parameters:
voterEmail - per voterEmail()
xml - the initial data from the 'xml' column of the voter input table, or null to use defaults
Throws:
XMLStreamException

RegistrationC

public RegistrationC(String voterEmail)
Constructs a RegistrationC with default initial data.

Parameters:
voterEmail - per voterEmail()
Method Detail

commit

public void commit(VoterInputTable voterInputTable,
                   ElectoralSubserver.UserSession session)
            throws SQLException,
                   VoterInputTable.BadInputException
Writes this registration to the table, if it has uncommitted changes; or removes it, if it is at default.

Parameters:
voterInputTable - of the register
Throws:
SQLException
VoterInputTable.BadInputException

commit

void commit(VoterInputTable voterInputTable,
            ElectoralSubserver.UserSession session,
            boolean toForce)
      throws SQLException,
             VoterInputTable.BadInputException
Writes this registration to the table; or removes it, if it is at default.

Parameters:
voterInputTable - of the register
toForce - false to commit only if changes were made in this instance of registration; true to force the commit, regardless
Throws:
SQLException
VoterInputTable.BadInputException

clone

public final RegistrationC clone()
Overrides:
clone in class Object

getLink

public String getLink()
Description copied from interface: Registration
A Web link in URI format, pointing to general information about the voter.

Specified by:
getLink in interface Registration
Returns:
link, or null if there is none
See Also:
setLink(String,ElectoralSubserver.UserSession,Register)

setLink

public void setLink(String newLink,
                    ElectoralSubserver.UserSession session,
                    Register register)
Changes the link.

Throws:
VotorolaSecurityException - if write permission denied
See Also:
getLink()

getName

public String getName()
Description copied from interface: Registration
The name of the voter.

Specified by:
getName in interface Registration
Returns:
name, or null if unknown
See Also:
setName(String,ElectoralSubserver.UserSession,Register)

setName

public void setName(String newName,
                    ElectoralSubserver.UserSession session,
                    Register register)
Changes the name.

Throws:
VotorolaSecurityException - if write permission denied
See Also:
getName()

getNote

public String getNote()
Description copied from interface: Registration
A short note explaining or commenting on this registration.

Specified by:
getNote in interface Registration
Returns:
note, or null if there is none
See Also:
setNote(String,ElectoralSubserver.UserSession,Register)

setNote

public void setNote(String newNote,
                    ElectoralSubserver.UserSession session,
                    Register register)
Changes the note.

Throws:
VotorolaSecurityException - if write permission denied
See Also:
getNote()

getResidence

public String getResidence()
Description copied from interface: Registration
The primary residential address of the voter.

Specified by:
getResidence in interface Registration
Returns:
residential address, or null if unknown
See Also:
setResidence(String,ElectoralSubserver.UserSession,Register)

setResidence

public void setResidence(String newResidence,
                         ElectoralSubserver.UserSession session,
                         Register register)
Changes the residential address.

Throws:
VotorolaSecurityException - if write permission denied
See Also:
getResidence()

isWriteable

boolean isWriteable(ElectoralSubserver.UserSession session,
                    Register register)
Returns true if this registration is writeable by the user.

See Also:
isWriteableAll()

isWriteableAll

public boolean isWriteableAll()
Description copied from interface: Registration
Returns true if the simple fields of this registration are generally writeable by other registrants, or false if they are exclusively writeable by the owning registrant. If the fields are generally writeable (the initial state of a new registration), then any authenticated registrant with sufficient trust may alter them. However, as soon as any field is altered by the owning registrant, then the state of this variable switches permanently to false.

The main purpose of this feature is to support pre-registration of candidates, by voters.

Specified by:
isWriteableAll in interface Registration
See Also:
Registration.WRITEABLE_ALL_DEFAULT

trustDestinations

public List<String> trustDestinations()
Description copied from interface: Registration
Returns the list of voters to whom trust edges are to be extended. The list is backed by this instance of registration, and will reflect any subsequent changes to it.

Specified by:
trustDestinations in interface Registration
Returns:
unmodifiable list of voter email addresses
See Also:
addTrustDestination(String,ElectoralSubserver.UserSession), removeTrustDestination(String,ElectoralSubserver.UserSession)

addTrustDestination

public void addTrustDestination(String newDestinationEmail,
                                ElectoralSubserver.UserSession session)
Adds a new trust destination, if not already present.

Parameters:
newDestinationEmail - identifying the destination to add
Throws:
IllegalStateException - if addition would exceed TRUST_DESTINATIONS_MAX
VotorolaSecurityException - if voterEmail is unequal to session.userEmail() (failsafe bug trap)
See Also:
trustDestinations()

removeTrustDestination

public void removeTrustDestination(String oldDestinationEmail,
                                   ElectoralSubserver.UserSession session)
Removes a trust destination, if found.

Parameters:
oldDestinationEmail - identifying the destination to remove
Throws:
VotorolaSecurityException - if voterEmail is unequal to session.userEmail() (failsafe bug trap)
See Also:
trustDestinations()

voterEmail

public String voterEmail()
Description copied from interface: Registration
Identifies the voter (registrant) by email address. The identifier is case sensitive.

Some parts of an email address (the domain name) are technically case insensitive. It is therefore possible for two identifiers to refer to the same mailbox (user@domain.dom and user@DoMain.com for example). Whether or not the two refer to the same person is a question for the trust network to sort out. The authentication issues are equivalent to those of someone posing under two separate mailboxes.

Specified by:
voterEmail in interface Registration
Returns:
canonical email address (having no personal part)
See Also:
http://en.wikipedia.org/wiki/E-mail_address