Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.sapia.util.license;
  
  import java.util.Date;
  import java.util.Map;

This factory is used to create LicenseRegistrations. The created registrations are handled by client applications. Registrations should normally be kept in a database, on a per-client basis, on the vendor's side.

The code snippet below illlustrates how an instance of this class can be used:

 DurationLicense     license      = new DurationLicense(new Date(), 30);
 LicenseRegistration registration = LicenseRegistrationFactory.createRegistration(someVendorIdentifier, license);
 
 // ... here save registration as blob in database ...
 
 // the license record below is normally sent to the licensee (for example, it can be sent
 // by mail, as a serialized object (in an attached file), or in some form of proprietary
 // marshalling format. A LicenseRecord is normally processed within application code at the client,
 // to enforce usage rights.
 LicenseRecord       toSend = registration.getLicenseRecord();
 
 

Note that an instance of this class keeps an application-specific vendor identifier. That identifier is also encapsulated within license records sent to clients. The vendor identifier is kept on the client side to make sure that eventual licenses on the client side are eventually updated with licenses coming from the original vendor.

Author(s):
Yanick Duchesne
Copyright:
Copyright &.169; 2002-2004 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site
 
 public class LicenseRegistrationFactory {
   
   private SecurityFactory _fac;
   
      = fac;
   }
   
     this(new SecurityFactory());
   }
  
  

Returns:
the SecurityFactory that this instance uses.
 
     return ;
   }
  
  
Creates a LicenseRegistration and returns it.

Parameters:
serializableVendorId the identifier of the vendor that emits the License.
license a License object.
data an Map of arbitrary serializable bindings kept within the returned registration.
currentDate a Date object representing the current date.
idFactory the LicenseIdFactory internally used to create the license identifier.
Returns:
a LicenseRegistration.
Throws:
java.io.IOException if an IO problem occurs while creating the registration.
java.lang.Exception if some low-level problem occurs.
 
   public LicenseRegistration createRegistration(Object serializableVendorIdLicense licenseDate currentDateLicenseIdFactory idFactorythrows IOExceptionException{
     return createRegistration(serializableVendorId, 1024, licensecurrentDateidFactory);
   }
  
  
Creates a LicenseRegistration and returns it.

Parameters:
serializableVendorId the identifier of the vendor that emits the License.
license a License object.
serializableData an Map of arbitrary serializable bindings kept within the returned registration.
currentDate a Date object representing the current date.
idFactory the LicenseIdFactory internally used to create the license identifier.
Returns:
a LicenseRegistration.
Throws:
java.io.IOException if an IO problem occurs while creating the registration.
java.lang.Exception if some low-level problem occurs.
   
   public LicenseRegistration createRegistration(Object serializableVendorId
                                                 License license
                                                 Map serializableData
                                                 Date currentDate,
                                                 LicenseIdFactory idFactorythrows IOExceptionException{
     return createRegistration(serializableVendorId, 1024, licenseserializableDatacurrentDateidFactory);
   }  
  
  
Creates a LicenseRegistration and returns it.

Parameters:
serializableVendorId the identifier of the vendor that emits the License.
license a License object.
currentDate a Date object representing the current date.
idFactory the LicenseIdFactory internally used to create the license identifier.
Returns:
a LicenseRegistration.
Throws:
java.io.IOException if an IO problem occurs while creating the registration.
java.lang.Exception if some low-level problem occurs.
  public LicenseRegistration createRegistration(Object serializableVendorId
                                                int strength
                                                License license
                                                Date currentDate,
                                                LicenseIdFactory idFactorythrows IOExceptionException{
    return createRegistration(serializableVendorIdstrengthlicensenullcurrentDateidFactory);
  }
  
  
Creates a LicenseRegistration and returns it.

Parameters:
strength the "strength" (number of bytes) of the internal encryption keys.
serializableVendorId the identifier of the vendor that emits the License.
license a License
serializableData an Map of arbitrary serializable bindings kept within the returned registration.
currentDate a Date object representing the current date.
idFactory the LicenseIdFactory internally used to create the license identifier.
Returns:
a LicenseRegistration
Throws:
java.io.IOException if an IO problem occurs while creating the registration.
java.lang.Exception if some low-level problem occurs.
  public LicenseRegistration createRegistration(Object serializableVendorId
                                                int strength
                                                License license
                                                Map serializableData
                                                Date currentDate,
                                                LicenseIdFactory idFactorythrows IOExceptionException{
    KeyPairGenerator kpGen = .newKeyPairGenerator("DSA");
    kpGen.initialize(strengthnew SecureRandom());
    KeyPair kp = kpGen.generateKeyPair();
    LicenseRecord rec = LicenseRecord.newInstance(serializableVendorIdlicensekp.getPublic(), kp.getPrivate(), idFactory);
    return new LicenseRegistration(serializableVendorIdreckpserializableDatacurrentDate);
  }  
  
New to GrepCode? Check out our FAQ X