Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed May 29, 2023
2 parents 3f52e75 + e5046ee commit 5fe0dff
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public boolean isSupportActivationByChannel() {
return false;
}

@Override
public String getPathDuringProccessing() {
return "/";
}

@Override
public Collection<Authorization> resolveAuthorities(Collection<Authorization> authorities) {
ArrayList<Authorization> newAuthorities = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
package com.evolveum.midpoint.authentication.impl.filter;

import java.io.IOException;

import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceChannelType;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -57,15 +60,19 @@ protected void sendStartAuthentication(HttpServletRequest request, HttpServletRe
ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication != null && moduleAuthentication.getAuthentication() instanceof AnonymousAuthenticationToken
&& !mpAuthentication.hasSucceededAuthentication()) {
AuthenticationSequenceChannelType channel = mpAuthentication.getSequence() != null ?
mpAuthentication.getSequence().getChannel() : null;
moduleAuthentication.setAuthentication(
createNewAuthentication((AnonymousAuthenticationToken) moduleAuthentication.getAuthentication()));
createNewAuthentication((AnonymousAuthenticationToken) moduleAuthentication.getAuthentication(),
channel));
mpAuthentication.setPrincipal(null);
}
SecurityContextHolder.getContext().setAuthentication(mpAuthentication);
}
}

