AMModelBase.java revision 8b6198b1170e3128c5df83267597f0058d07c70d
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: AMModelBase.java,v 1.18 2009/12/11 23:25:19 veiming Exp $
*
* Portions Copyrighted 2011-2015 ForgeRock AS.
*/
/**
* This class implements all the basic and commonly used methods used by view
* beans.
* <p>
* All the OpenSSO model implementation classes extends from this
* class.
*/
public class AMModelBase
implements AMModel
{
/** debug object */
private static SSOToken adminSSOToken =
private Map mapUserInfo;
private static int svcRevisionNumber;
/**
* Creates a simple model using default resource bundle.
*
* @param req HTTP Servlet Request
*/
}
public AMModelBase() {
// do nothing
}
/**
* Creates a simple model. The LDAP location distinguished name (DN) if
* default to start DN of the currently logged in user.
*
* @param req HTTP Servlet Request
* @param rbName resource bundle name
*/
}
/**
* Creates a model with user information retrieved from the user
* information map.
*
* @param req HTTP Servlet Request
* @param rbName resource bundle name
* @param map of user information
*/
mapUserInfo = map;
}
/**
* Creates a model with user information retrieved from the user
* information map. (using default resource bundle)
*
* @param req HTTP Servlet Request
* @param map of user information
*/
mapUserInfo = map;
}
/**
* Set location distinguished name
*
* @param DN distinguished name
*/
try {
} catch (SSOException e) {
}
}
/**
* Returns location DN.
*
* @return location DN.
*/
public String getLocationDN() {
}
/**
* Returns user information from SSO token or map of serialized information.
*/
userDN = getUniversalID();
}
/**
* Returns universal ID of user.
*
* @return Universal ID of user.
*/
public String getUniversalID() {
try {
} catch (SSOException e) {
}
}
/**
* Returns the preferred locale of currently logged in user.
*
* @return <code>java.util.Locale</code> of currently logged in user.
*/
return locale;
}
/**
* Returns current user's Single Sign On Token.
*
* @return current user's Single Sign On Token.
*/
public SSOToken getUserSSOToken() {
return ssoToken;
}
boolean bSet = false;
try {
bSet = true;
}
} catch (SSOException e) {
}
if (!bSet) {
}
}
/**
* Initializes object. It does the followings
* <ol>
* <li> check validity of SSO token
* <li> get user information from user map and SSO token
* <li> read console profile information from SSO token
* </ol>
*
* @param req HTTP Servlet Request
* @param rbName resource bundle name
*/
try {
}
} catch (SMSException smse) {
} catch (SSOException e) {
}
}
/**
* Returns client type from SSO token
*
* @return client type
*/
public String getClientType() {
}
/**
* Returns random string
*
* @return random string
*/
public String getRandomString() {
byte[] keyRandom = new byte[5];
}
/**
* Returns the attribute name that is used for the main user display
* on user entries. This attribute is defined in the administration
* this attribute is the value returned. If the attribute contains the
* following values <code>cn uid</code>, then <code>cn</code> will be
* the return value.
*
* @return attribute name used when displaying user entries.
*/
public String getUserDisplayAttribute() {
}
return searchAttribute;
}
/**
* Returns the attribute name that is used when performing searches
* on user entries. This attribute is defined in the administration
* service in <code>User Search Key</code>.
*
* @return attribute name for user searches.
*/
public String getUserSearchAttribute() {
}
return searchAttribute;
}
/**
* Returns DN of currently logged in user.
*
* @return DN of currently logged in user.
*/
try {
} catch (SSOException e) {
} catch (IdRepoException e) {
}
}
return dn;
}
/**
* Returns currently logged in user.
*
* @return currently logged in user.
*/
public String getUserName() {
return userDN;
}
/**
* Returns the <code>DN</code> of the users organization.
*
* @return <code>DN</code> of the users organization.
*/
public String getUserOrganization() {
try {
} catch (SSOException e) {
} catch (IdRepoException e) {
}
}
return orgDN;
}
/**
* Returns a localized error message from an exception. If the exception
* is of type <code>AMException</code> the error code and any possible
* arguments will be extracted from the exception and the message will be
* generated from the code and arguments. All other exception types will
* return the message from <code>Exception.getMessage</code>.
*
* @param ex exception
* @return String error message localized to users locale
*/
if (ex instanceof L10NMessage) {
} else {
}
return message;
}
/**
* Writes log event.
*
* @param id Log Message ID.
* @param data Log Data.
*/
try {
} else {
}
} catch (IOException e) {
}
}
/**
* Returns resource bundle.
*
* @return resource bundle.
*/
protected ResourceBundle getResourceBundle() {
return resBundle;
}
/**
* Returns localized string.
*
* @param key Key of resource string.
* @return localized string.
*/
}
/**
* Returns paging page size from template if one exists otherwise page size
* that is defined globally.
*
* @return paging page size
*/
public int getPageSize() {
}
public String getConsoleDirectory() {
if (consoleJSPDirectory == null) {
Map m = getConsoleAttributes();
if (m != null) {
}
}
}
return consoleJSPDirectory;
}
/**
* Returns a map of the cosole service attributes configured at the realm
* where the user started (typically where they logged in at.) If the
* admin service is not configured in that realm, the defaults are taken
* from global configuration.
*/
protected Map getConsoleAttributes() {
if (consoleAttributes == null) {
try {
adminSSOToken, getStartDN());
} else {
adminSSOToken, getStartDN());
}
} catch (SSOException e) {
} catch (SMSException e) {
} catch (IdRepoException e) {
}
}
return consoleAttributes;
}
int limit = -1;
try {
} catch (NumberFormatException e) {
"attributeName=" + attributeName, e);
}
}
}
return limit;
}
/**
* Returns globally defined page size
*
* @return globally defined page size.
*/
public int getGlobalPageSize() {
return getGlobalIntegerConsoleAttribute(
}
/**
* Returns search result limit from template if one exists otherwise page
* size that is defined globally.
*
* @return search result limit.
*/
public int getSearchResultLimit() {
}
/**
* Returns globally defined search result limit.
*
* @return globally defined search result limit.
*/
public int getGlobalSearchResultLimit() {
return getGlobalIntegerConsoleAttribute(
}
/**
* Returns search time limit from template if one exists otherwise page
* size that is defined globally.
*
* @return search time limit.
*/
public int getSearchTimeOutLimit() {
}
/**
* Returns globally defined search timeout limit.
*
* @return globally defined search timeout limit.
*/
public int getGlobalSearchTimeOutLimit() {
return getGlobalIntegerConsoleAttribute(
}
private int getGlobalIntegerConsoleAttribute(
int lowerLimit,
int defaultValue
) {
int value = 0;
try {
} catch (SSOException e) {
} catch (SMSException e) {
} catch (NumberFormatException e) {
}
}
/**
* Returns the localized service name.
*
* @param service Name of service.
* @return the localized service name.
*/
}
/**
* Returns the localized service name.
*
* @param service Name of service.
* @param defaultValue Default value of service name if localized service
* name cannot be determine.
* @return the localized service name.
*/
try {
}
}
}
}
} catch (SSOException e) {
} catch (SMSException e) {
} catch (MissingResourceException e) {
}
return i18nName;
}
try {
}
} catch (SSOException e) {
} catch (SMSException e) {
}
return rb;
}
/**
* Returns properties view bean URL of a service.
*
* @param serviceName Name of service.
* @return properties view bean URL of a service. Returns null if
* this URL is not defined in the schema.
*/
try {
} catch (SSOException e) {
} catch (SMSException e) {
}
return url;
}
/**
* Gets URL of hyperlink to logout
*
* @return URL of hyperlink to logout page
*/
public static String getLogoutURL() {
if (AMSystemConfig.isConsoleRemote) {
}
}
/**
* Returns a map of suppported entity type to its localized name.
*
* @param realmName Name of Realm.
* @return a map of suppported entity type to its localized name.
*/
realmName = "/";
}
try {
) {
// add the "Agent" tab only if revision number of
// sunIdentityRepository service is less than 30.
// This is for backward compatibility to support
// this scenerio : OpenSSO 8.0 server against
// AM 7.x existing DIT (Coexistence).
}
}
} catch (IdRepoException e) {
} catch (SSOException e) {
}
}
/**
* Returns a map of supported agent type to its localized name.
*
* @return a map of supported agent type to its localized name.
*/
public Map getSupportedAgentTypes() {
try {
}
} catch (SMSException e) {
} catch (SSOException e) {
}
}
/**
* Gets start DN
*
* @return start DN
*/
public String getStartDN() {
try {
} catch (SSOException e) {
}
return startDN;
}
/**
* Returns directory management start DN.
*
* @return directory management start DN.
*/
public String getStartDSDN(){
try {
} catch (SSOException e) {
}
return startDN;
}
protected Set getAttributesToDisplay(
) {
try {
} catch (SMSException smse) {
}
return Collections.EMPTY_SET;
}
try {
} catch (SMSException smse) {
}
return Collections.EMPTY_SET;
}
if (attrSchemaNames != null) {
while (asnIterator.hasNext()) {
if (isDisplayed(attrSchema)) {
}
}
}
return attrSchemaSet;
}
/**
* Determines whether attribute is to be displayed or not
*
* @param attrSchema - attribute schema
* @return true if
*/
boolean displayed = true;
if ((attrSchema == null) ||
displayed = false;
}
return displayed;
}
/**
* Gets service schema manager, we cache instance of this manager per
* HTTP request
*
* @param name of service
* @return service schema manager
* @throws SSOException when SSO token is invalid
* @throws SMSException when we are unable to retrieve the service
* schema manager
*/
throws SSOException, SMSException
{
}
return mgr;
}
/**
* Converts a set of string values to encrypted values.
* <code>AMPasswordUtil.encrypt</code> will be called on each value in
* the set to convert the current value to an encrypted value.
*
* @param values containing string values
* @return Set of encrypted data.
*/
}
return rs;
}
try {
} catch (SSOException e) {
}
return startDN;
}
/**
* Gets the organization where user authenticated to. This value is found
* in single-sign on token.
*
* return organization where user authenticated.
*/
public String getAuthenticatedOrgDN() {
}
/**
* Check the value of the user status attribute. It needs
* to be either 'Active' or 'Inactive' for the display to be set
* correctly.
*/
tmp = STRING_ACTIVE;
} else {
}
h.clear();
}
}
/**
* Returns true if the user profile is to be ignored by the console.
* The authentication service sets a property in the users session
* based on the properties in the core authentication service.
*
* @return true if the user profile should be ignored.
*/
public boolean ignoreUserProfile() {
try {
} catch (SSOException e) {
}
}
/**
* Returns the formated display name for user identities. This is needed
* to handle the situation where the attribute displayed for the user is
* not the same as the naming attribute. It is also possible that the
* attribute being displayed has multiple values. In the multiple value
* situation each of the values will be separated by a semicolon ";".
*
* @param id identity of the user being displayed.
* @return String value of the attribute to be displayed.
*/
try {
// get the values for the search attribute
// we know there is at least one entry, so add it
// iterate through any of the other values
for (; i.hasNext(); ) {
}
}
} catch (IdRepoException idr) {
} catch (SSOException sso) {
}
// default to the identity name if display cant be constructed.
}
/**
* Returns a set of special user identities. This set of identities
* typically should not be displayed in the console.
*
* @param realmName Name of Realm.
* @return a set of <code>AMIdentity</code> entries that should not be
* displayed in the console.
*/
try {
getUserSSOToken(), realmName);
} catch (IdRepoException e) {
} catch (SSOException e) {
}
}
/*
* Returns the realm names that match the specified filter value.
*
* @param base Base realm name for this search. null indicates root
* suffix.
* @param filter Filter string.
* @return realms names that match the filter.
* @throws AMConsoleException if search fails.
*/
throws AMConsoleException
{
base = getStartDN();
}
try {
return appendBaseDN(base,
} catch (SMSException e) {
return result;
} else {
throw new AMConsoleException(strError);
}
}
}
/*
* Search results are relative to the base (where the search was
* performed. Use this to add the base back to the search result,
* ending up with a fully qualified name.
*/
} else {
}
}
} else {
}
} else {
} else {
}
}
}
}
return altered;
}
/**
* Returns <code>true</code> if server is running with <code>AMSDK</code>
* repo enabled.
*
* @return <code>true</code> if server is running with <code>AMSDK</code>
* repo enabled.
*/
public boolean isAMSDKEnabled() {
try {
} catch (SMSException e) {
return false;
} catch (SSOException e) {
return false;
}
}
protected String[] getServerInstanceForLogMsg() {
return array;
}
}
return false;
}
}