/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 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: AgentConfiguration.java,v 1.52 2010/01/07 18:07:39 veiming Exp $
*
* Portions Copyrighted 2012-2016 ForgeRock AS.
* Portions Copyrighted 2012 Open Source Solution Technology Corporation
*/
/**
* This class provides agent configuration utilities.
*/
public class AgentConfiguration {
"com.sun.identity.agents.config.freeformproperties";
"com.sun.identity.agents.config.repository.location";
static {
localAgentProperties = new HashMap();
while (st.hasMoreTokens()) {
}
}
}
}
private AgentConfiguration() {
}
/**
* Returns a set of supported agent types.
*
* @return a set of supported agent types.
*/
throws SMSException, SSOException
{
}
}
return agentTypes;
}
throws ConfigurationException {
validateAgentType(type, false);
}
throws ConfigurationException {
try {
if (isGroup) {
}
throw new ConfigurationException(
"agent.invalid.type", param);
}
} catch (SMSException e) {
throw new ConfigurationException(e.getMessage());
} catch (SSOException e) {
throw new ConfigurationException(e.getMessage());
}
}
/**
* Creates an agent group.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Realm where group resides.
* @param agentGroupName Name of agent group.
* @param agentType Type of agent group.
* @param attrValues Map of attribute name to its values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if there are missing information in
* server or agent URL; or invalid agent type.
*/
public static void createAgentGroup(
}
/**
* Creates an agent group.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Realm where group resides.
* @param agentGroupName Name of agent group.
* @param agentType Type of agent group.
* @param attrValues Map of attribute name to its values.
* @param serverURL Server URL.
* @param agentURL Agent URL.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws MalformedURLException if server or agent URL is invalid.
* @throws ConfigurationException if there are missing information in
* server or agent URL; or invalid agent type
*/
public static void createAgentGroup(
throw new ConfigurationException(
"create.agent.invalid.server.url", null);
}
}
}
/**
* Creates an agent group.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Name of realm where agent group is going to reside.
* @param agentGroupName Name of agent group.
* @param agentType Type of agent group.
* @param attrValues Map of attribute name to its values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if there are missing information in
* server or agent URL; or invalid agent type.
*/
private static void createAgentGroupEx(
throw new ConfigurationException(
"create.agent.group.missing.name", null);
}
validateAgentType(agentType, true);
throw new ConfigurationException(
"create.agent.group.cannot.have.password", null);
}
//overwrite inherited values with what user has given
agentURL);
}
}
/**
* Creates an agent.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Realm where agent resides.
* @param agentName Name of agent.
* @param agentType Type of agent.
* @param attrValues Map of attribute name to its values.
* @param serverURL Server URL.
* @param agentURL Agent URL.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if there are missing information in
* server or agent URL; or invalid agent type.
*/
public static void createAgent(
throw new ConfigurationException(
"create.agent.invalid.server.url", null);
}
throw new ConfigurationException(
"create.agent.invalid.agent.url", null);
}
try {
} catch (MalformedURLException e) {
throw new ConfigurationException(
"create.agent.invalid.server.url", null);
}
try {
} catch (MalformedURLException e) {
throw new ConfigurationException(
"create.agent.invalid.agent.url", null);
}
}
/**
* Creates a localized agent.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Realm where agent resides.
* @param agentName Name of agent.
* @param agentType Type of agent.
* @param attrValues Map of attribute name to its values.
* @param agentURL Agent URL.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws MalformedURLException if server or agent URL is invalid.
* @throws ConfigurationException if there are missing information in
* server or agent URL; or invalid agent type.
*/
public static void createAgentLocal(
throw new ConfigurationException(
"create.agent.invalid.agent.url", null);
}
}
/**
* Creates an agent.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Realm where agent resides.
* @param agentName Name of agent.
* @param agentType Type of agent.
* @param attrValues Map of attribute name to its values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if there are missing information in
* server or agent URL; or invalid agent type.
*/
}
/**
* Creates an agent.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Name of realm where agent is going to reside.
* @param agentName Name of agent.
* @param agentType Type of agent.
* @param attrValues Map of attribute name to its values.
* @param serverURL Server URL.
* @param agentURL Agent URL.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if there are missing information in
* server or agent URL; or invalid agent type.
*/
throw new ConfigurationException(
"create.agent.missing.name", null);
}
//overwrite inherited values with what user has given
// need to set an arbitrary number to com.iplanet.am.server.port
// so that number validator will pass
map.put("AM_SERVICES_DEPLOY_URI", SystemProperties.get("com.iplanet.am.services.deploymentDescriptor"));
}
// need to set an arbitrary number to com.iplanet.am.server.port
// so that number validator will pass
}
agentURL);
}
}
throws ConfigurationException {
) {
}
}
}
}
throws ConfigurationException {
return;
}
}
}
}
throws ConfigurationException {
return;
}
throw new ConfigurationException(
"agent.root.url.starts.with", null);
}
}
try {
} catch(MalformedURLException e) {
}
if (port == -1) {
throw new ConfigurationException(
"agent.root.url.missing.port", null);
throw new ConfigurationException(
"agent.root.url.port.out.of.range", param);
}
}
/**
* For the given map of user supplied attributeValues, use the keys to find duplicate default
* values and remove them from the finalAttributes which will end up being used to create the
* actual agent configuration.<br>
* For example:
* <pre>
* com.sun.identity.agents.config.notenforced.url=[[0]=] from defaults is transformed into
* com.sun.identity.agents.config.notenforced.url[0]= which then clashes with any supplied values like
* com.sun.identity.agents.config.notenforced.url[0]=[*.gif]
* </pre>
* @param attributeValues a map of values supplied when configuring the agent
* @param finalAttributes a map of values that will be used to create the agent configuration.
*/
public static void removeDefaultDuplicates(Map<String, Set<String>> attributeValues, Map<String, Set<String>> finalAttributes) {
// This is only looking for keys in the form of propertyname[n] where n is usually a value starting from 0
// Remove the characters contained in the "[n]" before using the key to check for a duplicate.
if (endIndex != -1) {
}
}
}
}
}
public static void tagswapAttributeValues(
) throws ConfigurationException {
throw new ConfigurationException(
"create.agent.invalid.server.url", null);
}
if (!serverURL.isFullyQualified()) {
throw new ConfigurationException(
"create.agent.server.url.not.fqdn", null);
}
throw new ConfigurationException(
"create.agent.invalid.server.url.missing.uri", null);
}
throw new ConfigurationException(
"create.agent.invalid.server.url.missing.port", null);
}
}
throw new ConfigurationException(
"create.agent.invalid.agent.url", null);
}
if (!agentURL.isFullyQualified()) {
throw new ConfigurationException(
"create.agent.invalid.agent.url", null);
}
throw new ConfigurationException(
"create.agent.invalid.agent.url.missing.uri", null);
}
throw new ConfigurationException(
"create.agent.invalid.agent.url.uri.not.required",
null);
}
}
}
}
}
private static void tagswapAttributeValues(
Map tagswapInfo) {
}
}
}
return value;
}
}
return value;
}
/**
* Updates agent attribute values.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Name of realm where agent resides.
* @param agentName Name of agent.
* @param attrValues Map of attribute name to its values.
* @param bSet <code>true</code> to overwrite the values for the
* attribute.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if agent does not exist.
*/
public static void updateAgent(
boolean bSet
}
if (!bSet) {
i.hasNext();
) {
}
}
}
) throws SMSException, SSOException {
}
return newValues;
}
if (idx != -1) {
}
}
}
return set;
}
boolean bRemoved = false;
i.remove();
bRemoved = true;
}
}
return bRemoved;
}
/**
* Updates agent group attribute values.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Realm where group resides.
* @param agentGroupName Name group of agent.
* @param attrValues Map of attribute name to its values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if attribute values map contains invalid
* values.
*/
public static void updateAgentGroup(
{
}
/**
* Updates agent group attribute values.
*
* @param ssoToken Single Sign On token that is to be used for creation.
* @param realm Name of realm where agent resides.
* @param agentGroupName Name of agent group.
* @param attrValues Map of attribute name to its values.
* @param bSet <code>true</code> to overwrite the values for the
* attribute.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
* @throws ConfigurationException if attribute values map contains invalid
* values.
*/
public static void updateAgentGroup(
boolean bSet
{
throw new ConfigurationException(
"update.agent.group.cannot.have.password", null);
}
if (!bSet) {
i.hasNext();
) {
}
}
}
/**
* Returns a set of attribute schemas of a given agent type.
*
* @param agentTypeName Name of agent type.
* @return a set of attribute schemas of a given agent type.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
throws SMSException, SSOException {
}
}
i.remove();
}
}
return attrSchemas;
}
throws SMSException, SSOException {
}
return names;
}
/**
* Returns agent group's attribute values.
*
* @param ssoToken Single Sign On token that is to be used for query.
* @param realm Name of realm where agent group resides.
* @param agentGroupName Name of agent group.
* @return agent group's attribute values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
}
}
/**
* Returns agent's attribute values.
*
* @param ssoToken Single Sign On token that is to be used for query.
* @param realm Realm where agent resides.
* @param agentName Name of agent.
* @return agent's attribute values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
)
return getAgentAttributes(amid, true);
}
/**
* Returns agent's attribute values.
*
* @param ssoToken Single Sign On token that is to be used for query.
* @param realm Realm where agent resides.
* @param agentName Name of agent.
* @param bInherit <code>true</code> to inherit from group.
* @return agent's attribute values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
boolean bInherit
return getAgentAttributes(amid, true);
}
/**
* Returns agent's attribute values.
*
* @param amid Identity object.
* @param reformat <code>true</code> to reformat the values.
* @return agent's attribute values.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
if (supportLocalProperties(agentType) &&
) {
}
}
}
}
/**
* For the given Agent identity, return the value that represents the agent type.
* @param amid Identity object containing value.
* @return agent type or empty string if not found.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has expired.
*/
}
throws IdRepoException, SSOException {
boolean isLocal = false;
}
return isLocal;
}
throws SMSException, SSOException {
boolean isAttrFreeFormInSchema = false;
}
}
}
if (!isAttrFreeFormInSchema) {
}
}
}
}
return result;
}
/**
* E.g. abc[0]=x
* abc[1]=y
* where abc is the attribute schema name
* this method will return {[0]=x, [1]=y}.
*/
}
}
}
} else {
}
}
}
}
} else {
}
return results;
}
throws SMSException, SSOException {
}
}
} else {
}
return result;
}
throws SMSException, SSOException {
if (asListType == null) {
}
if (asValidatorType == null) {
}
int deviceKeyIndex = 0;
int idx1 = -1;
if (idx != -1) {
}
} else {
// this is for special case, where attribute
// can be list and non list type
}
}
} else {
}
}
}
}
} else {
}
return result;
}
boolean onlySpaces = true;
}
return onlySpaces;
}
// this is to handle the attribute value like
// my.new.map.property[cn=user1,o=xyz]=value1
if (m.find()) {
} else {
if (idx != -1) {
}
}
}
}
/**
* Returns a set of attribute schema names whose schema match a given
* syntax.
*
* @param amid Identity Object. Agent Type is to be gotten from it.
* @param syntax Syntax.
* @return a set of attribute schema names whose schema match a given
* syntax.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
}
}
}
return results;
}
}
}
return results;
}
/**
* Returns a set of attribute schema names whose schema match a given
* type.
*
* @param agentType Agent type
* @param type AttributeSchema type
* @return a set of attribute schema names whose schema match a given
* type.
* @throws IdRepoException if there are Id Repository related errors.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
) throws SMSException, SSOException {
}
}
}
return results;
}
/**
* Returns resource bundle name of agent service.
*
* @return resource bundle name of agent service.
* @throws SMSException if Service Schema cannot be located.
* @throws SSOException if admin single sign on token has expired.
*/
throws SMSException, SSOException {
}
throws SMSException, SSOException {
}
return ss;
}
/**
* Returns the default values of attribute schemas
* of a given agent type.
*
* @param agentType Type of agent.
* @param bGroup <code>true</code> if this is for a group.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
throws SMSException, SSOException {
}
}
if (bGroup) {
}
return mapDefault;
}
/**
* Returns choice values of an attribute schema.
*
* @param name Name of attribute schema.
* @param agentType Type of agent.
* @return choice values of an attribute schema.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
throws SMSException, SSOException {
}
}
}
return choiceValues;
}
/**
* Returns attribute schema of a given agent type.
*
* @param name Name of attribute schema.
* @param agentTypeName Name of agent type.
* @return attribute schema of a given agent type.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
) throws SMSException, SSOException {
}
return as;
}
/**
* Returns the inherited attribute names.
*
* @param amid Identity object of the agent.
* @return the inherited attribute names.
* @throws IdRepoException if attribute names cannot obtained.
* @throws SSOException if single sign on token is expired or invalid.
*/
}
return attributeSchemaNames;
}
/**
* Updates the inherited attribute names.
*
* @param amid Identity object of the agent.
* @param inherit Map of attribute name to either "1" or "0". "1" to
* inherit and "0" not.
* @throws IdRepoException if attribute names cannot obtained.
* @throws SSOException if single sign on token is expired or invalid.
*/
} else {
}
}
}
if ((defaultValues == null)) {
} else {
}
}
}
if (!resetValues.isEmpty()) {
}
}
/**
* Returns attribute schema for a given set of attribute names.
*
* @param agentType Agent type.
* @param names Set of attribute names.
* @return localized names for a given set of attribute names.
*/
) throws SMSException, SSOException {
}
}
return map;
}
throws SMSException, SSOException {
}
/**
* Adds an agent to a group.
*
* @param group Agent Group.
* @param agent Agent.
* @throws SSOException if Single Sign on for accessing identity attribute
* values is invalid.
* @throws IdRepoException if unable to access attribute values.
* @throws ConfigurationException if agent's properties are locally stored.
*/
throw new ConfigurationException(
"cannot.add.agent.to.group.group.does.not.exist", param);
}
throw new ConfigurationException(
"cannot.add.agent.to.group.agent.does.not.exist", param);
}
if (supportLocalProperties(agentType) &&
) {
throw new ConfigurationException(
"cannot.add.agent.to.group.proeprties.locally.stored", param);
}
throw new ConfigurationException(
"cannot.add.agent.to.group.type.mismatched", param);
}
}
/**
* Returns <code>true</code> if an agent type support local properties.
*
* @param agentType Agent Type.
* @return <code>true</code> if an agent type support local properties.
*/
}
/**
* Returns a set of local property name if an agent type. Returns null
* if agent type does not support local properties.
*
* @param agentType Agent Type.
* @return a set of local property name if an agent type.
*/
}
/**
* Deletes agent groups.
*
* @param ssoToken Single Sign On token that is to be used for deletion.
* @param realm Realm where agent groups reside.
* @param agentGroups Set of Agent Group object.
* @throws IdRepoException if unable to delete groups.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
public static void deleteAgentGroups(
}
}
}
}
}
}
private static void unheritPropertyValues(
}
// This is required because the attribute names that are returned
// but idRepo are all lowered cased.
) {
}
}
}
return results;
}
/**
* Set agent group. Returns <code>true</code> if group is set.
*
* @param ssoToken Single Sign On token that is to be used for this
* operation.
* @param realm Realm name where agent and group reside.
* @param universalId Universal ID of Agent.
* @param groupName Name of Group object to be set.
* @return <code>true</code> if group is set.
* @throws IdRepoException if group cannot be set.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers
*/
public static boolean setAgentGroup(
}
/**
* Set agent group. Returns <code>true</code> if group is set.
*
* @param ssoToken Single Sign On token that is to be used for this
* operation.
* @param realm Realm name where agent and group reside.
* @param amid Agent object.
* @param groupName Name of Group object to be set.
* @return <code>true</code> if group is set.
* @throws IdRepoException if group cannot be set.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers
*/
public static boolean setAgentGroup(
newGroup = new AMIdentity(
}
}
/**
* Set agent group. Returns <code>true</code> if group is set.
*
* @param amid Agent object.
* @param newGroup Group object to be set.
* @return <code>true</code> if group is set.
* @throws IdRepoException if group cannot be set.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers
*/
public static boolean setAgentGroup(
boolean bSet = false;
bSet = true;
}
} else {
bSet = true;
}
} else {
bSet = true;
}
}
return bSet;
}
/**
* Removes agent from it group. Returns <code>true</code> if group is
* removed.
*
* @param amid Agent object.
* @param groupToRemove Group object to be removed.
* @return <code>true</code> if group is removed.
* @throws IdRepoException if group cannot be removed.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers
*/
public static boolean removeAgentGroup(
boolean bRemoved = false;
if (groupToRemove != null) {
bRemoved = true;
}
}
}
return bRemoved;
}
}