protected Authentication createNewAuthentication(AnonymousAuthenticationToken authentication) {
protected Authentication createNewAuthentication(AnonymousAuthenticationToken authentication,
AuthenticationSequenceChannelType channel) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import com.evolveum.midpoint.authentication.impl.filter.MidpointAnonymousAuthenticationFilter;
import com.evolveum.midpoint.authentication.impl.filter.MidpointExceptionTranslationFilter;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceChannelType;

import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.authentication.AuthenticationTrustResolver;
import org.springframework.security.config.annotation.web.HttpSecurityBuilder;
Expand Down Expand Up @@ -87,8 +89,9 @@ public void configure(H http) throws Exception {
ExceptionTranslationFilter exceptionTranslationFilter = new MidpointExceptionTranslationFilter(
entryPoint, getRequestCache(http)) {
@Override
protected Authentication createNewAuthentication(AnonymousAuthenticationToken authentication) {
return MidpointExceptionHandlingConfigurer.this.createNewAuthentication(authentication);
protected Authentication createNewAuthentication(AnonymousAuthenticationToken authentication,
AuthenticationSequenceChannelType channel) {
return MidpointExceptionHandlingConfigurer.this.createNewAuthentication(authentication, channel);
}
};
AccessDeniedHandler deniedHandler = getAccessDeniedHandler();
Expand All @@ -98,7 +101,8 @@ protected Authentication createNewAuthentication(AnonymousAuthenticationToken au
http.addFilterAfter(exceptionTranslationFilter, MidpointAnonymousAuthenticationFilter.class);
}

protected Authentication createNewAuthentication(AnonymousAuthenticationToken authentication) {
protected Authentication createNewAuthentication(AnonymousAuthenticationToken authentication,
AuthenticationSequenceChannelType channel) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
import com.evolveum.midpoint.authentication.api.util.AuthUtil;
import com.evolveum.midpoint.authentication.api.ModuleWebSecurityConfiguration;

import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceChannelType;

import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.Authentication;


/**
* @author skublik
Expand All @@ -36,7 +42,18 @@ protected void configure(HttpSecurity http) throws Exception {
.failureHandler(new MidpointAuthenticationFailureHandler())
.successHandler(getObjectPostProcessor().postProcess(
new MidPointAuthenticationSuccessHandler())).permitAll();
getOrApply(http, new MidpointExceptionHandlingConfigurer<>())
MidpointExceptionHandlingConfigurer exceptionConfigurer = new MidpointExceptionHandlingConfigurer() {
@Override
protected Authentication createNewAuthentication(AnonymousAuthenticationToken anonymousAuthenticationToken,
AuthenticationSequenceChannelType channel) {
if (channel != null && SchemaConstants.CHANNEL_INVITATION_URI.equals(channel.getChannelId())) {
anonymousAuthenticationToken.setAuthenticated(false);
return anonymousAuthenticationToken;
}
return null;
}
};
getOrApply(http, exceptionConfigurer)
.authenticationEntryPoint(new WicketLoginUrlAuthenticationEntryPoint(
getConfiguration().getSpecificLoginUrl() == null ? "/emailNonce" : getConfiguration().getSpecificLoginUrl()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
package com.evolveum.midpoint.authentication.impl.module.configurer;

import java.util.UUID;

import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceChannelType;

import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;

Expand Down Expand Up @@ -70,7 +73,8 @@ protected void configure(HttpSecurity http) throws Exception {

MidpointExceptionHandlingConfigurer exceptionConfigurer = new MidpointExceptionHandlingConfigurer() {
@Override
protected Authentication createNewAuthentication(AnonymousAuthenticationToken anonymousAuthenticationToken) {
protected Authentication createNewAuthentication(AnonymousAuthenticationToken anonymousAuthenticationToken,
AuthenticationSequenceChannelType channel) {
if (anonymousAuthenticationToken.getDetails() != null
&& getAuthTokenClass().isAssignableFrom(anonymousAuthenticationToken.getDetails().getClass())) {
return (Authentication) anonymousAuthenticationToken.getDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ private PrismObject<? extends ObjectType> getCurrentNodeObject(Collection<Select
}
}

@GetMapping("/self/")
public ResponseEntity<?> getSelfAlt() {
return getSelf();
}

@GetMapping("/self")
public ResponseEntity<?> getSelf() {
logger.debug("model rest service for get operation start");
Expand All @@ -306,6 +311,14 @@ public ResponseEntity<?> getSelf() {
return response;
}

@PostMapping("/{type}/")
public <T extends ObjectType> ResponseEntity<?> addObjectAlt(
@PathVariable("type") String type,
@RequestParam(value = "options", required = false) List<String> options,
@RequestBody @NotNull PrismObject<T> object) {
return addObject(type, options, object);
}

@PostMapping("/{type}")
public <T extends ObjectType> ResponseEntity<?> addObject(
@PathVariable("type") String type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@
package com.evolveum.midpoint.repo.sql.util;

import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL95Dialect;
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.jdbc.LongVarbinaryJdbcType;
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl;

import java.sql.Types;

/**
* @author lazyman
*/
public class MidPointPostgreSQLDialect extends PostgreSQL95Dialect {
public class MidPointPostgreSQLDialect extends PostgreSQLDialect {

public MidPointPostgreSQLDialect() {

super( DatabaseVersion.make( 9, 5 ) );
}

@Override
protected void registerColumnTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
super.registerColumnTypes(typeContributions, serviceRegistry);
var blobBytea = new DdlTypeImpl(SqlTypes.BLOB, "bytea", this);
typeContributions.getTypeConfiguration().getDdlTypeRegistry().addDescriptor(blobBytea);

typeContributions.getTypeConfiguration().getJdbcTypeRegistry().addDescriptor(Types.BLOB, LongVarbinaryJdbcType.INSTANCE);
}

@Override
Expand All @@ -40,13 +42,4 @@ protected String columnType(int sqlTypeCode) {
return super.columnType(sqlTypeCode);
}

/*
@Override
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
if (Types.BLOB == sqlCode) {
return LongVarbinaryTypeDescriptor.INSTANCE;
}
return super.getSqlTypeDescriptorOverride(sqlCode);
}*/
}
2 changes: 1 addition & 1 deletion testing/story/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<artifactId>artemis-jakarta-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<!-- administrator -->
</ownerRef>
<executionState>runnable</executionState>
<category>AsynchronousUpdate</category>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/async-update/handler-3</handlerUri>
<objectRef oid="1eff65de-5bb6-483d-9edf-8cc2c2ee0233" relation="org:default" type="c:ResourceType">
<!-- Grouper Resource -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ Looks for groups with the lifecycleState of 'retired' and completes their deleti
</extension>
<ownerRef oid="00000000-0000-0000-0000-000000000002"/>
<executionState>runnable</executionState>
<category>BulkActions</category>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/iterative-scripting/handler-3</handlerUri>
<schedule>
<recurrence>recurring</recurrence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class ExportMiningOptions extends BaseMiningOptions implements BasicExpor
public static final String P_SUFFIX_APPLICATION_LONG = "--applicationRoleSuffix";
public static final String P_SUFFIX_BUSINESS = "-brs";
public static final String P_SUFFIX_BUSINESS_LONG = "--businessRoleSuffix";
public static final String P_ORG = "-org";
public static final String P_ORG_LONG = "--includeOrg";
public static final String P_ORG = "-do";
public static final String P_ORG_LONG = "--disableOrg";
public static final String P_NAME_OPTIONS = "-nm";
public static final String P_NAME_OPTIONS_LONG = "--nameMode";
public static final String P_ARCHETYPE_OID_APPLICATION_LONG = "--applicationRoleArchetypeOid";
Expand Down Expand Up @@ -64,7 +64,7 @@ public class ExportMiningOptions extends BaseMiningOptions implements BasicExpor
private String applicationRolePrefix;

@Parameter(names = { P_ORG, P_ORG_LONG }, descriptionKey = "export.prevent.org")
private boolean includeOrg = true;
private boolean disableOrg = false;

@Parameter(names = { P_NAME_OPTIONS, P_NAME_OPTIONS_LONG }, descriptionKey = "export.name.options")
private RoleMiningExportUtils.NameMode nameMode = RoleMiningExportUtils.NameMode.SEQUENTIAL;
Expand All @@ -82,7 +82,7 @@ public RoleMiningExportUtils.SecurityMode getSecurityLevel() {
}

public boolean isIncludeOrg() {
return includeOrg;
return !disableOrg;
}

public String getApplicationRoleArchetypeOid() {
Expand Down
2 changes: 1 addition & 1 deletion tools/ninja/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export.application.role.prefix=Prefix for identifying exported application roles
export.application.role.suffix=Suffix for identifying exported application roles. Multiple suffixes can be specified using a comma "," as a delimiter.
export.business.role.prefix=Prefix for identifying exported business roles. Multiple prefixes can be specified using a comma "," as a delimiter.
export.business.role.suffix=Suffix for identifying exported business roles. Multiple suffixes can be specified using a comma "," as a delimiter.
export.prevent.org=Specifies whether to include the export of organizational structures.
export.prevent.org=Prevent the export of organizational structures.
export.name.options=Defines the format of the name parameter in the export.
export.business.role.archetype.oid=Detects a business role based on a specific archetype, provided by its OID.
export.application.role.archetype.oid=Detects an application role based on a specific archetype, provided by its OID.
Expand Down

0 comments on commit 5fe0dff

Please sign in to comment.