ApplicationManager.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: ApplicationManager.java,v 1.11 2010/01/13 23:41:57 veiming Exp $
*
* Portions Copyrighted 2013-2015 ForgeRock AS.
*/
/**
* Application Manager handles addition, deletion and listing of applications for each realm.
*/
public final class ApplicationManager {
private static Map<String, Set<Application>> applications = new ConcurrentHashMap<String, Set<Application>>();
private ApplicationManager() {
}
/**
* Returns the application names in a realm.
*
* When performing the search using the Subject {@link PrivilegeManager#superAdminSubject},
* the provided filters must not contain {@link Operator#LESS_THAN_OR_EQUAL_OPERATOR }
* or {@link Operator#GREATER_THAN_OR_EQUAL_OPERATOR } as these are not supported by LDAP.
*
* @param adminSubject Admin Subject who has the rights to access configuration datastore.
* @param realm Realm name.
* @param filters Search Filters
* @return application names in a realm.
*/
throws EntitlementException {
}
// Delegation to applications is currently not configurable, passing super admin (see AME-4959)
}
private static Set<String> filterApplicationNames(String realm, Set<String> applNames, Set<SearchFilter> filters) {
try {
}
}
} catch (EntitlementException ex) {
}
}
} else {
}
return results;
}
return false;
}
return false;
}
return false;
}
return false;
}
return false;
}
return false;
}
}
}
return true;
}
switch (operator) {
case EQUALS_OPERATOR:
case GREATER_THAN_OPERATOR:
case LESS_THAN_OPERATOR:
default:
return false;
}
}
/**
* Returns the application names in a realm.
*
* @param adminSubject Admin Subject who has the rights to access
* configuration datastore.
* @param realm Realm name.
* @return application names in a realm.
*/
) throws EntitlementException {
}
return results;
}
throws EntitlementException {
return appls;
}
try {
}
return appls;
} finally {
}
}
return appls;
}
// Delegation to applications is currently not configurable, passing super admin (see AME-4959)
}
}
return accessible;
}
/**
* Returns application.
*
* @param realm Realm name.
* @param name Name of Application.
* @return application.
*/
public static Application getApplicationForEvaluation(
) throws EntitlementException {
name);
}
/**
* Returns application.
*
* @param adminSubject Admin Subject who has the rights to access
* configuration datastore.
* @param realm Realm name.
* @param name Name of Application.
* @return application.
*/
public static Application getApplication(
) throws EntitlementException {
}
return appl;
}
}
// try again, to get application for sub realm.
return appl;
}
}
return null;
}
/**
* Removes application.
*
* @param adminSubject Admin Subject who has the rights to access
* configuration datastore.
* @param realm Realm Name.
* @param name Application Name.
* @throws EntitlementException
*/
public static void deleteApplication(
) throws EntitlementException {
if (!allowed) {
}
if (!allowed) {
}
}
}
}
/**
* Saves application data.
*
* @param adminSubject Admin Subject who has the rights to access
* configuration datastore.
* @param realm Realm Name.
* @param application Application object.
*/
public static void saveApplication(
) throws EntitlementException {
if (!allow) {
} else {
}
}
if (!allow) {
throw new EntitlementException(326);
}
throw new EntitlementException(228);
}
// When this class is refactored (AME-6287) this dependency should be injected.
}
}
}
application.getName());
if (creationDate == -1) {
if (principalName != null) {
}
} else {
application.getName());
{
} else {
}
}
}
}
if (principalName != null) {
}
}
private static String getApplicationCreatedBy(
) {
try {
} catch (EntitlementException ex) {
// new application.
return null;
}
}
private static long getApplicationCreationDate(
) {
try {
} catch (EntitlementException ex) {
// new application.
return -1;
}
}
private static boolean isReferredApplication(
realm);
return true;
}
}
return false;
}
private static boolean hasAccessToApplication(
// applicationNames may be empty if the sub realm is removed.
// or the sub realm really do not have referral privilege assigned to
// it. In the latter case, clearing the cache for referral privilege
// should be ok.
return applicationNames.isEmpty() ||
}
private static boolean hasAccessToApplication(
}
private static boolean isNewApplication(
) throws EntitlementException {
return false;
}
}
return true;
}
/**
* Clears the cached applications. Must be called when notifications are
* received for changes to applications.
*/
break;
}
}
}
/**
* Refers resources to another realm.
*
* @param adminSubject Admin Subject who has the rights to access
* configuration datastore.
* @param parentRealm Parent realm name.
* @param referRealm Referred realm name.
* @param applicationName Application name.
* @param resources Referred resources.
* @throws EntitlementException if resources cannot be referred.
*/
public static void referApplication(
) throws EntitlementException {
if (!allowed) {
// Delegation to applications is currently not configurable, passing super admin (see AME-4959)
}
if (!allowed) {
throw new EntitlementException(326);
}
}
}
/**
* Derefers resources from a realm.
*
* @param adminSubject Admin Subject who has the rights to access
* configuration datastore.
* @param referRealm Referred realm name,
* @param applicationName Application name.
* @param resources Resources to be dereferred.
* @throws EntitlementException if resources cannot be dereferred.
*/
public static void dereferApplication(
) throws EntitlementException {
if (!allowed) {
// Delegation to applications is currently not configurable, passing super admin (see AME-4959)
}
if (!allowed) {
throw new EntitlementException(326);
}
}
/**
* Returns referred resources for a realm.
*
* @param adminSubject Admin Subject who has the rights to access
* configuration datastore.
* @param realm Realm name
* @param applicationTypeName Application Type Name.
* @return referred resources for a realm.
* @throws EntitlementException if referred resources cannot be returned.
*/
) throws EntitlementException {
if (!allowed) {
// Delegation to applications is currently not configurable, passing super admin (see AME-4959)
}
if (!allowed) {
return Collections.EMPTY_SET;
}
}
/**
* Creates an application.
*
* @param name Name of application.
* @param applicationType application type.
* @throws EntitlementException if application class is not found.
*/
public static Application newApplication(String name, ApplicationType applicationType) throws EntitlementException {
try {
} catch (NoSuchMethodException ex) {
} catch (SecurityException ex) {
} catch (InstantiationException ex) {
} catch (IllegalAccessException ex) {
} catch (IllegalArgumentException ex) {
} catch (InvocationTargetException ex) {
}
}
/**
* Replaces an existing application with a newer version of itself.
*
* @param oldApplication The application to update
* @param newApplication The updated version of the application
* @retun the new application
*/
public static void updateApplication(Application oldApplication, Application newApplication, Subject subject,
throws EntitlementException {
try {
} finally {
}
}
}