Skip to content

Commit

Permalink
Merge pull request #166 from krausvo1/data_stores_xui
Browse files Browse the repository at this point in the history
Add data store management to XUI
  • Loading branch information
pavelhoral authored Feb 16, 2024
2 parents 13c0244 + ffb9813 commit 02458b8
Show file tree
Hide file tree
Showing 27 changed files with 1,202 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@
*
* $Id: IDRepoViewBean.java,v 1.3 2008/07/07 20:39:20 veiming Exp $
*
* Portions Copyrighted 2024 Wren Security.
*/

package com.sun.identity.console.realm;

import static com.sun.identity.console.XuiRedirectHelper.getAdministeredRealm;
import static com.sun.identity.console.XuiRedirectHelper.getAuthenticationRealm;
import static com.sun.identity.console.XuiRedirectHelper.isXuiAdminConsoleEnabled;
import static com.sun.identity.console.XuiRedirectHelper.redirectToXui;

import com.iplanet.jato.RequestContext;
import com.iplanet.jato.RequestManager;
import com.iplanet.jato.model.ModelControlException;
Expand Down Expand Up @@ -56,6 +62,8 @@
import java.util.Set;
import javax.servlet.http.HttpServletRequest;

import org.forgerock.http.util.Uris;

public class IDRepoViewBean
extends RealmPropertiesBase
{
Expand All @@ -74,7 +82,7 @@ public class IDRepoViewBean

private static final String TBL_COL_TYPE = "tblColType";
private static final String TBL_DATA_TYPE = "tblDataType";

private CCActionTableModel tblModel = null;

/**
Expand Down Expand Up @@ -119,10 +127,17 @@ protected View createChild(String name) {
public void beginDisplay(DisplayEvent event)
throws ModelControlException
{
super.beginDisplay(event);
resetButtonState(TBL_BUTTON_DELETE);
getIDRepoNames();
setPageTitle(getModel(), "page.title.realms.idrepo");
if (isXuiAdminConsoleEnabled()) {
String redirectRealm = getAdministeredRealm(this);
String authenticationRealm = getAuthenticationRealm(this);
redirectToXui(getRequestContext().getRequest(), redirectRealm, authenticationRealm,
"realms/" + Uris.urlEncodePathElement(redirectRealm) + "/dataStores");
} else {
super.beginDisplay(event);
resetButtonState(TBL_BUTTON_DELETE);
getIDRepoNames();
setPageTitle(getModel(), "page.title.realms.idrepo");
}
}

protected AMModel getModelInternal() {
Expand Down Expand Up @@ -206,7 +221,7 @@ private void populateTableModel(Collection idRepoNames) {
tblModel.setValue(TBL_DATA_TYPE, "");
}

tblModel.setValue(TBL_DATA_ACTION_HREF,
tblModel.setValue(TBL_DATA_ACTION_HREF,
stringToHex(name));
cache.add(name);
}
Expand All @@ -228,8 +243,8 @@ public void handleTblButtonAddRequest(RequestInvocationEvent event) {

/*
* This causes the first step of the New Data Store wizard to be skipped
* when only one Data Store type is available. The ideal fix is to modify the
* second step page to act as a single page. This is only a temporary fix
* when only one Data Store type is available. The ideal fix is to modify the
* second step page to act as a single page. This is only a temporary fix
* until the page two work can be done.
*/
/********
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
* Portions copyright 2024 Wren Security.
*/

package org.forgerock.openam.core.rest.sms;
Expand Down Expand Up @@ -65,6 +66,8 @@ public Collection<String> get(SchemaType type) {
SmsServiceHandlerFunction.SAML2_METADATA_SERVICE,
SmsServiceHandlerFunction.WS_METADATA_SERVICE
));
} else if (type == SchemaType.ORGANIZATION) {
excludedServices.remove("sunIdentityRepositoryService");
}

return excludedServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* $Id: ServiceConfigManagerImpl.java,v 1.13 2009/01/28 05:35:03 ww203982 Exp $
*
* Portions Copyrighted 2010-2017 ForgeRock AS.
* Portions Copyrighted 2024 Wren Security.
*/
package com.sun.identity.sm;

