Search in sources :

Example 1 with ApplicationUser

use of org.isisaddons.module.security.dom.user.ApplicationUser in project estatio by estatio.

the class ApplicationUserBuilder method execute.

@Override
protected void execute(ExecutionContext executionContext) {
    checkParam("person", executionContext, Person.class);
    checkParam("securityUsername", executionContext, String.class);
    defaultParam("securityUserAccountCloneFrom", executionContext, "estatio-admin");
    if (securityUsername != null) {
        ApplicationUser userToCloneFrom = applicationUserRepository.findByUsername(securityUserAccountCloneFrom);
        if (userToCloneFrom == null) {
            throw new IllegalArgumentException("Could not find any user with username: " + securityUserAccountCloneFrom);
        }
        object = applicationUserRepository.newLocalUserBasedOn(securityUsername, new Password("pass"), new Password("pass"), userToCloneFrom, true, null);
        object.setAtPath(person.getAtPath());
        person.setUsername(securityUsername);
        executionContext.addResult(this, securityUsername, userToCloneFrom);
    }
}
Also used : ApplicationUser(org.isisaddons.module.security.dom.user.ApplicationUser) Password(org.apache.isis.applib.value.Password)

Example 2 with ApplicationUser

use of org.isisaddons.module.security.dom.user.ApplicationUser in project estatio by estatio.

the class AbstractUserRoleFixtureScript method addUserToRole.

protected ApplicationUser addUserToRole(final String userName, final String roleName, final ExecutionContext executionContext) {
    final ApplicationUser user = applicationUserRepository.findOrCreateUserByUsername(userName);
    final ApplicationRole applicationRole = applicationRoleRepository.findByName(roleName);
    if (applicationRole == null) {
        throw new IllegalArgumentException(String.format("Role [%s] not found", roleName));
    }
    user.addRole(applicationRole);
    executionContext.addResult(this, roleName, applicationRole);
    return user;
}
Also used : ApplicationUser(org.isisaddons.module.security.dom.user.ApplicationUser) ApplicationRole(org.isisaddons.module.security.dom.role.ApplicationRole)

Example 3 with ApplicationUser

use of org.isisaddons.module.security.dom.user.ApplicationUser in project estatio by estatio.

the class DocumentMenu method upload.

@Action(domainEvent = IncomingDocumentRepository.UploadDomainEvent.class, commandDtoProcessor = DeriveBlobFromReturnedDocumentArg0.class)
@MemberOrder(sequence = "3")
public Document upload(final Blob blob) {
    final String name = blob.getName();
    final DocumentType type = DocumentTypeData.INCOMING.findUsing(documentTypeRepository);
    final ApplicationUser me = meService.me();
    String atPath = me != null ? me.getAtPath() : null;
    if (atPath == null) {
        atPath = "/";
    }
    return incomingDocumentRepository.upsertAndArchive(type, atPath, name, blob);
}
Also used : ApplicationUser(org.isisaddons.module.security.dom.user.ApplicationUser) DocumentType(org.incode.module.document.dom.impl.types.DocumentType) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 4 with ApplicationUser

use of org.isisaddons.module.security.dom.user.ApplicationUser in project estatio by estatio.

the class EstatioUserProfileService method userProfileName.

@Programmatic
@Override
public String userProfileName() {
    final ApplicationUser currentUser = meService.me();
    final String atPath = currentUser.getAtPath();
    if (atPath != null) {
        return String.format("%s @ %s", currentUser.getName(), atPath);
    } else {
        return String.format("%s", currentUser.getName());
    }
}
Also used : ApplicationUser(org.isisaddons.module.security.dom.user.ApplicationUser) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

ApplicationUser (org.isisaddons.module.security.dom.user.ApplicationUser)4 Action (org.apache.isis.applib.annotation.Action)1 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 Password (org.apache.isis.applib.value.Password)1 DocumentType (org.incode.module.document.dom.impl.types.DocumentType)1 ApplicationRole (org.isisaddons.module.security.dom.role.ApplicationRole)1