use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class Notifier method run.
public void run() {
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
Set<String> serverURLs = ServerConfiguration.getServerInfo(adminToken);
for (String url : serverURLs) {
int idx = url.indexOf("|");
if (idx != -1) {
url = url.substring(0, idx);
}
if (sitemonitorDisabled || !url.equals(currentServerInstance)) {
String strURL = url + NotificationServlet.CONTEXT_PATH + "/" + action;
StringBuilder buff = new StringBuilder();
boolean bFirst = true;
for (String k : params.keySet()) {
if (bFirst) {
bFirst = false;
} else {
buff.append("&");
}
buff.append(URLEncoder.encode(k, "UTF-8")).append("=").append(URLEncoder.encode(params.get(k), "UTF-8"));
}
for (int i = 0; i < NUM_RETRY; i++) {
if (postRequest(strURL, buff.toString())) {
break;
} else {
try {
Thread.sleep(WAIT_BETWEEN_RETRY);
} catch (InterruptedException ex) {
//DO NOTHING
}
}
}
}
}
} catch (UnsupportedEncodingException ex) {
PolicyConstants.DEBUG.error("Notifier.notifyChanges", ex);
} catch (IOException ex) {
PolicyConstants.DEBUG.error("Notifier.notifyChanges", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("Notifier.notifyChanges", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("DataStore.notifyChanges", ex);
}
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class DelegationUtils method getRevisionNumber.
/**
* gets the Delegation Service revision number
* @return the revision number of the delegation service.
*
*/
static int getRevisionNumber() {
if (revisionNum == 0) {
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(DelegationManager.DELEGATION_SERVICE, DelegationManager.getAdminToken());
revisionNum = ssm.getRevisionNumber();
if (debug.messageEnabled()) {
debug.message("DelegationUtils.getRevisionNumber(): " + "Delegation Service revision number is " + revisionNum);
}
} catch (SMSException sme) {
debug.error("DelegationUtils.getRevisionNumber(): " + "Unable to get Delegation revision number", sme);
} catch (SSOException ssoe) {
debug.error("DelegationUtils.getRevisionNumber(): " + "Unable to get Delegation revision number", ssoe);
}
}
return revisionNum;
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class DelegationUtils method getPermissionConfig.
/**
* Returns service config information for a delegation permission.
* @param orgName name of the organization whose organization config
* is searched.
* @param name name of the delegation permission whose information is.
sought.
* @param global <code>boolean</code> indicating if global config
* of the delegation service is expected.
* @return <code>ServiceConfig</code> information for a delegation
* permission
*/
static ServiceConfig getPermissionConfig(String orgName, String name, boolean global) throws SSOException, DelegationException {
ServiceConfig orgConfig = null;
ServiceConfig permsConfig = null;
ServiceConfig perm = null;
try {
// get the service configuration manager of the
// delegation service
ServiceConfigManager scm = new ServiceConfigManager(DelegationManager.DELEGATION_SERVICE, DelegationManager.getAdminToken());
// get the organization configuration of this realm
if (global) {
orgConfig = scm.getGlobalConfig(null);
} else {
orgConfig = scm.getOrganizationConfig(orgName, null);
}
} catch (SMSException se) {
throw new DelegationException(ResBundleUtils.rbName, "get_org_config_failed", null, se);
}
if (orgConfig == null) {
throw new DelegationException(ResBundleUtils.rbName, "get_perms_config_failed", null, null);
}
try {
// get the sub configuration "Permissions"
permsConfig = orgConfig.getSubConfig(DelegationManager.PERMISSIONS);
} catch (SMSException se) {
throw new DelegationException(ResBundleUtils.rbName, "get_perms_config_failed", null, se);
}
try {
// get the sub configuration for the defined permission
perm = permsConfig.getSubConfig(name);
} catch (SMSException se) {
throw new DelegationException(ResBundleUtils.rbName, "get_permission_config_failed", null, se);
}
return (perm);
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class IdUtils method initialize.
protected static void initialize() {
if (ServiceManager.isConfigMigratedTo70()) {
// entities from there
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
serviceConfigManager = new ServiceConfigManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
ServiceConfig ss = serviceConfigManager.getGlobalConfig(null);
Set typeSchemaNames = ss.getSubConfigNames("*", IdConstants.SUPPORTED_TYPES);
if (typeSchemaNames == null || typeSchemaNames.isEmpty()) {
loadDefaultTypes();
} else {
Iterator it = typeSchemaNames.iterator();
while (it.hasNext()) {
String typeSchema = (String) it.next();
IdType idType = new IdType(typeSchema);
supportedTypes.add(idType);
mapSupportedTypes.put(idType.getName(), idType);
ServiceConfig tsc = ss.getSubConfig(typeSchema);
Map attributes = tsc.getAttributes();
Set serviceNameSet = (Set) attributes.get(IdConstants.SERVICE_NAME);
Set canBeMembersOf = (Set) attributes.get(IdConstants.ATTR_MEMBER_OF);
Set canHaveMembers = (Set) attributes.get(IdConstants.ATTR_HAVE_MEMBERS);
Set canAddMembers = (Set) attributes.get(IdConstants.ATTR_ADD_MEMBERS);
if (serviceNameSet != null && !serviceNameSet.isEmpty()) {
mapTypesToServiceNames.put(typeSchema, (String) serviceNameSet.iterator().next());
}
if (canBeMembersOf != null && !canBeMembersOf.isEmpty()) {
Set memberOfSet = getMemberSet(canBeMembersOf);
typesCanBeMemberOf.put(typeSchema, memberOfSet);
}
if (canHaveMembers != null && !canHaveMembers.isEmpty()) {
Set memberSet = getMemberSet(canHaveMembers);
typesCanHaveMembers.put(typeSchema, memberSet);
}
if (canAddMembers != null && !canAddMembers.isEmpty()) {
Set memberSet = getMemberSet(canAddMembers);
typesCanAddMembers.put(typeSchema, memberSet);
}
}
}
} catch (SMSException e) {
String installTime = SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
if (!installTime.equals("true")) {
debug.error("IdUtils.initialize: Loading default types.", e);
}
loadDefaultTypes();
} catch (SSOException ssoe) {
debug.error("dUtils.initialize: Loading default types", ssoe);
loadDefaultTypes();
}
} else {
loadDefaultTypes();
}
// Register for SMS notifications to root realm
if (notificationId == null) {
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
if (serviceConfigManager == null) {
serviceConfigManager = new ServiceConfigManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
}
notificationId = serviceConfigManager.addListener(new IdUtilsListener());
} catch (SMSException e) {
String installTime = SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
if (!installTime.equals("true")) {
debug.error("IdUtils.initialize: Register notification", e);
}
} catch (SSOException ssoe) {
String installTime = SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
if (!installTime.equals("true")) {
debug.error("IdUtils.initialize: Register notification", ssoe);
}
}
}
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class IdUtils method getIdentity.
/**
* Returns an <code>AMIdentity</code> object, given the
* DN of an authenticated identity, realm name and identity type.
* This interface is mainly for authentication component to get
* back the identity of the user.
*
* @param token SSOToken of the administrator
* @param amsdkdn DN of the authenticated user
* @param realm realm name where the user was authenticated
* @return Identity object or <code>null</code>
* @throws IdRepoException if the underly components throws
* exception while obtaining the identity object
*/
public static AMIdentity getIdentity(SSOToken token, String amsdkdn, String realm) throws IdRepoException {
if (amsdkdn == null || !LDAPUtils.isDN(amsdkdn)) {
Object[] args = { amsdkdn };
throw (new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.ILLEGAL_UNIVERSAL_IDENTIFIER, args));
}
DN amsdkdnObject = LDAPUtils.newDN(amsdkdn);
// Try constructing the identity object
if (amsdkdn.toLowerCase().startsWith("id=")) {
try {
return (new AMIdentity(amsdkdnObject, token));
} catch (IdRepoException ide) {
// this could be a AMSDK DN. Follow the AMSDK rules
if (debug.messageEnabled()) {
debug.message("IdUtils:getIdentity(token, " + amsdkdn + ") got exception: " + ide.getMessage() + "\n\tContinuing with AMSDK DN check");
}
}
}
// Check for Special Users
initializeSpecialUsers();
if (specialUsers.contains(DNUtils.normalizeDN(amsdkdn))) {
return new AMIdentity(amsdkdnObject, token, LDAPUtils.rdnValueFromDn(amsdkdnObject), IdType.USER, ROOT_SUFFIX);
}
// any of the realms.
try {
if (!ServiceManager.isAMSDKEnabled() || ((realm != null) && !OrgConfigViaAMSDK.isAMSDKConfigured(realm)) || (!ServiceManager.isAMSDKConfigured())) {
// Not configured for AMSDK, return
return (null);
}
} catch (SMSException smse) {
// Ignore the exception and continue
}
// Initialize root realm suffix, org and user naming attributes
initializeForGetIdentity();
// Determine if the amsdkdn is valid. Obtain name & type
String name = null;
IdType type = null;
try {
// Since we would using AMSDK, get AMDirectoryManager preload
// all the attributes and check if it exists
IDirectoryServices dsServices = AMDirectoryAccessFactory.getDirectoryServices();
// force multiple another directory lookup
try {
if (amsdkdn.startsWith(USER_NAMING_ATTR)) {
dsServices.getAttributes(token, amsdkdn, AMObject.USER);
}
} catch (Exception e) {
// Ignore the exception and continue since this for cache
}
// Getting object type would use the cached attributes
int sdkType = dsServices.getObjectType(token, amsdkdn);
// Convert the sdkType to IdRepo type
type = getType(AMStoreConnection.getObjectName(sdkType));
name = AMConstants.CONTAINER_DEFAULT_TEMPLATE_ROLE;
if (!type.equals(IdType.REALM)) {
name = LDAPUtils.rdnValueFromDn(amsdkdnObject);
}
} catch (AMException ame) {
// Debug the message and return null
if (debug.messageEnabled()) {
debug.message("IdUtils.getIdentity: Unable to resolve " + "AMSDK DN: " + amsdkdn, ame);
}
return (null);
} catch (SSOException ssoe) {
// Debug the message and return null
if (debug.messageEnabled()) {
debug.message("IdUtils.getIdentity: Unable to resolve " + "AMSDK DN. Got SSOException", ssoe);
}
return (null);
}
// Need to determine realm for amsdkdn
String srealm = ROOT_SUFFIX;
if (!amsdkdn.equals(ROOT_SUFFIX) && !amsdkdn.equals(SERVICES_SUFFIX)) {
// Need to get the object type and walk up the tree
int index = amsdkdn.indexOf(ORG_NAMING_ATTR);
if (index == 0) {
srealm = OrgConfigViaAMSDK.getRealmForAMSDK(amsdkdn, realm);
} else if (index > 0) {
srealm = OrgConfigViaAMSDK.getRealmForAMSDK(amsdkdn.substring(index), realm);
}
if (debug.messageEnabled()) {
debug.message("IdUtils.getIdentity:: amsdkdn=" + amsdkdn + " maps to realm=" + srealm);
}
} else if (amsdkdn.equals(SERVICES_SUFFIX)) {
// Since amsdkdn points to services node,
// it should be reset to root suffix
amsdkdn = ROOT_SUFFIX;
}
return (new AMIdentity(amsdkdnObject, token, name, type, srealm));
}
Aggregations