use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class CLIUtil method getPasswordFields.
/**
* Returns a set of attributes (of password syntax) of a given service.
*
* @param serviceName Name of service.
* @return a set of attributes (of password syntax) of a given service.
* @throws SMSException if error occurs when reading the service schema
* layer
* @throws SSOException if Single sign-on token is invalid.
*/
public static Set getPasswordFields(String serviceName) throws SMSException, SSOException {
Set setPasswords = new HashSet();
SSOToken ssoToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, ssoToken);
if (ssm != null) {
ServiceSchema schema = ssm.getOrganizationSchema();
if (schema != null) {
Set attributeSchemas = schema.getAttributeSchemas();
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
if (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD)) {
setPasswords.add(as.getName());
}
}
}
}
return setPasswords;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class CLIUtil method getPasswordFields.
/**
* Returns a set of attributes (of password syntax) of a given service.
*
* @param serviceName Name of service.
* @param schemaType Type of Schema.
* @param subSchema Name of SubSchema
* @return a set of attributes (of password syntax) of a given service.
* @throws SMSException if error occurs when reading the service schema
* layer
* @throws SSOException if Single sign-on token is invalid.
*/
public static Set getPasswordFields(String serviceName, SchemaType schemaType, String subSchema) throws SMSException, SSOException {
Set setPasswords = new HashSet();
SSOToken ssoToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, ssoToken);
if (ssm != null) {
ServiceSchema schema = ssm.getSchema(schemaType);
if (schema != null) {
ServiceSchema ss = schema.getSubSchema(subSchema);
Set attributeSchemas = ss.getAttributeSchemas();
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
if (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD)) {
setPasswords.add(as.getName());
}
}
}
}
return setPasswords;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class ComplianceServicesImpl method getDeletedObjectFilter.
/**
* Protected method to get the search filter to be used for searching for
* deleted objects.
*
*/
public String getDeletedObjectFilter(int objectType) throws AMException, SSOException {
Set values = new HashSet();
try {
if (gsc == null) {
ServiceSchemaManager scm = new ServiceSchemaManager(ADMINISTRATION_SERVICE, internalToken);
gsc = scm.getGlobalSchema();
}
Map attrMap = gsc.getAttributeDefaults();
if (attrMap != null)
values = (Set) attrMap.get(COMPLIANCE_SPECIAL_FILTER_ATTR);
if (debug.messageEnabled()) {
debug.message("Compliance.getDeletedObjectSearchFilter = " + values.toString());
}
} catch (SMSException ex) {
debug.error(AMSDKBundle.getString("359"), ex);
throw new AMException(AMSDKBundle.getString("359"), "359");
} catch (SSOException ex) {
debug.error(AMSDKBundle.getString("359"), ex);
throw new AMException(AMSDKBundle.getString("359"), "359");
}
String org_filter = null;
String group_filter = null;
String user_filter = null;
String def_filter = null;
String res_filter = null;
Iterator iter = values.iterator();
while (iter.hasNext()) {
String thisFilter = (String) iter.next();
if (thisFilter.startsWith("Organization=")) {
org_filter = thisFilter.substring(13);
} else if (thisFilter.startsWith("Group=")) {
group_filter = thisFilter.substring(6);
} else if (thisFilter.startsWith("User=")) {
user_filter = thisFilter.substring(5);
} else if (thisFilter.startsWith("Misc=")) {
def_filter = thisFilter.substring(5);
} else if (thisFilter.startsWith("Resource=")) {
res_filter = thisFilter.substring(9);
}
}
org_filter = (org_filter == null) ? DEFAULT_DELETED_ORG_FILTER : org_filter;
group_filter = (group_filter == null) ? DEFAULT_DELETED_GROUP_FILTER : group_filter;
user_filter = (user_filter == null) ? DEFAULT_DELETED_USER_FILTER : user_filter;
def_filter = (def_filter == null) ? DEFAULT_DELETED_OBJECT_FILTER : def_filter;
res_filter = (res_filter == null) ? DEFAULT_DELETED_RESOURCE_FILTER : res_filter;
switch(objectType) {
case AMObject.ORGANIZATION:
return (org_filter);
case AMObject.USER:
return (user_filter);
case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
case AMObject.DYNAMIC_GROUP:
case AMObject.STATIC_GROUP:
case AMObject.GROUP:
return (group_filter);
case AMObject.RESOURCE:
return (res_filter);
default:
return ("(|" + org_filter + group_filter + user_filter + def_filter + res_filter + ")");
}
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class DirectoryServicesImpl method getServiceAttributesWithQualifier.
/**
* Method to get the attribute names of a service with CosQualifier. For
* example: Return set could be ["iplanet-am-web-agent-allow-list
* merge-schemes", "iplanet-am-web-agent-deny-list merge-schemes"] This only
* returns Dynamic attributes
*/
private Set getServiceAttributesWithQualifier(SSOToken token, String serviceName) throws SMSException, SSOException {
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
ServiceSchema ss = null;
try {
ss = ssm.getSchema(SchemaType.DYNAMIC);
} catch (SMSException sme) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.getServiceNames(): No " + "schema defined for SchemaType.DYNAMIC type");
}
}
if (ss == null) {
return Collections.EMPTY_SET;
}
Set attrNames = new HashSet();
Set attrSchemaNames = ss.getAttributeSchemaNames();
Iterator itr = attrSchemaNames.iterator();
while (itr.hasNext()) {
String attrSchemaName = (String) itr.next();
AttributeSchema attrSchema = ss.getAttributeSchema(attrSchemaName);
String name = attrSchemaName + " " + attrSchema.getCosQualifier();
attrNames.add(name);
}
return attrNames;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class AMAuthenticationManager method createAuthenticationInstance.
/**
* Creates an <code>AMAuthenticationInstance</code> instance with the
* specified parameters.
*
* @param name Name of the authentication module instance.
* @param type Type of the authentication module instance.
* @param attributes A Map of parameters for this module instance.
* @return <code>AMAuthenticationInstance</code> object is newly created.
* @throws AMConfigurationException if error occurred during the
* authentication creation.
*/
public AMAuthenticationInstance createAuthenticationInstance(String name, String type, Map attributes) throws AMConfigurationException {
if (name.indexOf(' ') != -1) {
throw new AMConfigurationException(BUNDLE_NAME, "invalidAuthenticationInstanceName", null);
}
Set moduleTypes = getAuthenticationTypes();
if (!moduleTypes.contains(type)) {
throw new AMConfigurationException(BUNDLE_NAME, "wrongType", new Object[] { type });
}
AMAuthenticationInstance instance = getAuthenticationInstance(name);
if (instance != null) {
if (instance.getServiceConfig() != null) {
throw new AMConfigurationException(BUNDLE_NAME, "authInstanceExist", new Object[] { name });
} else {
throw new AMConfigurationException(BUNDLE_NAME, "authInstanceIsGlobal", new Object[] { name });
}
}
String serviceName = getServiceName(type);
ServiceSchema schema = null;
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
schema = ssm.getSchema(SchemaType.GLOBAL);
} catch (SSOException e) {
if (DEBUG.warningEnabled()) {
DEBUG.warning("Token doesn't have access to service: " + token + " -> " + serviceName);
}
} catch (SMSException e) {
// normal exception for service without global configuration.
// no need to log anything.
}
try {
OrganizationConfigManager ocm = new OrganizationConfigManager(token, realm);
// Check if service is assigned
if (!ocm.getAssignedServices().contains(serviceName)) {
ocm.assignService(serviceName, null);
}
ServiceConfig orgConfig = ocm.getServiceConfig(serviceName);
if (orgConfig == null) {
orgConfig = ocm.addServiceConfig(serviceName, null);
}
ServiceConfig subConfig = orgConfig;
if (!name.equals(type)) {
orgConfig.addSubConfig(name, ISAuthConstants.SERVER_SUBSCHEMA, 0, attributes);
subConfig = orgConfig.getSubConfig(name);
} else {
// if the module instance name equals to its type, set the
// the attributes in its organization config, not sub config.
subConfig.setAttributes(attributes);
}
//AMAuthLevelManager listeners are in place, so let's reinitialize to be on the safe side.
if (!SystemProperties.isServerMode()) {
buildModuleInstanceForService(realm, serviceName);
}
return new AMAuthenticationInstance(name, type, subConfig, schema);
} catch (Exception e) {
throw new AMConfigurationException(e);
}
}
Aggregations