use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthPropertiesModelImpl method getAuthInstances.
public Set getAuthInstances() {
Set instances = null;
if (currentRealm != null) {
String[] param = { currentRealm };
logEvent("ATTEMPT_GET_AUTH_INSTANCE", param);
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
instances = mgr.getAuthenticationInstances();
logEvent("SUCCEED_GET_AUTH_INSTANCE", param);
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, strError };
logEvent("AUTH_CONFIG_EXCEPTION_GET_AUTH_INSTANCE", paramsEx);
debug.warning("AuthPropertiesModelImpl.getAuthInstances", e);
}
}
return (instances == null) ? Collections.EMPTY_SET : instances;
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthConfigurationModelImpl method initialize.
/**
* Initialize configuration entry information for the given realm
* and named configuration.
*
* @param realm name where configuration is locate.
* @param config name of entry.
*/
public void initialize(String realm, String config) {
verifyConfigurationService(realm);
try {
if (configData == null) {
String[] params = { realm, config };
logEvent("ATTEMPT_GET_AUTH_CONFIG_PROFILE", params);
configData = AMAuthConfigUtils.getNamedConfig(config, realm, getUserSSOToken());
logEvent("SUCCEED_GET_AUTH_CONFIG_PROFILE", params);
}
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, config, strError };
logEvent("SSO_EXCEPTION_GET_AUTH_CONFIG_PROFILE", paramsEx);
debug.warning("AuthConfigurationModelImpl.initialize", e);
configData = Collections.EMPTY_MAP;
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, config, strError };
logEvent("AUTH_CONFIGURATION_EXCEPTION_GET_AUTH_CONFIG_PROFILE", paramsEx);
debug.error("AuthConfigurationModelImpl.initialize", e);
configData = Collections.EMPTY_MAP;
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, config, strError };
logEvent("SMS_EXCEPTION_GET_AUTH_CONFIG_PROFILE", paramsEx);
debug.error("AuthConfigurationModelImpl.initialize", e);
configData = Collections.EMPTY_MAP;
}
if ((configData != null) && !configData.isEmpty() && (xmlValue == null)) {
Set tmp = (Set) configData.get(AUTH_CONFIG_ATTR);
if ((tmp != null) && (!tmp.isEmpty())) {
xmlValue = (String) tmp.iterator().next();
entryList = new ArrayList(AMAuthConfigUtils.xmlToAuthConfigurationEntry(xmlValue));
}
}
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class AuthConfigurationModelImpl method deleteAuthConfiguration.
/**
* Deletes the named authentication configuration object.
*
* @param realm name where configuration is locate.
* @param names names of entries.
*/
public void deleteAuthConfiguration(String realm, Set names) throws AMConsoleException {
StringBuilder errorList = new StringBuilder();
String message = null;
for (Iterator i = names.iterator(); i.hasNext(); ) {
String config = (String) i.next();
message = null;
try {
AMAuthConfigUtils.removeNamedConfig(config, realm, getUserSSOToken());
} catch (AMConfigurationException e) {
debug.warning("failed to delete", e);
message = e.getMessage();
errorList.append(config);
} catch (SMSException e) {
debug.warning("failed to delete", e);
message = e.getMessage();
errorList.append(config);
} catch (SSOException e) {
debug.warning("failed to delete", e);
message = e.getMessage();
errorList.append(config);
}
if (message != null) {
if (errorList.length() > 0) {
errorList.append(", ");
}
}
}
if (errorList.length() > 0) {
String[] tmp = { errorList.toString(), message };
throw new AMConsoleException(MessageFormat.format(getLocalizedString("authentication.config.delete.failed"), (Object[]) tmp));
}
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class ResourceEnvIPCondition method getAdviceMessagesforRedirectURL.
/**
* Returns advice messages for Authentication Redirect condition.
*/
private Set getAdviceMessagesforRedirectURL(String adviceValue, SSOToken token, Map env) throws PolicyException, SSOException {
Set adviceMessages = new HashSet();
Set requestAuthSchemes = null;
Set requestAuthSchemesIgnoreRealm = null;
boolean nullRealm = false;
boolean allow = false;
String orgName = "/";
if ((env != null) && (env.get(REQUEST_AUTH_SCHEMES) != null)) {
try {
Set<String> orgSet = (Set<String>) env.get(PolicyEvaluator.REALM_DN);
if (orgSet != null) {
orgName = orgSet.iterator().next();
}
requestAuthSchemes = (Set) env.get(REQUEST_AUTH_SCHEMES);
if (DEBUG.messageEnabled()) {
DEBUG.message("At ResourceEnvIPCondition." + "getAdviceMessagesforRedirectURL(): " + "requestAuthSchemes from env= " + requestAuthSchemes + " AND orgName from env= " + orgName);
}
} catch (ClassCastException e) {
String[] args = { REQUEST_AUTH_SCHEMES };
throw new PolicyException(ResBundleUtils.rbName, "property_is_not_a_Set", args, e);
}
} else {
if (token != null) {
orgName = token.getProperty(ISAuthConstants.ORGANIZATION);
requestAuthSchemes = AMAuthUtils.getRealmQualifiedAuthenticatedSchemes(token);
requestAuthSchemesIgnoreRealm = AMAuthUtils.getAuthenticatedSchemes(token);
if (DEBUG.messageEnabled()) {
DEBUG.message("At ResourceEnvIPCondition." + "getAdviceMessagesforRedirectURL(): " + "orgName from ssoToken= " + orgName);
DEBUG.message("At ResourceEnvIPCondition." + "getAdviceMessagesforRedirectURL(): " + "requestAuthSchemes from ssoToken= " + requestAuthSchemes);
DEBUG.message("At ResourceEnvIPCondition." + "getAdviceMessagesforRedirectURL(): " + "requestAuthSchemesIgnoreRealm from ssoToken= " + requestAuthSchemesIgnoreRealm);
}
}
}
if (requestAuthSchemes == null) {
requestAuthSchemes = Collections.EMPTY_SET;
}
if (requestAuthSchemesIgnoreRealm == null) {
requestAuthSchemesIgnoreRealm = Collections.EMPTY_SET;
}
String schemeInstance = null;
String authSchemeType = null;
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
for (Iterator iter = requestAuthSchemes.iterator(); iter.hasNext(); ) {
String requestAuthnScheme = (String) iter.next();
schemeInstance = AMAuthUtils.getDataFromRealmQualifiedData(requestAuthnScheme);
String realm = AMAuthUtils.getRealmFromRealmQualifiedData(requestAuthnScheme);
if ((realm == null) || (realm.length() == 0)) {
nullRealm = true;
break;
} else {
AMAuthenticationManager authManager = new AMAuthenticationManager(adminToken, orgName);
AMAuthenticationInstance authInstance = authManager.getAuthenticationInstance(schemeInstance);
authSchemeType = authInstance.getType();
if ("Federation".equals(authSchemeType)) {
allow = true;
break;
}
}
}
if (nullRealm) {
for (Iterator iter = requestAuthSchemesIgnoreRealm.iterator(); iter.hasNext(); ) {
schemeInstance = (String) iter.next();
AMAuthenticationManager authManager = new AMAuthenticationManager(adminToken, orgName);
AMAuthenticationInstance authInstance = authManager.getAuthenticationInstance(schemeInstance);
authSchemeType = authInstance.getType();
if ("Federation".equals(authSchemeType)) {
allow = true;
break;
}
}
}
} catch (AMConfigurationException ace) {
if (DEBUG.warningEnabled()) {
DEBUG.warning("ResourceEnvIPCondition." + "getAdviceMessagesforRedirectURL():" + "got AMConfigurationException:" + "schemeInstance=" + schemeInstance + ", authSchemeType = " + authSchemeType);
}
Object[] args = { schemeInstance };
throw new PolicyException(ResBundleUtils.rbName, "auth_scheme_not_found", args, ace);
}
if (!allow) {
adviceMessages.add(adviceValue);
}
if (DEBUG.messageEnabled()) {
DEBUG.message("At ResourceEnvIPCondition." + "getAdviceMessagesforRedirectURL():" + "redirectURL=" + adviceValue + "schemeInstance=" + schemeInstance + ",authSchemeType=" + authSchemeType + ",adviceMessages=" + adviceMessages);
}
return adviceMessages;
}
use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.
the class ResourceEnvIPCondition method getAdviceMessagesforRedirectURL.
/**
* Returns advice messages for Authentication Redirect condition.
*/
private Set<String> getAdviceMessagesforRedirectURL(String adviceValue, SSOToken token, Map env) throws EntitlementException, SSOException {
if (debug.messageEnabled()) {
localDebugName = debugName + ".getAdviceMessagesforRedirectURL(): ";
}
Set<String> adviceMessages = new HashSet<String>();
Set requestAuthSchemes = null;
Set requestAuthSchemesIgnoreRealm = null;
boolean nullRealm = false;
boolean allow = false;
String orgName = "/";
if ((env != null) && (env.get(REQUEST_AUTH_SCHEMES) != null)) {
try {
orgName = CollectionHelper.getMapAttr(env, PolicyEvaluator.REALM_DN, orgName);
requestAuthSchemes = (Set) env.get(REQUEST_AUTH_SCHEMES);
if (debug.messageEnabled()) {
debug.message(localDebugName + "requestAuthSchemes from env= " + requestAuthSchemes + " AND " + "orgName from env= " + orgName);
}
} catch (ClassCastException e) {
throw new EntitlementException(PROPERTY_IS_NOT_A_SET, new String[] { REQUEST_AUTH_SCHEMES }, e);
}
} else {
if (token != null) {
orgName = token.getProperty(ISAuthConstants.ORGANIZATION);
requestAuthSchemes = AMAuthUtils.getRealmQualifiedAuthenticatedSchemes(token);
requestAuthSchemesIgnoreRealm = AMAuthUtils.getAuthenticatedSchemes(token);
if (debug.messageEnabled()) {
debug.message(localDebugName + "orgName " + "from ssoToken= " + orgName);
debug.message(localDebugName + "requestAuthSchemes from ssoToken= " + requestAuthSchemes);
debug.message(localDebugName + "requestAuthSchemesIgnoreRealm from ssoToken= " + requestAuthSchemesIgnoreRealm);
}
}
}
if (requestAuthSchemes == null) {
requestAuthSchemes = Collections.EMPTY_SET;
}
if (requestAuthSchemesIgnoreRealm == null) {
requestAuthSchemesIgnoreRealm = Collections.EMPTY_SET;
}
String schemeInstance = null;
String authSchemeType = null;
try {
SSOToken adminToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
for (Iterator iter = requestAuthSchemes.iterator(); iter.hasNext(); ) {
String requestAuthnScheme = (String) iter.next();
schemeInstance = AMAuthUtils.getDataFromRealmQualifiedData(requestAuthnScheme);
String realm = AMAuthUtils.getRealmFromRealmQualifiedData(requestAuthnScheme);
if ((realm == null) || (realm.length() == 0)) {
nullRealm = true;
break;
} else {
AMAuthenticationManager authManager = new AMAuthenticationManager(adminToken, orgName);
AMAuthenticationInstance authInstance = authManager.getAuthenticationInstance(schemeInstance);
authSchemeType = authInstance.getType();
if ("Federation".equals(authSchemeType)) {
allow = true;
break;
}
}
}
if (nullRealm) {
for (Iterator iter = requestAuthSchemesIgnoreRealm.iterator(); iter.hasNext(); ) {
schemeInstance = (String) iter.next();
AMAuthenticationManager authManager = new AMAuthenticationManager(adminToken, orgName);
AMAuthenticationInstance authInstance = authManager.getAuthenticationInstance(schemeInstance);
authSchemeType = authInstance.getType();
if ("Federation".equals(authSchemeType)) {
allow = true;
break;
}
}
}
} catch (AMConfigurationException ace) {
if (debug.warningEnabled()) {
debug.warning(localDebugName + "got AMConfigurationException: schemeInstance=" + schemeInstance + ", " + "authSchemeType = " + authSchemeType);
}
throw new EntitlementException(AUTH_SCHEME_NOT_FOUND, new String[] { schemeInstance }, ace);
}
if (!allow) {
adviceMessages.add(adviceValue);
}
if (debug.messageEnabled()) {
debug.message(localDebugName + "redirectURL=" + adviceValue + "schemeInstance=" + schemeInstance + "," + "authSchemeType=" + authSchemeType + ",adviceMessages=" + adviceMessages);
}
return adviceMessages;
}
Aggregations