use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType in project midpoint by Evolveum.
the class InitialDataImport method init.
public void init() throws SchemaException {
LOGGER.info("Starting initial object import (if necessary).");
OperationResult mainResult = new OperationResult(OPERATION_INITIAL_OBJECTS_IMPORT);
Task task = taskManager.createTaskInstance(OPERATION_INITIAL_OBJECTS_IMPORT);
task.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI);
int count = 0;
int errors = 0;
File[] files = getInitialImportObjects();
LOGGER.debug("Files to be imported: {}.", Arrays.toString(files));
// We need to provide a fake Spring security context here.
// We have to fake it because we do not have anything in the repository yet. And to get
// something to the repository we need a context. Chicken and egg. So we fake the egg.
SecurityContext securityContext = SecurityContextHolder.getContext();
UserType userAdministrator = new UserType();
prismContext.adopt(userAdministrator);
userAdministrator.setName(new PolyStringType(new PolyString("initAdmin", "initAdmin")));
MidPointPrincipal principal = new MidPointPrincipal(userAdministrator);
AuthorizationType superAutzType = new AuthorizationType();
prismContext.adopt(superAutzType, RoleType.class, new ItemPath(RoleType.F_AUTHORIZATION));
superAutzType.getAction().add(AuthorizationConstants.AUTZ_ALL_URL);
Authorization superAutz = new Authorization(superAutzType);
Collection<Authorization> authorities = principal.getAuthorities();
authorities.add(superAutz);
Authentication authentication = new PreAuthenticatedAuthenticationToken(principal, null);
securityContext.setAuthentication(authentication);
for (File file : files) {
try {
LOGGER.debug("Considering initial import of file {}.", file.getName());
PrismObject object = prismContext.parseObject(file);
if (ReportType.class.equals(object.getCompileTimeClass())) {
ReportTypeUtil.applyDefinition(object, prismContext);
}
Boolean importObject = importObject(object, file, task, mainResult);
if (importObject == null) {
continue;
}
if (importObject) {
count++;
} else {
errors++;
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import file {}", ex, file.getName());
mainResult.recordFatalError("Couldn't import file '" + file.getName() + "'", ex);
}
}
securityContext.setAuthentication(null);
mainResult.recomputeStatus("Couldn't import objects.");
LOGGER.info("Initial object import finished ({} objects imported, {} errors)", count, errors);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Initialization status:\n" + mainResult.debugDump());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType in project midpoint by Evolveum.
the class TestAbstractAuthenticationEvaluator method addFakeAuthorization.
private void addFakeAuthorization(MidPointPrincipal principal) {
if (principal == null) {
return;
}
if (principal.getAuthorities().isEmpty()) {
AuthorizationType authorizationType = new AuthorizationType();
authorizationType.getAction().add("FAKE");
principal.getAuthorities().add(new Authorization(authorizationType));
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType in project midpoint by Evolveum.
the class GuiAuthenticationChannel method resolveAuthorities.
@Override
public Collection<Authorization> resolveAuthorities(Collection<Authorization> authorities) {
if (isPostAuthenticationEnabled()) {
AuthorizationType authorizationType = new AuthorizationType();
authorizationType.getAction().add(AuthorizationConstants.AUTZ_UI_SELF_POST_AUTHENTICATION_URL);
Authorization postAuthenticationAuthz = new Authorization(authorizationType);
return Collections.singletonList(postAuthenticationAuthz);
}
return super.resolveAuthorities(authorities);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType in project midpoint by Evolveum.
the class ResetPasswordAuthenticationChannel method resolveAuthorities.
public Collection<Authorization> resolveAuthorities(@NotNull Collection<Authorization> authorities) {
ArrayList<Authorization> newAuthorities = new ArrayList<>();
for (Authorization authzI : authorities) {
authzI.getAction().removeIf(action -> action.contains(AuthorizationConstants.NS_AUTHORIZATION_UI));
}
AuthorizationType authorizationType = new AuthorizationType();
authorizationType.getAction().add(AuthorizationConstants.AUTZ_UI_SELF_CREDENTIALS_URL);
Authorization selfServiceCredentialsAuthz = new Authorization(authorizationType);
newAuthorities.add(selfServiceCredentialsAuthz);
authorities.addAll(newAuthorities);
return authorities;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType in project midpoint by Evolveum.
the class SecurityContextManagerImpl method createPrivilegedAuthorization.
private Authorization createPrivilegedAuthorization() {
AuthorizationType authorizationType = new AuthorizationType();
authorizationType.getAction().add(AuthorizationConstants.AUTZ_ALL_URL);
return new Authorization(authorizationType);
}
Aggregations