|
@@ -23,6 +23,7 @@
|
|
package password.pwm.ws.server.rest;
|
|
package password.pwm.ws.server.rest;
|
|
|
|
|
|
import com.novell.ldapchai.exception.ChaiUnavailableException;
|
|
import com.novell.ldapchai.exception.ChaiUnavailableException;
|
|
|
|
+import jetbrains.exodus.core.dataStructures.hash.LinkedHashSet;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import password.pwm.PwmConstants;
|
|
import password.pwm.PwmConstants;
|
|
import password.pwm.config.PwmSetting;
|
|
import password.pwm.config.PwmSetting;
|
|
@@ -61,8 +62,10 @@ import javax.servlet.annotation.WebServlet;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.Serializable;
|
|
import java.io.Serializable;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
|
|
@WebServlet(
|
|
@WebServlet(
|
|
urlPatterns = {
|
|
urlPatterns = {
|
|
@@ -73,6 +76,8 @@ import java.util.Map;
|
|
public class RestProfileServer extends RestServlet
|
|
public class RestProfileServer extends RestServlet
|
|
{
|
|
{
|
|
|
|
|
|
|
|
+ private static final String FIELD_USERNAME = "username";
|
|
|
|
+
|
|
@Data
|
|
@Data
|
|
public static class JsonProfileData implements Serializable
|
|
public static class JsonProfileData implements Serializable
|
|
{
|
|
{
|
|
@@ -191,7 +196,13 @@ public class RestProfileServer extends RestServlet
|
|
)
|
|
)
|
|
throws PwmUnrecoverableException, ChaiUnavailableException, PwmOperationalException
|
|
throws PwmUnrecoverableException, ChaiUnavailableException, PwmOperationalException
|
|
{
|
|
{
|
|
- final TargetUserIdentity targetUserIdentity = RestUtility.resolveRequestedUsername( restRequest, jsonInput.getUsername() );
|
|
|
|
|
|
+ final String username = RestUtility.readValueFromJsonAndParam(
|
|
|
|
+ jsonInput.getUsername(),
|
|
|
|
+ restRequest.readParameterAsString( FIELD_USERNAME ),
|
|
|
|
+ FIELD_USERNAME, RestUtility.ReadValueFlag.optional
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ final TargetUserIdentity targetUserIdentity = RestUtility.resolveRequestedUsername( restRequest, username );
|
|
|
|
|
|
final String updateProfileID = ProfileUtility.discoverProfileIDforUser(
|
|
final String updateProfileID = ProfileUtility.discoverProfileIDforUser(
|
|
restRequest.getPwmApplication(),
|
|
restRequest.getPwmApplication(),
|
|
@@ -225,15 +236,22 @@ public class RestProfileServer extends RestServlet
|
|
|
|
|
|
final FormMap inputFormData = new FormMap( jsonInput.profile );
|
|
final FormMap inputFormData = new FormMap( jsonInput.profile );
|
|
final List<FormConfiguration> profileForm = updateProfileProfile.readSettingAsForm( PwmSetting.UPDATE_PROFILE_FORM );
|
|
final List<FormConfiguration> profileForm = updateProfileProfile.readSettingAsForm( PwmSetting.UPDATE_PROFILE_FORM );
|
|
|
|
+ final Set<String> attributesInRequest = new HashSet<>( inputFormData.keySet() );
|
|
final Map<FormConfiguration, String> profileFormData = new HashMap<>();
|
|
final Map<FormConfiguration, String> profileFormData = new HashMap<>();
|
|
for ( final FormConfiguration formConfiguration : profileForm )
|
|
for ( final FormConfiguration formConfiguration : profileForm )
|
|
{
|
|
{
|
|
if ( !formConfiguration.isReadonly() && inputFormData.containsKey( formConfiguration.getName() ) )
|
|
if ( !formConfiguration.isReadonly() && inputFormData.containsKey( formConfiguration.getName() ) )
|
|
{
|
|
{
|
|
profileFormData.put( formConfiguration, inputFormData.get( formConfiguration.getName() ) );
|
|
profileFormData.put( formConfiguration, inputFormData.get( formConfiguration.getName() ) );
|
|
|
|
+ attributesInRequest.remove( formConfiguration.getName() );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ( !attributesInRequest.isEmpty() )
|
|
|
|
+ {
|
|
|
|
+ throw new PwmUnrecoverableException( PwmError.ERROR_REST_INVOCATION_ERROR, "unknown profile data field '" + attributesInRequest.iterator().next() + "'" );
|
|
|
|
+ }
|
|
|
|
+
|
|
final UserInfo userInfo = UserInfoFactory.newUserInfo(
|
|
final UserInfo userInfo = UserInfoFactory.newUserInfo(
|
|
restRequest.getPwmApplication(),
|
|
restRequest.getPwmApplication(),
|
|
restRequest.getSessionLabel(),
|
|
restRequest.getSessionLabel(),
|