use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AMClientCapData method init.
/**
* 1. get the admin token (or create one) 2. Create a ServiceManager 3. Get
* the ServiceSchemaManager for the service 4. Get the ServiceSchema for the
* Global schema 5. Get the schema for the "internalData" schema. (temp
* var). 6. Get the schema for the "clientData" schema id. (overwrite 8). 7.
* Get the ROOT_SUFFIX 8. Read config info & properties schema from
* ServiceSchema 9. Add Listeners to EventService.
*/
private synchronized void init(String instanceRDN) throws Exception {
// "SunAMClientData"
String srvcName = getServiceName();
if (adminToken == null) {
// single static instance
adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
// (2)
sManager = new ServiceManager(adminToken);
ServiceSchemaManager schemaManager = sManager.getSchemaManager(srvcName, // (3)
SERVICE_VERSION);
// (4)
clientServiceSchema = schemaManager.getGlobalSchema();
//
// the internalDB & externalDB share the same schema (5)
//
clientSchema = clientServiceSchema.getSubSchema(DBSTORE_SUBSCHEMA_ID);
//(6)
clientSchema = clientSchema.getSubSchema(CLIENT_SUBSCHEMA_ID);
amConnection = new AMStoreConnection(adminToken);
// (7)
topLevelDN = amConnection.getOrganizationDN(null, null);
// (8)
initClientSchema();
initConfigurationInfo(clientServiceSchema);
clientDataDN = CLIENT_DATA_DN_PREFIX + COMMA + topLevelDN;
// TBD : Commented so that persistant search is not setup to
// directory server when running in remote client SDK mode.
// This is temporary fix. Proper fix for this problem is TBD.
// initEventListeners (adminToken, clientDataDN); // (9)
}
databaseDN = instanceRDN + COMMA + clientDataDN;
amClientOrg = amConnection.getOrganizationalUnit(databaseDN);
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class ImportConfig method main.
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.err.println("usage: serverAdmin import xmlFile");
System.exit(1);
}
if (args[0].equals("import")) {
try {
FileInputStream fisSchema = new FileInputStream(args[1]);
DSConfigMgr cfgMgr = DSConfigMgr.getDSConfigMgr();
ServerInstance sInst = cfgMgr.getServerInstance(LDAPUser.Type.AUTH_ADMIN);
authPcpl = new AuthPrincipal(sInst.getAuthID());
AuthContext authCtx = new AuthContext(authPcpl, sInst.getPasswd().toCharArray());
SSOToken userSSOToken = authCtx.getSSOToken();
ServiceManager smsMgr = new ServiceManager(userSSOToken);
smsMgr.registerServices(fisSchema);
} catch (Exception e) {
e.printStackTrace();
System.err.println(e);
}
}
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AMIdentity method getAssignableServices.
/**
* Returns all services which can be assigned to this entity.
*
* This method is only valid for AMIdentity object of type User.
*
* @return Set of service names
* @throws IdRepoException
* if there are repository related error conditions.
* @throws SSOException
* If user's single sign on token is invalid.
* @supported.api
*/
public Set getAssignableServices() throws IdRepoException, SSOException {
// Get all service names for the type from SMS
ServiceManager sm;
try {
sm = new ServiceManager(token);
} catch (SMSException smse) {
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.SERVICE_MANAGER_INITIALIZATION_FAILED, null);
}
Map sMap = sm.getServiceNamesAndOCs(type.getName());
// Get the list of assigned services
IdServices idServices = IdServicesFactory.getDataStoreServices();
Set assigned = Collections.EMPTY_SET;
try {
assigned = idServices.getAssignedServices(token, type, name, sMap, orgName, univDN);
} catch (IdRepoException ide) {
// Check if this is permission denied exception
if (!ide.getErrorCode().equals(IdRepoErrorCode.ACCESS_DENIED)) {
throw (ide);
} else {
// Return the empty set
return (assigned);
}
}
// Return the difference
Set keys = sMap.keySet();
keys.removeAll(assigned);
return (keys);
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AMIdentity method getAssignedServices.
// SERVICE RELATED APIS
/**
* Returns the set of services already assigned to this identity.
*
* This method is only valid for AMIdentity object of type User.
*
* @return Set of serviceNames
* @throws IdRepoException
* If there are repository related error conditions.
* @throws SSOException
* If user's single sign on token is invalid.
* @supported.api
*/
public Set getAssignedServices() throws IdRepoException, SSOException {
// Get all service names for the type from SMS
ServiceManager sm;
try {
sm = new ServiceManager(token);
} catch (SMSException smse) {
debug.error("Error while creating Service manager:", smse);
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.SERVICE_MANAGER_INITIALIZATION_FAILED, null);
}
Map sMap = sm.getServiceNamesAndOCs(type.getName());
// Get the list of assigned services
IdServices idServices = IdServicesFactory.getDataStoreServices();
Set assigned = Collections.EMPTY_SET;
try {
assigned = idServices.getAssignedServices(token, type, name, sMap, orgName, univDN);
} catch (IdRepoException ide) {
// Check if this is permission denied exception
if (!ide.getErrorCode().equals(IdRepoErrorCode.ACCESS_DENIED)) {
throw (ide);
}
}
return (assigned);
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class UpgradeUtils method createService.
public static void createService(String xml, SSOToken adminSSOToken) throws UpgradeException {
String classMethod = "UpgradeUtils:createService : ";
InputStream serviceStream = null;
try {
ServiceManager serviceManager = new ServiceManager(adminSSOToken);
serviceStream = (InputStream) new ByteArrayInputStream(xml.getBytes());
serviceManager.registerServices(serviceStream);
} catch (SSOException ssoe) {
debug.error(classMethod + ssoe.getMessage());
throw new UpgradeException(ssoe);
} catch (SMSException smse) {
debug.error(classMethod + smse.getMessage());
throw new UpgradeException(smse);
} finally {
if (serviceStream != null) {
try {
serviceStream.close();
} catch (IOException ioe) {
throw new UpgradeException(ioe);
}
}
}
}
Aggregations