org.exist.security.AbstractSubject Maven / Gradle / Ivy
/*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
* [email protected]
* http://www.exist-db.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.exist.security;
import java.util.Optional;
import java.util.Set;
import org.exist.config.Configuration;
import org.exist.security.realm.Realm;
import org.exist.storage.DBBroker;
/**
* @author Dmitriy Shabanov
*
*/
public abstract class AbstractSubject implements Subject {
protected final AbstractAccount account;
protected final Session session;
public AbstractSubject(final AbstractAccount account) {
this.account = account;
this.session = new Session(this);
}
@Override
public Group addGroup(final String name) throws PermissionDeniedException {
return account.addGroup(name);
}
@Override
public Group addGroup(final Group group) throws PermissionDeniedException {
return account.addGroup(group);
}
@Override
public void setPrimaryGroup(final Group group) throws PermissionDeniedException {
account.setPrimaryGroup(group);
}
@Override
public void remGroup(final String group) throws PermissionDeniedException {
account.remGroup(group);
}
@Override
public String[] getGroups() {
return account.getGroups();
}
@Override
public int[] getGroupIds() {
return account.getGroupIds();
}
@Override
public boolean hasDbaRole() {
return account.hasDbaRole();
}
@Override
public String getPrimaryGroup() {
return account.getPrimaryGroup();
}
@Override
public Group getDefaultGroup() {
return account.getDefaultGroup();
}
@Override
public boolean hasGroup(final String group) {
return account.hasGroup(group);
}
@Override
public void setPassword(final String passwd) {
account.setPassword(passwd);
}
@Override
public void setCredential(final Credential credential) {
account.setCredential(credential);
}
@Override
public Realm getRealm() {
return account.getRealm();
}
@Override
public String getPassword() {
return account.getPassword();
}
@Override
public String getDigestPassword() {
return account.getDigestPassword();
}
@Override
public void setGroups(final String[] groups) {
account.setGroups(groups);
}
@Override
public String getRealmId() {
return account.getRealmId();
}
@Override
public int getId() {
return account.getId();
}
@Override
public String getName() {
return account.getName();
}
@Override
public boolean isConfigured() {
return account.isConfigured();
}
@Override
public Configuration getConfiguration() {
return account.getConfiguration();
}
@Override
public String getUsername() {
return account.getUsername();
}
@Override
public boolean isAccountNonExpired() {
return account.isAccountNonExpired();
}
@Override
public boolean isAccountNonLocked() {
return account.isAccountNonLocked();
}
@Override
public boolean isCredentialsNonExpired() {
return account.isCredentialsNonExpired();
}
@Override
public void setEnabled(final boolean enabled) {
account.setEnabled(enabled);
}
@Override
public boolean isEnabled() {
return account.isEnabled();
}
@Override
public boolean equals(final Object obj) {
return Optional
.ofNullable(obj)
.flatMap(other -> other instanceof Account ? Optional.of((Account)other) : Optional.empty())
.map(account::equals)
.orElse(false);
}
@Override
public String getSessionId() {
return session.getId();
}
@Override
public Session getSession() {
return session;
}
@Override
public void save() throws PermissionDeniedException {
//do nothing
}
@Override
public void save(final DBBroker broker) throws PermissionDeniedException {
//do nothing
}
@Override
public String getMetadataValue(final SchemaType schemaType) {
return account.getMetadataValue(schemaType);
}
@Override
public void setMetadataValue(final SchemaType schemaType, final String value) {
account.setMetadataValue(schemaType, value);
}
@Override
public Set getMetadataKeys() {
return account.getMetadataKeys();
}
@Override
public void assertCanModifyAccount(final Account user) throws PermissionDeniedException {
account.assertCanModifyAccount(user);
}
@Override
public void clearMetadata() {
account.clearMetadata();
}
@Override
public int getUserMask() {
return account.getUserMask();
}
@Override
public void setUserMask(final int umask) {
account.setUserMask(umask);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy