Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.labs64.utils.swid.processor;
 
 
Default SWID tag processor creates SWID tag with pre-defined mandatory elements. See ISO/IEC 19770-2:2009 for guidance.
 
 public class DefaultSwidProcessor implements SwidProcessor {
 
     private static final String NULL_ID = null;
 
     private SoftwareIdentificationTagComplexType swidTag;

    
Creates SWID Tag default processor.
 
     public DefaultSwidProcessor() {
          = new SoftwareIdentificationTagComplexType();
     }

    

Identifies whether this application needs to match up with an entitlement for a reconciliation to be considered successful (entitlement_required_indicator).

Specifies if an entitlement is required to reconcile this application. Example data format: XX = entitlement status (true = entitlement required; false = no entitlement required).

Parameters:
entitlementRequiredIndicator entitlements required indicator
Returns:
a reference to this object.
 
     public DefaultSwidProcessor setEntitlementRequiredIndicator(final boolean entitlementRequiredIndicator) {
                 new org.iso.standards.iso._19770.__2._2009.schema.Boolean(entitlementRequiredIndicator));
         return this;
     }

    

Accurately identifies the application (product_title).

Parameters:
productTitle product title
Returns:
a reference to this object.
 
     public DefaultSwidProcessor setProductTitle(final String productTitle) {
         .setProductTitle(
                 new Token(productTitle));
         return this;
     }

    
Identifies the application version (product_version) using two values – numeric version and version string.

Parameters:
productVersion product version
productVersionMajor product major version
productVersionMinor product minor version
productVersionBuild product build version
productVersionReview product review version
Returns:
a reference to this object.
 
     public DefaultSwidProcessor setProductVersion(final String productVersion,
             final long productVersionMajor,
             final long productVersionMinor,
             final long productVersionBuild,
             final long productVersionReview) {
         final NumericVersionComplexType numericVersion = new NumericVersionComplexType(
                 new UInt(productVersionMajor),
                new UInt(productVersionMinor),
                new UInt(productVersionBuild),
                new UInt(productVersionReview),
                );
        .setProductVersion(
                new ProductVersionComplexType(
                        new Token(productVersion), numericVersion));
        return this;
    }

    
Identifies the creator of the software (software_creator).

Parameters:
softwareCreatorName software creator name
softwareCreatorRegId software creator registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setSoftwareCreator(final String softwareCreatorNamefinal String softwareCreatorRegId) {
                new EntityComplexType(
                        new Token(softwareCreatorName),
                        new RegistrationId(softwareCreatorRegId),
                        ));
        return this;
    }

    
Identifies the licensor of the software (software_licensor).

Parameters:
softwareLicensorName software licensor name
softwareLicensorRegId software licensor registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setSoftwareLicensor(final String softwareLicensorName,
            final String softwareLicensorRegId) {
                new EntityComplexType(
                        new Token(softwareLicensorName),
                        new RegistrationId(softwareLicensorRegId),
                        ));
        return this;
    }

    
Identifies the specific version of a specific application (software_id).

Parameters:
uniqueId software unique ID
tagCreatorRegid tag creator registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setSoftwareId(final String uniqueIdfinal String tagCreatorRegid) {
        .setSoftwareId(
                new SoftwareIdComplexType(
                        new Token(uniqueId),
                        new RegistrationId(tagCreatorRegid),
                        ));
        return this;
    }

    

Identifies the tag creator (tag_creator).

Example data format: “regid.2010-01.com.labs64,NLIC” where:

  • regid = registered id
  • 2010-01 = the year and first month the domain was registered (yyyy-mm)
  • com = the upper level domain
  • labs64 = the domain name
  • NLIC = the name of the business unit (BU) that created the SWID tag

Note that everything after the comma ‘,’ is optional and only required if a software title is specific

Parameters:
tagCreatorName tag creator name
tagCreatorRegId tag creator registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setTagCreator(final String tagCreatorNamefinal String tagCreatorRegId) {
        .setTagCreator(
                new EntityComplexType(
                        new Token(tagCreatorName),
                        new RegistrationId(tagCreatorRegId),
                        ));
        return this;
    }

    
Validate whether processor configuration is valid.

Throws:
com.labs64.utils.swid.exception.SwidException in case of invalid processor configuration
    public void validate() {
        if (.getEntitlementRequiredIndicator() == null) {
            throw new SwidException("'entitlement_required_indicator' is not set");
        }
        if (.getProductTitle() == null) {
            throw new SwidException("'product_title' is not set");
        }
        if (.getProductVersion() == null) {
            throw new SwidException("'product_version' is not set");
        }
        if (.getSoftwareCreator() == null) {
            throw new SwidException("'software_creator' is not set");
        }
        if (.getSoftwareLicensor() == null) {
            throw new SwidException("'software_licensor' is not set");
        }
        if (.getSoftwareId() == null) {
            throw new SwidException("'software_id' is not set");
        }
        if (.getTagCreator() == null) {
            throw new SwidException("'tag_creator' is not set");
        }
    }
    @Override
        validate();
        return ;
    }
New to GrepCode? Check out our FAQ X