Expand Down Expand Up @@ -84,7 +85,7 @@ class ServiceConfigManagerImpl implements SMSObjectListener {
// LRU caches for global and org configs
Cache globalConfigs;
Cache orgConfigs;

// Validity of this object
private boolean valid = true;

Expand Down Expand Up @@ -165,11 +166,10 @@ ServiceConfigImpl getGlobalConfig(SSOToken token, String instanceName)
// Get group name
String groupName = SMSUtils.DEFAULT;
if ((instanceName != null) && !instanceName.equals(SMSUtils.DEFAULT)) {
groupName = ServiceInstanceImpl.getInstance(token,
groupName = ServiceInstanceImpl.getInstance(token,
serviceName, version,instanceName, null).getGroup();
}



String cacheName = null;
ServiceConfigImpl answer = null;
// Check the cache
Expand All @@ -187,7 +187,7 @@ ServiceConfigImpl getGlobalConfig(SSOToken token, String instanceName)
}

}

// Not in cache, check global schema
if ((ssm == null) || !ssm.isValid()) {
// Get the ServiceSchemaManagerImpl
Expand Down Expand Up @@ -219,7 +219,7 @@ ServiceConfigImpl getOrganizationConfig(SSOToken token, String orgName,
// Construct the group name
String groupName = SMSUtils.DEFAULT;
if ((instanceName != null) && !instanceName.equals(SMSUtils.DEFAULT)) {
groupName = ServiceInstanceImpl.getInstance(token,
groupName = ServiceInstanceImpl.getInstance(token,
serviceName, version, instanceName, orgName).getGroup();
}
String cacheName = null;
Expand All @@ -239,7 +239,7 @@ ServiceConfigImpl getOrganizationConfig(SSOToken token, String orgName,
answer = null;
}
}

// Not in cache, check organization schema
if ((ssm == null) || !ssm.isValid()) {
// Get the ServiceSchemaManagerImpl
Expand All @@ -250,7 +250,7 @@ ServiceConfigImpl getOrganizationConfig(SSOToken token, String orgName,
if (ss == null) {
return (null);
}

// Construct org config
String orgDN = constructServiceConfigDN(groupName,
CreateServiceConfig.ORG_CONFIG_NODE, orgdn);
Expand Down Expand Up @@ -305,7 +305,7 @@ String addListener(SSOToken token, ServiceListener listener) {
}
return (id);
}

private synchronized void registerListener(SSOToken token) {
if (listenerId == null) {
// Regsiter for notifications
Expand All @@ -321,7 +321,7 @@ private synchronized void registerListener(SSOToken token) {
"," + SMSEntry.getRootSuffix();
schemaNotificationSearchString = sdn + "," +
SMSEntry.getRootSuffix();

// Initialize instance variables
listenerObjects = new HashMap();
}
Expand All @@ -345,8 +345,8 @@ void removeListener(String listenerID) {
}
}
}
private synchronized void deregisterListener() {

private synchronized void deregisterListener() {
if (listenerId != null) {
SMSNotificationManager.getInstance().removeCallbackHandler(
listenerId);
Expand All @@ -364,7 +364,7 @@ boolean containsGroup(SSOToken token, String groupName)
}
return (groups.contains(token, groupName));
}

// Implementations for SMSObjectListener
public void allObjectsChanged() {
// Ignore, do nothing
Expand All @@ -390,23 +390,23 @@ public void objectChanged(String dn, int type) {
boolean globalConfig = false;
boolean orgConfig = false;
int index = 0, orgIndex = 0;
dn = DNUtils.normalizeDN(dn);
if ((index = dn.indexOf(orgNotificationSearchString)) != -1) {
String normalizedDn = DNUtils.normalizeDN(dn);
if ((index = normalizedDn.indexOf(orgNotificationSearchString)) != -1) {
orgConfig = true;
if (index == 0) {
// Organization config node is created
// No data is stored in this node
return;
}
orgIndex = orgNotificationSearchString.length();
} else if ((index = dn.indexOf(glbNotificationSearchString)) != -1) {
} else if ((index = normalizedDn.indexOf(glbNotificationSearchString)) != -1) {
globalConfig = true;
} else if ((index = dn.indexOf(schemaNotificationSearchString)) != -1) {
} else if ((index = normalizedDn.indexOf(schemaNotificationSearchString)) != -1) {
// Global schema changes, resulting in config change
globalConfig = true;
orgConfig = true;
} else if (serviceName.equalsIgnoreCase("sunidentityrepositoryservice")
&& (dn.startsWith(SMSEntry.ORG_PLACEHOLDER_RDN) || dn
&& (normalizedDn.startsWith(SMSEntry.ORG_PLACEHOLDER_RDN) || normalizedDn
.equalsIgnoreCase(DNMapper.serviceDN))) {
// Since sunIdentityRepositoryService has realm creation
// attributes, we need to send notification
Expand All @@ -420,7 +420,7 @@ public void objectChanged(String dn, int type) {
String groupName = "";
String compName = "";
if (index > 1) {
DN compDn = DN.valueOf(dn.substring(0, index - 1));
DN compDn = DN.valueOf(LDAPUtils.newDN(dn).toString().substring(0, index - 1));
List<RDN> rdns = new ArrayList<>();
for (RDN rdn : compDn) {
rdns.add(rdn);
Expand All @@ -444,21 +444,21 @@ public void objectChanged(String dn, int type) {
}

// Get organization name
String orgName = dn;
String orgName = normalizedDn;
if (globalConfig && orgConfig) {
// Schema change, use base DN
orgName = ServiceManager.getBaseDN();
} else if ((index >= 0) && orgConfig) {
// Get org name
orgName = dn.substring(index + orgIndex + 1);
orgName = normalizedDn.substring(index + orgIndex + 1);
}
if (globalConfig) {
notifyGlobalConfigChange(groupName, compName, type);
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message(
"ServiceConfigManagerImpl(" + serviceName +
"):entryChanged Sending global config change " +
"notifications for DN "+ dn);
"notifications for DN "+ normalizedDn);
}
}
if (orgConfig) {
Expand All @@ -467,7 +467,7 @@ public void objectChanged(String dn, int type) {
SMSEntry.eventDebug.message(
"ServiceConfigManagerImpl(" + serviceName +
"):entryChanged Sending org config change " +
"notifications for DN " + dn);
"notifications for DN " + normalizedDn);
}
}
}
Expand Down Expand Up @@ -495,7 +495,7 @@ void notifyGlobalConfigChange(String groupName, String comp, int type) {
void notifyOrgConfigChange(String orgName, String groupName, String comp,
int type) {
HashSet lObject = new HashSet();
synchronized (listenerObjects) {
synchronized (listenerObjects) {
lObject.addAll(listenerObjects.values());
}
Iterator items = lObject.iterator();
Expand Down Expand Up @@ -535,11 +535,11 @@ String constructServiceConfigDN(String groupName, String configName,
sb.append(orgName);
return (sb.toString());
}

protected boolean isValid() {
return (valid);
}

/**
* Clears instance cache and deregisters listeners
*/
Expand All @@ -556,7 +556,7 @@ private void clear() {
globalConfigs.clear();
}
}

// @Override
public int hashCode() {
int hash = 4;
Expand All @@ -569,7 +569,7 @@ public int hashCode() {

/**
* Compares this object with the given object.
*
*
* @param o
* object for comparison.
* @return true if objects are equals.
Expand All @@ -587,7 +587,7 @@ public boolean equals(Object o) {

/**
* Returns String representation of the service's name and version.
*
*
* @return String representation of the service's name and version
*/
public String toString() {
Expand All @@ -613,12 +613,12 @@ protected static ServiceConfigManagerImpl getInstance(SSOToken token,
if (answer != null) {
return (answer);
}

// Not in cache, need to construct the entry and add to cache
// Check if user has permissions to this object. This call will
// throw an exception if the user does not have permissions
checkAndUpdatePermission(cName, serviceName, version, token);

// User has permissions,
// Construct ServiceConfigManagerImpl and add to cache
synchronized (configMgrImpls) {
Expand Down Expand Up @@ -676,7 +676,7 @@ private static boolean checkAndUpdatePermission(String cacheName,
} else {
SMSEntry.getDelegationPermission(t, dn, SMSEntry.readActionSet);
}

// User has permissions, add principal to cache
synchronized (userPrincipals) {
Set sudoPrincipals = (Set) userPrincipals.get(cacheName);
Expand Down Expand Up @@ -716,7 +716,7 @@ static void clearCache() {

private static Map userPrincipals = Collections.synchronizedMap(
new HashMap());

private static int PRINCIPALS_CACHE_SIZE = 20;

private static Debug debug = SMSEntry.debug;
Expand Down
Loading

0 comments on commit 02458b8

Please sign in to comment.