All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.truelicense.jsf.DisplayBean Maven / Gradle / Ivy

Go to download

Provides an internationalized, Facelet based wizard component for license management in consumer applications.

There is a newer version: 2.6.6
Show newest version
/*
 * Copyright (C) 2005-2013 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truelicense.jsf;

import java.util.Date;
import javax.annotation.Nullable;
import javax.faces.component.FacesComponent;
import javax.security.auth.x500.X500Principal;
import net.java.truelicense.core.*;
import static net.java.truelicense.ui.LicenseWizardMessage.*;

/**
 * The backing bean for displaying the installed license key.
 *
 * @author Christian Schlichtherle
 */
@FacesComponent("")
public final class DisplayBean extends LicenseBean {

    private @Nullable License license;

    public String getTitle() { return message(display_title); }
    public String getSubjectLabel() { return message(display_subject); }
    public String getSubjectValue() { return license().getSubject(); }
    public String getHolderLabel() { return message(display_holder); }
    public X500Principal getHolderValue() { return license().getHolder(); }
    public String getIssuerLabel() { return message(display_issuer); }
    public X500Principal getIssuerValue() { return license().getIssuer(); }
    public String getIssuedLabel() { return message(display_issued); }
    public Date getIssuedValue() { return license().getIssued(); }
    public String getNotBeforeLabel() { return message(display_notBefore); }
    public Date getNotBeforeValue() { return license().getNotBefore(); }
    public String getNotAfterLabel() { return message(display_notAfter); }
    public Date getNotAfterValue() { return license().getNotAfter(); }
    public String getConsumerLabel() { return message(display_consumer); }
    private String consumerType() { return license().getConsumerType(); }
    private int consumerAmount() { return license().getConsumerAmount(); }
    public String getConsumerValue() { return message(display_consumerFormat,
            subject(), consumerType(), consumerAmount()); }
    public String getInfoLabel() { return message(display_info); }
    public String getInfoValue() { return license().getInfo(); }

    private License license() {
        final License license = this.license;
        return null != license ? license : (this.license = defaultLicense());
    }

    private License defaultLicense() {
        try {
            return installedLicense();
        } catch (LicenseManagementException ex) {
            return emptyLicense();
        }
    }

    private License installedLicense() throws LicenseManagementException {
        return manager().view();
    }

    private License emptyLicense() { return managementContext().license(); }

    private LicenseManagementContext managementContext() {
        return consumerContext().context();
    }

    private LicenseConsumerContext consumerContext() {
        return manager().context();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy