use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class NamingService method initialize.
public static void initialize() {
namingDebug = Debug.getInstance("amNaming");
platformProperties = SystemProperties.getAll();
server_proto = platformProperties.getProperty("com.iplanet.am.server.protocol", "");
server_host = platformProperties.getProperty("com.iplanet.am.server.host", "");
server_port = platformProperties.getProperty(Constants.AM_SERVER_PORT, "");
PrivilegedAction<SSOToken> adminAction = InjectorHolder.getInstance(Key.get(new TypeLiteral<PrivilegedAction<SSOToken>>() {
}));
sso = AccessController.doPrivileged(adminAction);
try {
ssmNaming = new ServiceSchemaManager(NAMING_SERVICE, sso);
ssmPlatform = new ServiceSchemaManager(PLATFORM_SERVICE, sso);
serviceRevNumber = ssmPlatform.getRevisionNumber();
} catch (SMSException | SSOException e) {
throw new IllegalStateException(e);
}
ServiceListeners.Action action = new ServiceListeners.Action() {
@Override
public void performUpdate() {
try {
updateNamingTable();
WebtopNaming.updateNamingTable();
} catch (Exception ex) {
namingDebug.error("Error occured in updating naming table", ex);
}
}
};
ServiceListeners builder = InjectorHolder.getInstance(ServiceListeners.class);
builder.config(NAMING_SERVICE).global(action).schema(action).listen();
builder.config(PLATFORM_SERVICE).global(action).schema(action).listen();
}
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;
}
Aggregations