mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,187 +1,187 @@
|
||||
package org.alfresco.repo.security.authentication.ldap;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.TabularType;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationStep;
|
||||
import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizerStatus;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Monitoring methods and properties to be exposed via the
|
||||
* JMX admin console.
|
||||
*/
|
||||
|
||||
public class Monitor
|
||||
{
|
||||
LDAPAuthenticationComponentImpl component;
|
||||
ChainingUserRegistrySynchronizerStatus syncMonitor;
|
||||
String id;
|
||||
|
||||
private static Log logger = LogFactory.getLog(Monitor.class);
|
||||
|
||||
public void setLDAPAuthenticationComponent(LDAPAuthenticationComponentImpl component)
|
||||
{
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public void setChainingUserRegistrySynchronizerStatus(ChainingUserRegistrySynchronizerStatus syncStatus)
|
||||
{
|
||||
this.syncMonitor = syncStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* test authenticate
|
||||
*
|
||||
* @param userName String
|
||||
* @param credentials String
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
public CompositeData testAuthenticate(String userName, String credentials)
|
||||
{
|
||||
String stepKeys[] = {"id", "stepMessage", "success"};
|
||||
String stepDescriptions[] = {"id", "stepMessage", "success"};
|
||||
OpenType<?> stepTypes[] = {SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN };
|
||||
|
||||
try
|
||||
{
|
||||
String[] key = {"id"};
|
||||
CompositeType sType = new CompositeType("Authentication Step", "Step", stepKeys, stepDescriptions, stepTypes);
|
||||
TabularType tType = new TabularType("Diagnostic", "Authentication Steps", sType, key);
|
||||
TabularData table = new TabularDataSupport(tType);
|
||||
|
||||
String attributeKeys[] = {"authenticationMessage", "success", "diagnostic"};
|
||||
String attributeDescriptions[] = {"authenticationMessage", "success", "diagnostic"};
|
||||
OpenType<?> attributeTypes[] = {SimpleType.STRING, SimpleType.BOOLEAN, tType};
|
||||
try
|
||||
{
|
||||
component.authenticate(userName, credentials.toCharArray());
|
||||
|
||||
CompositeType cType = new CompositeType("Authentication Result", "Result Success", attributeKeys, attributeDescriptions, attributeTypes);
|
||||
Map<String, Object> value = new HashMap<String, Object>();
|
||||
value.put("authenticationMessage", "Test Passed");
|
||||
value.put("success", true);
|
||||
value.put("diagnostic", table);
|
||||
CompositeDataSupport row = new CompositeDataSupport(cType, value);
|
||||
return row;
|
||||
}
|
||||
catch (AuthenticationException ae)
|
||||
{
|
||||
CompositeType cType = new CompositeType("Authentication Result", "Result Failed", attributeKeys, attributeDescriptions, attributeTypes);
|
||||
Map<String, Object> value = new HashMap<String, Object>();
|
||||
value.put("authenticationMessage", ae.getMessage());
|
||||
value.put("success", false);
|
||||
|
||||
if(ae.getDiagnostic() != null)
|
||||
{
|
||||
int i = 0;
|
||||
for(AuthenticationStep step : ae.getDiagnostic().getSteps())
|
||||
{
|
||||
Map<String, Object> x = new HashMap<String, Object>();
|
||||
x.put("id", i++);
|
||||
x.put("stepMessage", step.getMessage());
|
||||
x.put("success", step.isSuccess());
|
||||
CompositeDataSupport row = new CompositeDataSupport(sType, x);
|
||||
table.put(row);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
value.put("diagnostic", table);
|
||||
|
||||
CompositeDataSupport row = new CompositeDataSupport(cType, value);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
catch (OpenDataException oe)
|
||||
{
|
||||
logger.error("", oe);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberFailedAuthentications()
|
||||
{
|
||||
return component.getNumberFailedAuthentications();
|
||||
}
|
||||
|
||||
public int getNumberSuccessfulAuthentications()
|
||||
{
|
||||
return component.getNumberSuccessfulAuthentications();
|
||||
}
|
||||
|
||||
public String getSynchronizationStatus()
|
||||
{
|
||||
return syncMonitor.getSynchronizationStatus(getZone(component.getId()));
|
||||
}
|
||||
|
||||
// public Date getSynchronizationLastUserUpdateTime()
|
||||
// {
|
||||
// // TODO This method fails due to a unable to find transaction error - Comment out for now
|
||||
// return syncMonitor.getSynchronizationLastUserUpdateTime(getZone(component.getId()));
|
||||
// }
|
||||
//
|
||||
// public Date getSynchronizationLastGroupUpdateTime()
|
||||
// {
|
||||
// // TODO This method fails due to a unable to find transaction error - Comment out for now
|
||||
// return syncMonitor.getSynchronizationLastGroupUpdateTime(getZone(component.getId()));
|
||||
// }
|
||||
//
|
||||
public String getSynchronizationLastError()
|
||||
{
|
||||
return syncMonitor.getSynchronizationLastError(getZone(component.getId()));
|
||||
}
|
||||
|
||||
public String getSynchronizationSummary()
|
||||
{
|
||||
return syncMonitor.getSynchronizationSummary(getZone(component.getId()));
|
||||
}
|
||||
|
||||
public String getLastRunOnServer()
|
||||
{
|
||||
return syncMonitor.getLastRunOnServer();
|
||||
}
|
||||
|
||||
public Date getSyncStartTime()
|
||||
{
|
||||
return syncMonitor.getSyncStartTime();
|
||||
}
|
||||
|
||||
public Date getSyncEndTime()
|
||||
{
|
||||
return syncMonitor.getSyncEndTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the zone for an ldap authentication component. e.g given [managed,ldap1] return ldap1
|
||||
* @param id ths id of the subsystem
|
||||
* @return the zone
|
||||
*/
|
||||
private String getZone(String id)
|
||||
{
|
||||
|
||||
String s = id.replace("[", "");
|
||||
String s2 = s.replace("]", "");
|
||||
String[] ids = s2.split(",");
|
||||
|
||||
String x = ids[ids.length -1].trim();
|
||||
|
||||
return x;
|
||||
|
||||
}
|
||||
}
|
||||
package org.alfresco.repo.security.authentication.ldap;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.TabularType;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationStep;
|
||||
import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizerStatus;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Monitoring methods and properties to be exposed via the
|
||||
* JMX admin console.
|
||||
*/
|
||||
|
||||
public class Monitor
|
||||
{
|
||||
LDAPAuthenticationComponentImpl component;
|
||||
ChainingUserRegistrySynchronizerStatus syncMonitor;
|
||||
String id;
|
||||
|
||||
private static Log logger = LogFactory.getLog(Monitor.class);
|
||||
|
||||
public void setLDAPAuthenticationComponent(LDAPAuthenticationComponentImpl component)
|
||||
{
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public void setChainingUserRegistrySynchronizerStatus(ChainingUserRegistrySynchronizerStatus syncStatus)
|
||||
{
|
||||
this.syncMonitor = syncStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* test authenticate
|
||||
*
|
||||
* @param userName String
|
||||
* @param credentials String
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
public CompositeData testAuthenticate(String userName, String credentials)
|
||||
{
|
||||
String stepKeys[] = {"id", "stepMessage", "success"};
|
||||
String stepDescriptions[] = {"id", "stepMessage", "success"};
|
||||
OpenType<?> stepTypes[] = {SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN };
|
||||
|
||||
try
|
||||
{
|
||||
String[] key = {"id"};
|
||||
CompositeType sType = new CompositeType("Authentication Step", "Step", stepKeys, stepDescriptions, stepTypes);
|
||||
TabularType tType = new TabularType("Diagnostic", "Authentication Steps", sType, key);
|
||||
TabularData table = new TabularDataSupport(tType);
|
||||
|
||||
String attributeKeys[] = {"authenticationMessage", "success", "diagnostic"};
|
||||
String attributeDescriptions[] = {"authenticationMessage", "success", "diagnostic"};
|
||||
OpenType<?> attributeTypes[] = {SimpleType.STRING, SimpleType.BOOLEAN, tType};
|
||||
try
|
||||
{
|
||||
component.authenticate(userName, credentials.toCharArray());
|
||||
|
||||
CompositeType cType = new CompositeType("Authentication Result", "Result Success", attributeKeys, attributeDescriptions, attributeTypes);
|
||||
Map<String, Object> value = new HashMap<String, Object>();
|
||||
value.put("authenticationMessage", "Test Passed");
|
||||
value.put("success", true);
|
||||
value.put("diagnostic", table);
|
||||
CompositeDataSupport row = new CompositeDataSupport(cType, value);
|
||||
return row;
|
||||
}
|
||||
catch (AuthenticationException ae)
|
||||
{
|
||||
CompositeType cType = new CompositeType("Authentication Result", "Result Failed", attributeKeys, attributeDescriptions, attributeTypes);
|
||||
Map<String, Object> value = new HashMap<String, Object>();
|
||||
value.put("authenticationMessage", ae.getMessage());
|
||||
value.put("success", false);
|
||||
|
||||
if(ae.getDiagnostic() != null)
|
||||
{
|
||||
int i = 0;
|
||||
for(AuthenticationStep step : ae.getDiagnostic().getSteps())
|
||||
{
|
||||
Map<String, Object> x = new HashMap<String, Object>();
|
||||
x.put("id", i++);
|
||||
x.put("stepMessage", step.getMessage());
|
||||
x.put("success", step.isSuccess());
|
||||
CompositeDataSupport row = new CompositeDataSupport(sType, x);
|
||||
table.put(row);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
value.put("diagnostic", table);
|
||||
|
||||
CompositeDataSupport row = new CompositeDataSupport(cType, value);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
catch (OpenDataException oe)
|
||||
{
|
||||
logger.error("", oe);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberFailedAuthentications()
|
||||
{
|
||||
return component.getNumberFailedAuthentications();
|
||||
}
|
||||
|
||||
public int getNumberSuccessfulAuthentications()
|
||||
{
|
||||
return component.getNumberSuccessfulAuthentications();
|
||||
}
|
||||
|
||||
public String getSynchronizationStatus()
|
||||
{
|
||||
return syncMonitor.getSynchronizationStatus(getZone(component.getId()));
|
||||
}
|
||||
|
||||
// public Date getSynchronizationLastUserUpdateTime()
|
||||
// {
|
||||
// // TODO This method fails due to a unable to find transaction error - Comment out for now
|
||||
// return syncMonitor.getSynchronizationLastUserUpdateTime(getZone(component.getId()));
|
||||
// }
|
||||
//
|
||||
// public Date getSynchronizationLastGroupUpdateTime()
|
||||
// {
|
||||
// // TODO This method fails due to a unable to find transaction error - Comment out for now
|
||||
// return syncMonitor.getSynchronizationLastGroupUpdateTime(getZone(component.getId()));
|
||||
// }
|
||||
//
|
||||
public String getSynchronizationLastError()
|
||||
{
|
||||
return syncMonitor.getSynchronizationLastError(getZone(component.getId()));
|
||||
}
|
||||
|
||||
public String getSynchronizationSummary()
|
||||
{
|
||||
return syncMonitor.getSynchronizationSummary(getZone(component.getId()));
|
||||
}
|
||||
|
||||
public String getLastRunOnServer()
|
||||
{
|
||||
return syncMonitor.getLastRunOnServer();
|
||||
}
|
||||
|
||||
public Date getSyncStartTime()
|
||||
{
|
||||
return syncMonitor.getSyncStartTime();
|
||||
}
|
||||
|
||||
public Date getSyncEndTime()
|
||||
{
|
||||
return syncMonitor.getSyncEndTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the zone for an ldap authentication component. e.g given [managed,ldap1] return ldap1
|
||||
* @param id ths id of the subsystem
|
||||
* @return the zone
|
||||
*/
|
||||
private String getZone(String id)
|
||||
{
|
||||
|
||||
String s = id.replace("[", "");
|
||||
String s2 = s.replace("]", "");
|
||||
String[] ids = s2.split(",");
|
||||
|
||||
String x = ids[ids.length -1].trim();
|
||||
|
||||
return x;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,92 +1,92 @@
|
||||
package org.alfresco.repo.security.authentication.ldap;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.SimpleBeanInfo;
|
||||
/**
|
||||
* A BeanInfo providing metadata for the Monitor class
|
||||
*
|
||||
* @author mrogers
|
||||
*/
|
||||
public class MonitorBeanInfo extends SimpleBeanInfo
|
||||
{
|
||||
/**
|
||||
* Gets the beans <code>BeanDescriptor</code>.
|
||||
*
|
||||
* @return A BeanDescriptor providing overall information about
|
||||
* the bean, such as its displayName, its customizer, etc. May
|
||||
* return null if the information should be obtained by automatic
|
||||
* analysis.
|
||||
*/
|
||||
// BeanDescriptor getBeanDescriptor();
|
||||
|
||||
/**
|
||||
* Gets the beans <code>EventSetDescriptor</code>s.
|
||||
*
|
||||
* @return An array of EventSetDescriptors describing the kinds of
|
||||
* events fired by this bean. May return null if the information
|
||||
* should be obtained by automatic analysis.
|
||||
*/
|
||||
// EventSetDescriptor[] getEventSetDescriptors();
|
||||
|
||||
/**
|
||||
* A bean may have a "default" event that is the event that will
|
||||
* mostly commonly be used by humans when using the bean.
|
||||
* @return Index of default event in the EventSetDescriptor array
|
||||
* returned by getEventSetDescriptors.
|
||||
* <P> Returns -1 if there is no default event.
|
||||
*/
|
||||
// int getDefaultEventIndex();
|
||||
|
||||
/**
|
||||
* Returns descriptors for all properties of the bean.
|
||||
* May return {@code null} if the information
|
||||
* should be obtained by automatic analysis.
|
||||
* <p>
|
||||
* If a property is indexed, then its entry in the result array
|
||||
* will belong to the {@link IndexedPropertyDescriptor} subclass
|
||||
* of the {@link PropertyDescriptor} class.
|
||||
* A client of the {@code getPropertyDescriptors} method
|
||||
* can use "{@code instanceof}" to check
|
||||
* whether a given {@code PropertyDescriptor}
|
||||
* is an {@code IndexedPropertyDescriptor}.
|
||||
*
|
||||
* @return an array of {@code PropertyDescriptor}s
|
||||
* describing all properties supported by the bean
|
||||
* or {@code null}
|
||||
*/
|
||||
// PropertyDescriptor[] getPropertyDescriptors();
|
||||
|
||||
/**
|
||||
* A bean may have a "default" property that is the property that will
|
||||
* mostly commonly be initially chosen for update by human's who are
|
||||
* customizing the bean.
|
||||
* @return Index of default property in the PropertyDescriptor array
|
||||
* returned by getPropertyDescriptors.
|
||||
* <P> Returns -1 if there is no default property.
|
||||
*/
|
||||
// int getDefaultPropertyIndex();
|
||||
|
||||
/**
|
||||
* Gets the beans <code>MethodDescriptor</code>s.
|
||||
*
|
||||
* @return An array of MethodDescriptors describing the externally
|
||||
* visible methods supported by this bean. May return null if
|
||||
* the information should be obtained by automatic analysis.
|
||||
*/
|
||||
// MethodDescriptor[] getMethodDescriptors();
|
||||
|
||||
/**
|
||||
* This method allows a BeanInfo object to return an arbitrary collection
|
||||
* of other BeanInfo objects that provide additional information on the
|
||||
* current bean.
|
||||
* <P>
|
||||
* If there are conflicts or overlaps between the information provided
|
||||
* by different BeanInfo objects, then the current BeanInfo takes precedence
|
||||
* over the getAdditionalBeanInfo objects, and later elements in the array
|
||||
* take precedence over earlier ones.
|
||||
*
|
||||
* @return an array of BeanInfo objects. May return null.
|
||||
*/
|
||||
// BeanInfo[] getAdditionalBeanInfo();
|
||||
|
||||
}
|
||||
package org.alfresco.repo.security.authentication.ldap;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.SimpleBeanInfo;
|
||||
/**
|
||||
* A BeanInfo providing metadata for the Monitor class
|
||||
*
|
||||
* @author mrogers
|
||||
*/
|
||||
public class MonitorBeanInfo extends SimpleBeanInfo
|
||||
{
|
||||
/**
|
||||
* Gets the beans <code>BeanDescriptor</code>.
|
||||
*
|
||||
* @return A BeanDescriptor providing overall information about
|
||||
* the bean, such as its displayName, its customizer, etc. May
|
||||
* return null if the information should be obtained by automatic
|
||||
* analysis.
|
||||
*/
|
||||
// BeanDescriptor getBeanDescriptor();
|
||||
|
||||
/**
|
||||
* Gets the beans <code>EventSetDescriptor</code>s.
|
||||
*
|
||||
* @return An array of EventSetDescriptors describing the kinds of
|
||||
* events fired by this bean. May return null if the information
|
||||
* should be obtained by automatic analysis.
|
||||
*/
|
||||
// EventSetDescriptor[] getEventSetDescriptors();
|
||||
|
||||
/**
|
||||
* A bean may have a "default" event that is the event that will
|
||||
* mostly commonly be used by humans when using the bean.
|
||||
* @return Index of default event in the EventSetDescriptor array
|
||||
* returned by getEventSetDescriptors.
|
||||
* <P> Returns -1 if there is no default event.
|
||||
*/
|
||||
// int getDefaultEventIndex();
|
||||
|
||||
/**
|
||||
* Returns descriptors for all properties of the bean.
|
||||
* May return {@code null} if the information
|
||||
* should be obtained by automatic analysis.
|
||||
* <p>
|
||||
* If a property is indexed, then its entry in the result array
|
||||
* will belong to the {@link IndexedPropertyDescriptor} subclass
|
||||
* of the {@link PropertyDescriptor} class.
|
||||
* A client of the {@code getPropertyDescriptors} method
|
||||
* can use "{@code instanceof}" to check
|
||||
* whether a given {@code PropertyDescriptor}
|
||||
* is an {@code IndexedPropertyDescriptor}.
|
||||
*
|
||||
* @return an array of {@code PropertyDescriptor}s
|
||||
* describing all properties supported by the bean
|
||||
* or {@code null}
|
||||
*/
|
||||
// PropertyDescriptor[] getPropertyDescriptors();
|
||||
|
||||
/**
|
||||
* A bean may have a "default" property that is the property that will
|
||||
* mostly commonly be initially chosen for update by human's who are
|
||||
* customizing the bean.
|
||||
* @return Index of default property in the PropertyDescriptor array
|
||||
* returned by getPropertyDescriptors.
|
||||
* <P> Returns -1 if there is no default property.
|
||||
*/
|
||||
// int getDefaultPropertyIndex();
|
||||
|
||||
/**
|
||||
* Gets the beans <code>MethodDescriptor</code>s.
|
||||
*
|
||||
* @return An array of MethodDescriptors describing the externally
|
||||
* visible methods supported by this bean. May return null if
|
||||
* the information should be obtained by automatic analysis.
|
||||
*/
|
||||
// MethodDescriptor[] getMethodDescriptors();
|
||||
|
||||
/**
|
||||
* This method allows a BeanInfo object to return an arbitrary collection
|
||||
* of other BeanInfo objects that provide additional information on the
|
||||
* current bean.
|
||||
* <P>
|
||||
* If there are conflicts or overlaps between the information provided
|
||||
* by different BeanInfo objects, then the current BeanInfo takes precedence
|
||||
* over the getAdditionalBeanInfo objects, and later elements in the array
|
||||
* take precedence over earlier ones.
|
||||
*
|
||||
* @return an array of BeanInfo objects. May return null.
|
||||
*/
|
||||
// BeanInfo[] getAdditionalBeanInfo();
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user