use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ApplicationCacheAfterRealmChangeTest method cleanup.
@AfterClass
public void cleanup() throws Exception {
if (!migrated) {
return;
}
OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
String subRealm = SUB_REALM.substring(1);
ocm.deleteSubOrganization(subRealm, true);
setOrgAlias(false);
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class CanBeDeletedAppTest method setup.
@BeforeClass
public void setup() throws Exception {
if (!migrated) {
return;
}
OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
String subRealm = SUB_REALM.substring(1);
ocm.createSubOrganization(subRealm, Collections.EMPTY_MAP);
createAppl();
createPrivilege();
createApplicationPrivilege();
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class AgentMigration71 method migrate22AgentsToFAM80.
public static void migrate22AgentsToFAM80() {
try {
// Assuming upgrade scripts imported the OpenSSO
// AgentService.xml,
// migrate agents from existing DIT (AM 6.x/AM 7.x to OpenSSO
// Enterprise 8.0.
SSOToken token = getSSOToken();
// First get all the sub realms
OrganizationConfigManager ocmGet = new OrganizationConfigManager(token, "/");
Set getSet = new HashSet();
getSet.add(SMSEntry.getRootSuffix());
Set orgSet = ocmGet.getSubOrganizationNames();
if (!orgSet.isEmpty()) {
getSet.addAll(orgSet);
}
System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_START));
Object[] args = { getSet.toString() };
System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_GETTING_SUBREALMS, args));
String p = IdConstants.AGENTREPO_PLUGIN;
Class thisClass = Class.forName(p);
IdRepo thisPlugin = (IdRepo) thisClass.newInstance();
// identities from IdRepo node.
for (Iterator items = getSet.iterator(); items.hasNext(); ) {
String realm = (String) items.next();
AMIdentityRepository idRepo = new AMIdentityRepository(token, realm);
IdSearchResults results = idRepo.searchIdentities(IdType.AGENT, "*", new IdSearchControl());
Iterator it = results.getSearchResults().iterator();
while (it.hasNext()) {
AMIdentity iden = (AMIdentity) it.next();
String idName = iden.getName();
Object[] args1 = { idName };
System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_IDNAME, args1));
Map attrs = iden.getAttributes();
attrs.remove("cn");
attrs.remove("dn");
attrs.remove("objectclass");
attrs.remove("sunidentityserverdevicetype");
attrs.remove("sunidentityserverdeviceversion");
attrs.remove("uid");
if (attrs.containsKey("sunidentityserverdevicestatus")) {
// To match the schema in OpenSSO's
// AgentService.xml
Set dSet = (Set) attrs.get("sunidentityserverdevicestatus");
attrs.remove("sunidentityserverdevicestatus");
attrs.put("sunIdentityServerDeviceStatus", dSet);
}
Object[] args2 = { attrs.toString() };
System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_AGENT_ATTRIBUTES, args2));
thisPlugin.create(token, IdType.AGENTONLY, idName, attrs);
}
// Now upgrade scripts should reset the revision number of
// idRepoService.xml from 20 to 30 to add the AgentRepo
// as IdRepo Plugin and to display these migrated agents
// under 'Configuration/Agents' tab.
}
System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_COMPLETED));
} catch (Exception ex2) {
System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_TO_FAM80_FAILED));
ex2.printStackTrace();
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class FedSystemProperties method get.
/**
* Returns system properties.
*
* @param key Key to the properties.
*/
@Override
public String get(String key) {
String value = null;
if (isServerMode()) {
AttributeStruct ast = attributeMap.get(key);
if (ast != null) {
value = PropertiesFinder.getProperty(key, ast);
}
}
if (key.startsWith(METADATA_SIGNING_KEY)) {
//this will be true for both the key alias and the password
int idx = key.indexOf('[');
String attribute = key.substring(0, idx);
String realm = key.substring(idx + 1, key.length() - 1);
try {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(AccessController.doPrivileged(AdminTokenAction.getInstance()), realm);
Map<String, Set<String>> svcAttrs = orgMgr.getServiceAttributes("sunFAMSAML2Configuration");
return CollectionHelper.getMapAttr(svcAttrs, attribute);
} catch (SMSException smse) {
Debug.getInstance("libSAML2").error("Unable to retrieve " + attribute + " from realm: " + realm, smse);
return null;
}
}
return value != null ? value : getPropertyValue(key);
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class PeerOrgReferral method getValidValues.
/**Gets the valid values for this referral
* matching a pattern
* @param token SSOToken
* @param pattern a pattern to match against the value
* @return <code>ValidValues</code> object
* @exception SSOException if <code>SSOToken></code> is not valid
* @exception PolicyException if unable to get the list of valid
* names.
*/
public ValidValues getValidValues(SSOToken token, String pattern) throws SSOException, PolicyException {
Set values = new HashSet();
int status = ValidValues.SUCCESS;
if (debug.messageEnabled()) {
debug.message("PeerOrgReferral.getValidValues():entering");
}
try {
Set orgSet = (Set) _configurationMap.get(PolicyManager.ORGANIZATION_NAME);
if ((orgSet == null) || (orgSet.isEmpty())) {
debug.error("PeerOrgReferral.getValidValues(): " + " Organization name not set");
throw new PolicyException(ResBundleUtils.rbName, "org_name_not_set", null, null);
}
Iterator iter = orgSet.iterator();
String orgName = (String) iter.next();
OrganizationConfigManager orgConfigManager = new OrganizationConfigManager(token, orgName);
String fullOrgName = orgConfigManager.getOrganizationName();
if (debug.messageEnabled()) {
debug.message("PeerOrgReferral.getValidValues():fullOrgName=" + fullOrgName);
}
OrganizationConfigManager parentOrgConfig = orgConfigManager.getParentOrgConfigManager();
String fullParentOrgName = parentOrgConfig.getOrganizationName();
Set subOrgNames = parentOrgConfig.getSubOrganizationNames(pattern, //get only first level children
false);
if (!fullOrgName.equals(fullParentOrgName) && (subOrgNames != null) && !subOrgNames.isEmpty()) {
Iterator subOrgsIter = subOrgNames.iterator();
while (subOrgsIter.hasNext()) {
String subOrgName = (String) subOrgsIter.next();
OrganizationConfigManager subOrgManager = parentOrgConfig.getSubOrgConfigManager(subOrgName);
if (subOrgManager != null) {
String fullSubOrgName = subOrgManager.getOrganizationName();
if (!fullOrgName.equals(fullSubOrgName)) {
values.add(fullSubOrgName);
}
}
}
}
if (debug.messageEnabled()) {
debug.message("PeerOrgReferral.getValidValues():returning=" + values);
}
} catch (SMSException smse) {
debug.error("Can not get valid values for referral " + getReferralTypeName() + smse);
String[] objs = { getReferralTypeName() };
throw new PolicyException(ResBundleUtils.rbName, "can_not_get_values_for_referral", objs, smse);
}
return (new ValidValues(status, values));
}
Aggregations