/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 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: IDFFMetaManager.java,v 1.9 2009/10/28 23:58:57 exu Exp $
*
*/
/**
* The <code>IDFFMetaManager</code> provides methods to manage the Service and
* Identity Provider and Affiliation Metadata ,
* the Entity Configuration.
*/
public class IDFFMetaManager {
/**
* Constant used to identify meta alias.
*/
static {
try {
} catch (ConfigurationException ce) {
}
if (idffMetaConfigInstanceStatic != null) {
try {
new IDFFMetaServiceListener());
} catch (ConfigurationException ce) {
+ "ConfigurationListener for IDFF Meta service",ce);
}
}
try {
cotManagerStatic = new CircleOfTrustManager();
} catch (COTException ce) {
}
}
/**
* Constructor.
*
* @param session handle to the session object.
* @throws IDFFMetaException if there is an error creating this object.
*/
} else {
try {
} catch (ConfigurationException ce) {
throw new IDFFMetaException(ce);
} catch (COTException cex) {
throw new IDFFMetaException(cex);
}
}
if (idffMetaConfigInstance == null) {
+ "IDFF Meta Service");
}
}
/**
* Creates the standard metadata entity descriptor.
* The metadata is created under the realm.
*
* @param realm The realm under which the entity resides.
* @param entityDescriptor The standard entity descriptor object to
* be created.
* @throws IDFFMetaException if unable to create the entity descriptor.
*/
public void createEntityDescriptor(
throws IDFFMetaException
{
if (entityDescriptor == null) {
} else {
}
}
realm = ROOT_REALM;
}
if (descriptor != null) {
}
}
} else {
try {
if (debug.messageEnabled()) {
}
args);
} catch (ConfigurationException ce) {
throw new IDFFMetaException(ce);
} catch (UnsupportedOperationException uoe) {
"Creating EntityDescriptor : Unsupported operation");
} catch (JAXBException jaxbe) {
args);
}
}
}
/**
* Returns the standard metadata entity descriptor under the realm.
* @param realm The realm under which the entity resides.
* @param entityID identifier of the entity to be retrieved.
* @return <code>EntityDescriptorElement</code> for the entity or null if
* not found.
* @throws IDFFMetaException if unable to retrieve the entity descriptor.
*/
throws IDFFMetaException {
if (debug.messageEnabled()) {
}
realm = ROOT_REALM;
}
// retrieve from cache
if (callerSession == null) {
}
if (entityDescriptor == null) {
try {
if (object instanceof EntityDescriptorElement) {
} else {
+ " meta value for : " + entityID);
}
}
}
} catch (ConfigurationException ce) {
throw new IDFFMetaException(
"cannotRetreiveEntityDescriptor",null);
} catch (JAXBException jaxbe) {
throw new IDFFMetaException(
"invalidEntityDescriptor", args);
}
}
if (entityDescriptor != null) {
}
} else {
}
return entityDescriptor;
}
/**
* Sets the standard metadata entity descriptor under the realm.
* The EntiyDescriptor to be set should exist otherwise an error is
* thrown.
*
* @param realm The realm under which the entity resides.
* @param entityDescriptor The standard entity descriptor object to be set.
* @throws IDFFMetaException if there is an error setting the entity
* descriptor.
* @see #createEntityDescriptor(String, EntityDescriptorElement)
*/
public void setEntityDescriptor(
throws IDFFMetaException {
if (entityDescriptor != null) {
realm = ROOT_REALM;
}
try {
entityID);
} else {
}
} catch (ConfigurationException ce) {
throw new IDFFMetaException(ce);
} catch (JAXBException jaxbe) {
args);
}
}
}
/**
* Deletes the standard metadata entity descriptor under the realm.
* @param realm The realm under which the entity resides.
* @param entityID identifier of the entity to be deleted.
* @throws IDFFMetaException if there is an error deleting the entity
* descriptor.
*/
throws IDFFMetaException {
} else {
realm = ROOT_REALM;
}
try {
}
} catch (ConfigurationException ce) {
throw new IDFFMetaException(ce);
} catch (UnsupportedOperationException uoe) {
}
}
}
/**
* Deletes the extended entity configuration.
* @param realm The realm under which the entity resides.
* @param entityId The ID of the entity for whom the extended entity
* configuration will be deleted.
* @throws IDFFMetaException if unable to delete the entity descriptor.
*/
throws IDFFMetaException {
} else {
realm = ROOT_REALM;
}
try {
}
}
} catch (ConfigurationException e) {
args);
throw new IDFFMetaException(e);
} catch (UnsupportedOperationException uoe) {
}
}
}
/**
* Returns the Service Provider's Descriptor for the
* entity identifier. If there are more then one Service Providers
* the first one retrieved is returned.
* @param realm The realm under which the entity resides.
* @param entityID Entity Identifier to retrieve Service Provider from.
* @return <code>SPDescriptorType</code> for the provider. A null is
* returned if no Service Provider is found.
* @throws IDFFMetaException if there is an error retreiving the provider.
*/
throws IDFFMetaException {
}
/**
* Returns Identity Provider's Descriptor for the
* entity identifier. If there are more then one Identity Providers
* the first one retrieved is returned.
* @param realm The realm under which the entity resides.
* @param entityID Entity Identifier to retrieve Identity Provider from.
* @return <code>IDPDescriptorType</code> for the entity. A null is
* returned if no Identity Provider is found.
* @throws IDFFMetaException if there is an error retreiving the provider.
*/
throws IDFFMetaException {
}
/**
* Returns the Affiliation Descriptor for the entity identifier.
*
* @param realm The realm under which the entity resides.
* @param entityID Entity Identifier to retrieve Affiliation Descriptor
* from.
* @return <code>AffiliationDescriptorType</code> the Affliation
* descriptor.
* @throws IDFFMetaException if there is an error retreiving the
* affiliation.
*/
throws IDFFMetaException {
if (entityDescriptor != null) {
}
return affiliationDescriptor;
}
/**
* Creates the extended entity configuration under the realm.
*
* @param realm The realm under which the entity configuration will be
* created.
* @param entityConfig extended entity configuration to be created.
* @throws IDFFMetaException if unable to create the entity configuration.
*/
public void createEntityConfig(
throws IDFFMetaException {
if (entityConfig == null) {
} else {
}
}
realm = ROOT_REALM;
}
try {
entityID);
if (debug.messageEnabled()) {
entityID + " does not exist");
}
}
if (!origValues.isEmpty()) {
if (debug.messageEnabled()) {
"Use setEntityConfig to set the configuration");
}
}
if (debug.messageEnabled()) {
}
// add entity to the circle of trust
} catch (ConfigurationException ce) {
throw new IDFFMetaException(ce);
} catch (UnsupportedOperationException uoe) {
throw new IDFFMetaException(uoe);
} catch (JAXBException jaxbe) {
}
}
/**
* Returns extended entity configuration under the realm.
*
* @param realm The realm under which the entity resides.
* @param entityID identifier of the entity whose config is to be
* retrieved.
* @return <code>EntityConfigElement</code> object of the entity or null
* if the entity configuration does not exist.
* @throws IDFFMetaException if unable to retrieve the entity
* configuration.
*/
throws IDFFMetaException {
realm = ROOT_REALM;
}
if (callerSession == null) {
// retrieve config from cache
}
if (entityConfig == null) {
try {
if (object instanceof EntityConfigElement) {
} else {
+ entityID);
}
}
}
} catch (ConfigurationException ce) {
throw new IDFFMetaException(
"cannotRetreiveEntityConfig",null);
} catch (JAXBException jaxbe) {
}
}
if (entityConfig != null) {
}
} else {
}
return entityConfig ;
}
/**
* Sets the extended entity configuration under the realm.
* The EntityConfig should exist in order to set attributes in
* the EntityConfig.
*
* @param realm The realm under which the entity resides in
* @param entityConfig The extended entity configuration object to be set.
* @throws IDFFMetaException if unable to set the entity configuration.
*/
throws IDFFMetaException {
if (entityConfig != null) {
realm = ROOT_REALM;
}
try {
entityID);
} else {
if (debug.messageEnabled()) {
}
}
} catch (ConfigurationException ce) {
throw new IDFFMetaException(ce);
} catch (JAXBException jaxbe) {
}
}
}
/**
* Returns Service Provider's Configuration for the entity identifier.
* If there are multiple service providers found then the first one
* retrieved is returned.
*
* @param realm The realm under which the entity resides.
* @param entityID ID of the entity to be retrieved.
* @return <code>SPDescriptorConfigElement</code> for the entity
* identifier . A null is returned if the configuration
* is not found.
* @throws IDFFMetaException if there is an error retrieving service
* provider configuration.
*/
throws IDFFMetaException
{
}
/**
* Returns Identity Provider's Configuration for the entity identifier.
* If there are multiple identity providers found then the first one
* retrieved is returned.
* @param realm The realm under which the entity resides.
* @param entityID ID of the entity to be retrieved.
* @return <code>IDPDescriptorConfigElement</code> for the entity
* identifier . A null is returned if the configuration
* is not found.
* @throws IDFFMetaException if there is an error retrieving service
* provider configuration.
*/
throws IDFFMetaException
{
}
/**
* Returns Affiliation Configuration for the entity identifier.
*
* @param realm The realm under which the entity resides.
* @param entityID ID of the entity to be retrieved.
* @return <code>AffiliationDescriptorConfigElement</code> for the entity
* identifier . A null is returned if the configuration
* is not found.
* @throws IDFFMetaException if there is an error retrieving service
* provider configuration.
*/
throws IDFFMetaException {
if (entityConfig != null) {
}
return affiliationDesConfig;
}
/**
* Returns all entities under the realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>Set</code> of entity ID <code>String</code>.
* @throws IDFFMetaException if unable to retrieve the entity ids.
*/
try {
}
} catch (ConfigurationException e) {
throw new IDFFMetaException(e);
}
return entityIDSet;
}
/**
* Returns all remote entities under the realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of entity identifiers as Strings.
* @throws IDFFMetaException if unable to retrieve the remote entity
* identifiers.
*/
try {
while (entityIterator.hasNext()) {
}
}
}
} catch (ConfigurationException e) {
throw new IDFFMetaException(e);
}
return hostedEntityList;
}
/**
* Returns all remote entities under the realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of entity identifiers as Strings.
* @throws IDFFMetaException if unable to retrieve the remote entity
* identifiers.
*/
try {
while (entityIterator.hasNext()) {
}
}
}
} catch (ConfigurationException e) {
throw new IDFFMetaException(e);
}
return remoteEntityList;
}
/**
* Returns all hosted Service Provider Entity Identifiers under the
* realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of entity identifiers as Strings.
* @throws IDFFMetaException if unable to retrieve the entity ids.
*/
throws IDFFMetaException {
while (entityIterator.hasNext()) {
}
}
return hostedSPEntityList;
}
/**
* Returns all remote Service Provider Entity Identifiers under the
* realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of entity identifiers as Strings.
* @throws IDFFMetaException if unable to retrieve the entity ids.
*/
throws IDFFMetaException {
while (entityIterator.hasNext()) {
}
}
return remoteSPEntityList;
}
/**
* Returns all hosted Identity Provider Entity Identifiers under the
* realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of identity provider entity identifiers.
* The values in the list are Strings.
* @throws IDFFMetaException if unable to retrieve the entity ids.
*/
throws IDFFMetaException {
while (entityIterator.hasNext()) {
}
}
return hostedIDPEntityList;
}
/**
* Returns all remote Identity Provider Identifiers under the realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of remote identity provider identifiers.
* The values in the list are Strings.
* @throws IDFFMetaException if unable to retrieve the provider identifiers.
*/
throws IDFFMetaException {
while (entityIterator.hasNext()) {
}
}
return remoteIDPEntityList;
}
/**
* Checks whether two entities are in the same circle of trust.
*
* @param realm The realm under which the entity resides.
* @param hostedEntityID the hosted entity identifier.
* @param entityID the identifier of the entity to be checked for trust.
* @return true if both providers are in the same circle of trust.
*/
public boolean isTrustedProvider(
{
boolean isTrusted = false;
try {
} else {
}
}
} catch (IDFFMetaException ide) {
}
return isTrusted;
}
/**
* Returns a set of remote providers trusted by the hosted providers.
*
* @param hostedProviderMetaAlias the metaAlias of the hosted provider.
* @return a set of trusted remote providers. An empty set is returned
* if there is an error or no trusted providers are found.
*/
try {
}
}
}
}
}
}
} catch (COTException cote) {
} catch (IDFFMetaException ide) {
}
if (debug.messageEnabled()) {
+ trustedProviders);
}
return trustedProviders;
}
/**
* Checks if the provider is a member of the Affiliation.
*
* @param realm The realm under which the entity resides.
* @param providerID the provider's identitifer.
* @param affiliationID the Affiliation identifier.
*
* @return true if the provider is a member of the affiliation.
* @throws IDFFMetaException if there is an error retreiving the affiliate
* information.
*/
public boolean isAffiliateMember(
throws IDFFMetaException {
boolean isAffiliateMember = false;
realm = ROOT_REALM;
}
while (entityIterator.hasNext()) {
if (affDescriptor != null) {
if (affMemberList != null &&
!affMemberList.isEmpty() &&
isAffiliateMember = true;
break;
}
}
}
}
}
}
return isAffiliateMember;
}
/**
* Returns a set of Affiliation Entity Descriptors of which the
* provider identifier is a member of.
*
* @param realm The realm under which the entity resides.
* @param providerID the provider identifier.
* @return a set of Affliation Entity Descriptors. An empty set is
* returned if there are no affiliation descriptors found or
* if there is an retrieving the descriptors.
*/
realm = ROOT_REALM;
}
try {
}
}
}
}
} catch (IDFFMetaException ide) {
if (debug.messageEnabled()) {
"Error getting affiliate entities",ide);
}
}
return affDescSet;
}
/**
* Returns entity ID associated with the metaAlias.
*
* @param metaAlias The Meta Alias of the provider.
* @return entity ID associated with the metaAlias or null if not found.
* @throws IDFFMetaException if unable to retrieve the entity id.
*/
throws IDFFMetaException {
try {
return null;
}
// check cache first
if (debug.messageEnabled()) {
+ " found entity in cache, metaAlias=" + metaAlias
+ ", ID=" + entityId);
}
return entityId;
}
return null;
}
if (debug.messageEnabled()) {
+ " process entity cache for metaAlias=" + metaAlias
+ ", ID=" + tmpId);
}
// remember this and continue to process others,
}
tmpId);
if (debug.messageEnabled()) {
"IDFFMetaManager.getEntityByMetaAlias :"
+ " save to cache, metaAlias=" + tmpMetaAlias
}
}
}
// remember this and continue to process others,
}
tmpId);
if (debug.messageEnabled()) {
"IDFFMetaManager.getEntityByMetaAlias :"
+ " save to cache, metaAlias=" + tmpMetaAlias
+ IFSConstants.IDP);
}
}
}
}
return entityId;
} catch (ConfigurationException e) {
throw new IDFFMetaException(e);
}
}
/**
* Returns entity role associated with the metaAlias.
*
* @param metaAlias The Meta Alias of the provider.
* @return role of the provider with the metaAlias or null if not found.
* @throws IDFFMetaException if unable to retrieve the entity role.
*/
throws IDFFMetaException {
return null;
} else {
}
}
/**
* Returns entity ID associated with the succinct ID.
*
* @param realm The realm under which the entity resides.
* @param succinctId Succinct ID of a IDP contained in the entity
* to be retrieved.
* @return Entity ID associated with the succinct ID, or null if could
* not be found.
* @throws IDFFMetaException if unable to retrieve the entity ID.
*/
throws IDFFMetaException {
try {
return null;
}
// check cache first
if (debug.messageEnabled()) {
+ " found entity in cache, succinctId=" + succinctId
+ ", ID=" + entityId);
}
return entityId;
}
realm = ROOT_REALM;
}
return null;
}
if (debug.messageEnabled()) {
+ " process entity cache for succinctID="
}
if ((tmpSuccinctId != null) &&
// remember this and continue to process others,
}
if (debug.messageEnabled()) {
+ ": update cache, succinctId=" + tmpSuccinctId
+ ", entity ID=" + tmpId);
}
}
}
return entityId;
} catch (ConfigurationException e) {
throw new IDFFMetaException(e);
}
}
/**
* Checks if the remote entity identifier is in the Entity Config's
* circle of trust.
*
* @param realm The realm under which the entity resides.
* @param config the entity config object.
* @param entityID the entity identifer.
*/
private boolean isSameCircleOfTrust(
{
boolean isTrusted = false;
isTrusted = true;
}
}
}
}
return isTrusted;
}
/**
* Adds entity identifier to circle of trust.
*
* @param realm The realm under which the entity resides.
* @param config the entity config.
* @param entityId the entity identifier.
*/
{
try {
try {
} catch (COTException ce) {
}
}
}
}
} catch (Exception e) {
+ entityId + " to COT.",e);
}
}
/**
* Remove entity identifier from circle of trust.
*
* @param realm The realm under which the entity resides.
* @param config the <code>BaseConfigType</code> object
* which is the entity config.
* @param entityId the entity identifier.
*/
private void removeFromCircleOfTrust(
{
try {
try {
} catch (COTException ce) {
if (debug.messageEnabled()) {
+ cotName);
}
}
}
}
}
}
} catch (Exception e) {
}
}
/**
* Adds an entity identifier to circle of trust.
*
* @param realm The realm under which the entity resides in
* @param entityID the entity identifier.
* @throws IDFFMetaException if there is an error adding entity to circle
* of trust.
*/
throws IDFFMetaException
{
}
}
}
/**
* Removes and entity identifier from circle of trust.
* @param realm The realm under which the entity resides.
* @param entityID the entity identifier.
* @throws IDFFMetaException if there is an error remove entity.
*/
throws IDFFMetaException
{
}
}
if (affiConfig != null) {
}
}
}