Search in sources :

Example 81 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class EntitlementService method getApplicationConfiguration.

/**
     * Get the service config for registered applications.
     * @param token The admin token for access to the Service Config.
     * @param realm The realm from which to retrieve the service config.
     * @return The application Service Config.
     */
private ServiceConfig getApplicationConfiguration(SSOToken token, String realm) {
    try {
        if (token != null) {
            if (realm.startsWith(SMSEntry.SUN_INTERNAL_REALM_PREFIX) || realm.startsWith(SMSEntry.SUN_INTERNAL_REALM_PREFIX2)) {
                realm = "/";
            }
            // TODO. Since applications for the hidden realms have to be
            // the same as root realm mainly for delegation without any
            // referrals, the hack is to use root realm for hidden realm.
            String hackRealm = LDAPUtils.isDN(realm) ? DNMapper.orgNameToRealmName(realm) : realm;
            ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, token);
            ServiceConfig orgConfig = mgr.getOrganizationConfig(hackRealm, null);
            if (orgConfig != null) {
                return orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
            }
        } else {
            PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration, admin token is missing");
        }
    } catch (ClassCastException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
    } catch (SMSException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
    } catch (SSOException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
    }
    return null;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 82 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class EntitlementService method addApplicationAction.

/**
     * Adds a new action.
     *
     * @param appName application name.
     * @param name Action name.
     * @param defVal Default value.
     * @throws EntitlementException if action cannot be added.
     */
public void addApplicationAction(String appName, String name, Boolean defVal) throws EntitlementException {
    try {
        SSOToken token = SubjectUtils.getSSOToken(getAdminSubject());
        if (token == null) {
            throw new EntitlementException(226);
        }
        ServiceConfig applConf = getApplicationSubConfig(token, realm, appName);
        if (applConf != null) {
            Map<String, Set<String>> data = applConf.getAttributes();
            Map<String, Set<String>> result = addAction(data, name, defVal);
            if (result != null) {
                applConf.setAttributes(result);
            }
        }
    } catch (SMSException ex) {
        throw new EntitlementException(221, ex);
    } catch (SSOException ex) {
        throw new EntitlementException(221, ex);
    }
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 83 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class EntitlementService method setConfiguration.

private static void setConfiguration(SSOToken token, String attrName, Set<String> values) {
    try {
        if (token != null) {
            ServiceSchemaManager smgr = new ServiceSchemaManager(SERVICE_NAME, token);
            AttributeSchema as = smgr.getGlobalSchema().getAttributeSchema(attrName);
            if (as != null) {
                as.setDefaultValues(values);
            }
        } else {
            PolicyConstants.DEBUG.error("EntitlementService.getAttributeValues: " + "admin token is missing");
        }
    } catch (SMSException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.setAttributeValues", ex);
    } catch (SSOException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.setAttributeValues", ex);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 84 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class LogConfigReader method newStatusIsInactive.

private boolean newStatusIsInactive() {
    SSOToken ssoToken;
    try {
        ssoToken = getSSOToken();
    } catch (SSOException ssoe) {
        debug.error("LogConfigReader:newStatusIsInactive:" + "Could not get proper SSOToken", ssoe);
        return false;
    }
    try {
        ServiceSchemaManager schemaManager = new ServiceSchemaManager("iPlanetAMLoggingService", ssoToken);
        ServiceSchema smsLogSchema = schemaManager.getGlobalSchema();
        Map sss = smsLogSchema.getAttributeDefaults();
        String key = LogConstants.LOG_STATUS_ATTR;
        String value = CollectionHelper.getMapAttr(sss, key);
        if ((value == null) || (value.length() == 0)) {
            value = "ACTIVE";
        }
        return (value.equalsIgnoreCase("INACTIVE"));
    } catch (Exception e) {
        debug.error("LogConfigReader:newStatusIsInactive:" + "error reading Log Status attribute: " + e.getMessage());
    }
    return false;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 85 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class OrgConfigViaAMSDK method removeAttribute.

/**
     * Removes the specified attribute from AMSDK organization. The organziation
     * attribute names are defined in the IdRepo service.
     */
void removeAttribute(String attrName) throws SMSException {
    if (attrName == null) {
        return;
    }
    // Get the attribute mapping and removed specified attribute
    Map attrMap = getAttributeMapping();
    String amsdkAttrName = (String) attrMap.get(attrName);
    if (amsdkAttrName != null) {
        HashSet set = new HashSet();
        set.add(amsdkAttrName);
        try {
            parentOrg.removeAttributes(set);
            parentOrg.store();
        } catch (AMException ame) {
            if (debug.messageEnabled()) {
                debug.message("OrgConfigViaAMSDK::removeAttribute" + ": failed with AMException", ame);
            }
            throw (new SMSException(AMSDKBundle.BUNDLE_NAME, ame.getMessage(), ame, ame.getMessage()));
        } catch (SSOException ssoe) {
            throw (new SMSException(bundle.getString("sms-INVALID_SSO_TOKEN"), ssoe, "sms-INVALID_SSO_TOKEN"));
        }
    }
}
Also used : AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

SSOException (com.iplanet.sso.SSOException)1002 SMSException (com.sun.identity.sm.SMSException)553 Set (java.util.Set)374 SSOToken (com.iplanet.sso.SSOToken)336 IdRepoException (com.sun.identity.idm.IdRepoException)291 HashSet (java.util.HashSet)289 Map (java.util.Map)223 HashMap (java.util.HashMap)205 AMIdentity (com.sun.identity.idm.AMIdentity)193 Iterator (java.util.Iterator)189 CLIException (com.sun.identity.cli.CLIException)170 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)126 ServiceConfig (com.sun.identity.sm.ServiceConfig)126 IOutput (com.sun.identity.cli.IOutput)121 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)104 ServiceSchema (com.sun.identity.sm.ServiceSchema)101 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)93 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)88 IOException (java.io.IOException)65 PolicyException (com.sun.identity.policy.PolicyException)62