Application.java revision 1350b637af96e2390d247918800c02a7f531b47d
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: Application.java,v 1.7 2010/01/08 22:20:47 veiming Exp $
*
* Portions copyright 2013-2015 ForgeRock AS.
*/
/**
* Application class contains the information on how an application behaves
* e.g. how to combine decision and how to compare resources;
* and the supported actions.
*/
public class Application implements Cloneable {
/**
* Created by index key
*/
/**
* Created by search attribute
*/
public static final SearchAttribute CREATED_BY_SEARCH_ATTRIBUTE = new SearchAttribute(CREATED_BY_ATTRIBUTE, "ou");
/**
* Last modified by index key
*/
/**
* Last modified by search attribute
*/
public static final SearchAttribute LAST_MODIFIED_BY_SEARCH_ATTRIBUTE = new SearchAttribute(LAST_MODIFIED_BY_ATTRIBUTE, "ou");
/**
* Creation date index key
*/
/**
* Creation date search attribute
*/
public static final SearchAttribute CREATION_DATE_SEARCH_ATTRIBUTE = new SearchAttribute(CREATION_DATE_ATTRIBUTE, "ou");
/**
* Last modified date index key
*/
public static final String LAST_MODIFIED_DATE_ATTRIBUTE =
"lastmodifieddate";
/**
* Last modified date search attribute
*/
public static final SearchAttribute LAST_MODIFIED_DATE_SEARCH_ATTRIBUTE =
/**
* Name attribute name,
*/
/**
* Name search attribute
*/
public static final SearchAttribute NAME_SEARCH_ATTRIBUTE = new SearchAttribute(NAME_ATTRIBUTE, "ou");
/**
* Description attribute name,
*/
/**
* Description search attribute
*/
public static final SearchAttribute DESCRIPTION_SEARCH_ATTRIBUTE = new SearchAttribute(DESCRIPTION_ATTRIBUTE, "ou");
private static final int LEN_CREATED_BY_ATTRIBUTE =
private static final int LEN_LAST_MODIFIED_BY_ATTRIBUTE =
private static final int LEN_CREATION_DATE_ATTRIBUTE =
private static final int LEN_LAST_MODIFIED_DATE_ATTRIBUTE =
private String description;
private ApplicationType applicationType;
private Class entitlementCombiner;
private Class searchIndex;
private Class resourceComparator;
private String lastModifiedBy;
private long creationDate = -1;
private long lastModifiedDate = -1;
private ResourceName resourceComparatorInstance;
private ISaveIndex saveIndexInstance;
private ISearchIndex searchIndexInstance;
private final EntitlementRegistry registry;
/**
* Package-private contructor lets us test. The public default constructor
* passes through to here.
*
* @param registry Used to perform lookups for internal instantiations
*/
}
/**
* Public, default constructor must be used so that derived classes
* can still use super().
*/
public Application() {
this(EntitlementRegistry.load());
}
/**
* Constructs an instance.
*
* @param name Name of Application.
* @param applicationType Its application type.
*/
this();
this.applicationType = applicationType;
}
/**
* Sets the application type of this Application
*
* @param applicationType The non-null application type
*/
this.applicationType = applicationType;
}
public Application clone() {
return clone;
}
if (conditions != null) {
}
}
if (attributeNames != null) {
}
}
/**
* Returns application type.
*
* @return application type.
*/
public ApplicationType getApplicationType() {
return applicationType;
}
/**
* Returns set of supported condition class names.
*
* @return set of supported condition class names.
*/
return conditions;
}
/**
* Returns set of supported subject class names.
*
* @return set of supported subject class names.
*/
return subjects;
}
/**
* Returns entitlement combiner class.
*
* @return entitlement combiner class.
*/
public Class getEntitlementCombinerClass() {
return entitlementCombiner;
}
/**
* Returns a new instance of entitlement combiner.
*
* @return an instance of entitlement combiner.
*/
public EntitlementCombiner getEntitlementCombiner() {
if (entitlementCombiner != null) {
try {
} catch (InstantiationException e) {
"Application.getEntitlementCombiner", e);
} catch (IllegalAccessException e) {
"Application.getEntitlementCombiner", e);
}
}
return null;
}
/**
* Returns application name.
*
* @return application name.
*/
return name;
}
/**
* Sets supported condition class names.
*
* @param conditions Supported condition class names.
*/
if (conditions == null) {
}
this.conditions = conditions;
}
/**
* Sets supported subject class names.
*
* @param subjects Supported subject class names.
*/
}
}
/**
* Sets save index.
*
* @param saveIndex save index.
*/
} else {
}
}
/**
* Sets search index generator.
*
* @param searchIndex search index generator.
*/
this.searchIndex = searchIndex;
if (searchIndex != null) {
} else {
}
}
/**
* Sets entitlement combiner.
*
* @param entitlementCombiner entitlement combiner.
*/
}
/**
* Sets entitlement combiner using the {@link EntitlementRegistry} to look up
* the appropriate class.
*
* @param entitlementCombiner name of the entitlement combiner to look up
*/
}
/**
* Sets resource comparator.
*
* @param resourceComparator resource comparator.
*/
throws InstantiationException, IllegalAccessException {
this.resourceComparator = resourceComparator;
if (resourceComparator != null) {
newInstance();
} else {
}
}
/**
* Retrieves the resource type UUIDs associated with the application.
*
* @return the set of associated resource type UUIDs
*/
return resourceTypeUuids;
}
/**
* Adds the passed set of resource type UUIDs to the application.
*
* @param resourceTypeUuids
* the set of resource type UUIDs
*/
}
/**
* Returns search indexes for a given resource.
*
* @param resource resource to generate the indexes.
* @param realm Current realm to be searched.
* @return search indexes.
* @throws EntitlementException When an error occurs in the entitlements framework.
*/
return (searchIndex == null) ?
}
/**
* Returns save indexes for a given resource.
*
* @param resource resource to generate the indexes.
* @return save indexes.
*/
}
/**
* Returns save index class.
*
* @return save index class.
*/
public Class getSaveIndexClass() {
return saveIndex;
}
/**
* Returns search index class.
*
* @return search index class.
*/
public Class getSearchIndexClass() {
return searchIndex;
}
/**
* Returns resource comparator class.
*
* @return resource comparator class.
*/
public Class getResourceComparatorClass() {
return resourceComparator;
}
/**
* Returns resource comparator for this Application, defaulting to the ApplicationType's
* resource comparator if none is directly associated with this Application.
*
* @return resource comparator, which may be null.
*/
public ResourceName getResourceComparator() {
return getResourceComparator(true);
}
/**
* Returns resource comparator for this Application.
*
* @param defaultToAppType if <code>true</code>, will return this Application's ApplicationType
* resource comparator if none is set on the Application.
* @return resource comparator, which may be null.
*/
if (resourceComparator == null) {
if (defaultToAppType) {
return applicationType.getResourceComparator();
} else {
return null;
}
} else {
return resourceComparatorInstance;
}
}
/**
* Sets attribute names.
*
* @param names Attribute names.
*/
}
}
/**
* Adds attribute names.
*
* @param names Attribute names.
*/
if (attributeNames == null) {
}
}
}
/**
* Returns save index
*
* @return save index
*/
public ISaveIndex getSaveIndex() {
return saveIndexInstance;
}
/**
* Returns search index
*
* @return search index
*/
public ISearchIndex getSearchIndex() {
return searchIndexInstance;
}
/**
* Return attribute names.
*
* @return attribute names.
*/
return attributeNames;
}
/**
* Returns description.
*
* @return description.
*/
public String getDescription() {
return description;
}
/**
* Set description.
*
* @param description description.
*/
this.description = description;
}
/**
* Returns creation date.
*
* @return creation date.
*/
public long getCreationDate() {
return creationDate;
}
/**
* Sets the creation date.
*
* @param creationDate creation date.
*/
public void setCreationDate(long creationDate) {
this.creationDate = creationDate;
}
/**
* Returns last modified date.
*
* @return last modified date.
*/
public long getLastModifiedDate() {
return lastModifiedDate;
}
/**
* Sets the last modified date.
*
* @param lastModifiedDate last modified date.
*/
public void setLastModifiedDate(long lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
/**
* Returns the user ID who last modified the policy.
*
* @return user ID who last modified the policy.
*/
public String getLastModifiedBy() {
return lastModifiedBy;
}
/**
* Sets the user ID who last modified the policy.
*
* @param lastModifiedBy user ID who last modified the policy.
*/
this.lastModifiedBy = lastModifiedBy;
}
/**
* Returns the user ID who created the policy.
*
* @return user ID who created the policy.
*/
public String getCreatedBy() {
return createdBy;
}
/**
* Sets the user ID who created the policy.
*
* @param createdBy user ID who created the policy.
*/
}
/**
* Returns meta information.
*
* @return meta information.
*/
}
if (creationDate != -1) {
}
if (lastModifiedDate != -1) {
}
if (lastModifiedBy != null) {
}
return meta;
}
try {
} catch (NumberFormatException e) {
}
try {
} catch (NumberFormatException e) {
}
}
}
}
}
try {
} catch (EntitlementException ex) {
return false;
}
}
/**
* An Application is editable if it can be changed by an end user. This method was put
* in place for subclasses that can not be edited.
*
* @return True if the Application can be edited.
*/
public boolean isEditable() {
return true;
}
}