use of org.apache.directory.api.ldap.model.message.ModifyRequest in project directory-ldap-api by apache.
the class LdapNetworkConnection method modify.
/**
* {@inheritDoc}
*/
@Override
public void modify(Dn dn, Modification... modifications) throws LdapException {
if (dn == null) {
if (LOG.isDebugEnabled()) {
LOG.debug(I18n.msg(I18n.MSG_03240_NULL_DN_MODIFY));
}
throw new IllegalArgumentException("The Dn to be modified cannot be null");
}
if ((modifications == null) || (modifications.length == 0)) {
String msg = "Cannot process a ModifyRequest without any modification";
LOG.debug(msg);
throw new IllegalArgumentException(msg);
}
ModifyRequest modReq = new ModifyRequestImpl();
modReq.setName(dn);
for (Modification modification : modifications) {
modReq.addModification(modification);
}
ModifyResponse modifyResponse = modify(modReq);
processResponse(modifyResponse);
}
use of org.apache.directory.api.ldap.model.message.ModifyRequest in project directory-ldap-api by apache.
the class LdapNetworkConnection method modify.
/**
* {@inheritDoc}
*/
@Override
public void modify(Entry entry, ModificationOperation modOp) throws LdapException {
if (entry == null) {
if (LOG.isDebugEnabled()) {
LOG.debug(I18n.msg(I18n.MSG_03241_NULL_ENTRY_MODIFY));
}
throw new IllegalArgumentException("Entry to be modified cannot be null");
}
ModifyRequest modReq = new ModifyRequestImpl();
modReq.setName(entry.getDn());
Iterator<Attribute> itr = entry.iterator();
while (itr.hasNext()) {
modReq.addModification(itr.next(), modOp);
}
ModifyResponse modifyResponse = modify(modReq);
processResponse(modifyResponse);
}
use of org.apache.directory.api.ldap.model.message.ModifyRequest in project directory-ldap-api by apache.
the class QuirkySchemaTest method createFakeConnection.
private LdapConnection createFakeConnection(final String schemaFileName) {
return new LdapConnection() {
@Override
public void unBind() throws LdapException {
}
@Override
public void setTimeOut(long timeOut) {
}
@Override
public void setSchemaManager(SchemaManager schemaManager) {
}
@Override
public void setBinaryAttributeDetector(BinaryAttributeDetector binaryAttributeDetecter) {
}
@Override
public SearchCursor search(SearchRequest searchRequest) throws LdapException {
return null;
}
@Override
public EntryCursor search(String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException {
return null;
}
@Override
public EntryCursor search(Dn baseDn, String filter, SearchScope scope, String... attributes) throws LdapException {
return null;
}
@Override
public void rename(Dn entryDn, Rdn newRdn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void rename(String entryDn, String newRdn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void rename(Dn entryDn, Rdn newRdn) throws LdapException {
}
@Override
public void rename(String entryDn, String newRdn) throws LdapException {
}
@Override
public void moveAndRename(String entryDn, String newDn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void moveAndRename(Dn entryDn, Dn newDn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void moveAndRename(String entryDn, String newDn) throws LdapException {
}
@Override
public void moveAndRename(Dn entryDn, Dn newDn) throws LdapException {
}
@Override
public void move(Dn entryDn, Dn newSuperiorDn) throws LdapException {
}
@Override
public void move(String entryDn, String newSuperiorDn) throws LdapException {
}
@Override
public ModifyDnResponse modifyDn(ModifyDnRequest modDnRequest) throws LdapException {
return null;
}
@Override
public ModifyResponse modify(ModifyRequest modRequest) throws LdapException {
return null;
}
@Override
public void modify(Entry entry, ModificationOperation modOp) throws LdapException {
}
@Override
public void modify(String dn, Modification... modifications) throws LdapException {
}
@Override
public void modify(Dn dn, Modification... modifications) throws LdapException {
}
@Override
public Entry lookup(String dn, Control[] controls, String... attributes) throws LdapException {
return lookup(new Dn(dn));
}
@Override
public Entry lookup(String dn, String... attributes) throws LdapException {
return lookup(new Dn(dn));
}
@Override
public Entry lookup(Dn dn, Control[] controls, String... attributes) throws LdapException {
return lookup(dn);
}
@Override
public Entry lookup(Dn dn, String... attributes) throws LdapException {
return lookup(dn);
}
@Override
public Entry lookup(String dn) throws LdapException {
return lookup(new Dn(dn));
}
@Override
public Entry lookup(Dn dn) throws LdapException {
if (dn.isRootDse()) {
Entry entry = new DefaultEntry(dn);
entry.add(SchemaConstants.SUBSCHEMA_SUBENTRY_AT, SCHEMA_DN);
return entry;
} else if (dn.toString().equals(SCHEMA_DN)) {
Entry entry = loadSchemaEntry(schemaFileName);
return entry;
} else {
throw new UnsupportedOperationException("Unexpected DN " + dn);
}
}
@Override
public void loadSchemaRelaxed() throws LdapException {
}
@Override
public void loadSchema() throws LdapException {
}
@Override
public boolean isRequestCompleted(int messageId) {
return true;
}
@Override
public boolean isControlSupported(String controlOID) throws LdapException {
return true;
}
@Override
public boolean isConnected() {
return true;
}
@Override
public boolean isAuthenticated() {
return false;
}
@Override
public List<String> getSupportedControls() throws LdapException {
return null;
}
@Override
public SchemaManager getSchemaManager() {
return null;
}
@Override
public Entry getRootDse(String... attributes) throws LdapException {
return lookup(Dn.ROOT_DSE);
}
@Override
public Entry getRootDse() throws LdapException {
return lookup(Dn.ROOT_DSE);
}
@Override
public LdapApiService getCodecService() {
return null;
}
@Override
public BinaryAttributeDetector getBinaryAttributeDetector() {
return null;
}
@Override
public ExtendedResponse extended(ExtendedRequest extendedRequest) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(Oid oid, byte[] value) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(Oid oid) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(String oid, byte[] value) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(String oid) throws LdapException {
return null;
}
@Override
public boolean exists(Dn dn) throws LdapException {
return false;
}
@Override
public boolean exists(String dn) throws LdapException {
return false;
}
@Override
public boolean doesFutureExistFor(int messageId) {
return false;
}
@Override
public DeleteResponse delete(DeleteRequest deleteRequest) throws LdapException {
return null;
}
@Override
public void delete(Dn dn) throws LdapException {
}
@Override
public void delete(String dn) throws LdapException {
}
@Override
public boolean connect() throws LdapException {
return true;
}
@Override
public CompareResponse compare(CompareRequest compareRequest) throws LdapException {
return null;
}
@Override
public boolean compare(Dn dn, String attributeName, byte[] value) throws LdapException {
return false;
}
@Override
public boolean compare(Dn dn, String attributeName, String value) throws LdapException {
return false;
}
@Override
public boolean compare(String dn, String attributeName, byte[] value) throws LdapException {
return false;
}
@Override
public boolean compare(String dn, String attributeName, String value) throws LdapException {
return false;
}
@Override
public void close() throws IOException {
}
@Override
public BindResponse bind(BindRequest bindRequest) throws LdapException {
return null;
}
@Override
public void bind(Dn name, String credentials) throws LdapException {
}
@Override
public void bind(Dn name) throws LdapException {
}
@Override
public void bind(String name, String credentials) throws LdapException {
}
@Override
public void bind(String name) throws LdapException {
}
@Override
public void bind() throws LdapException {
}
@Override
public void anonymousBind() throws LdapException {
}
@Override
public AddResponse add(AddRequest addRequest) throws LdapException {
return null;
}
@Override
public void add(Entry entry) throws LdapException {
}
@Override
public void abandon(AbandonRequest abandonRequest) {
}
@Override
public void abandon(int messageId) {
}
@Override
public boolean compare(String dn, String attributeName, Value value) throws LdapException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean compare(Dn dn, String attributeName, Value value) throws LdapException {
// TODO Auto-generated method stub
return false;
}
@Override
public BindResponse bind(SaslRequest saslRequest) throws LdapException {
// TODO Auto-generated method stub
return null;
}
};
}
use of org.apache.directory.api.ldap.model.message.ModifyRequest in project directory-ldap-api by apache.
the class AddModifyRequestAttribute method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<ModifyRequestDecorator> container) throws DecoderException {
ModifyRequestDecorator modifyRequestDecorator = container.getMessage();
ModifyRequest modifyRequest = modifyRequestDecorator.getDecorated();
TLV tlv = container.getCurrentTLV();
// Store the value. It can't be null
String type;
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04083);
LOG.error(msg);
ModifyResponseImpl response = new ModifyResponseImpl(modifyRequest.getMessageId());
throw new ResponseCarryingException(msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, modifyRequest.getName(), null);
} else {
type = Strings.utf8ToString(tlv.getValue().getData());
modifyRequestDecorator.addAttributeTypeAndValues(type);
}
if (IS_DEBUG) {
LOG.debug("Modifying type : {}", type);
}
}
use of org.apache.directory.api.ldap.model.message.ModifyRequest in project karaf by apache.
the class LdapSpecialCharsInPasswordTest method changeAdminPassword.
@Before
public void changeAdminPassword() throws Exception {
LdapConnection connection = new LdapNetworkConnection("localhost", getLdapServer().getPort());
connection.bind("uid=admin,ou=system", "secret");
Dn adminDn = new Dn("uid=admin,ou=system");
ModifyRequest modReq = new ModifyRequestImpl();
modReq.setName(adminDn);
modReq.replace(SchemaConstants.USER_PASSWORD_AT, NEW_CONNECTION_PASSWORD);
connection.modify(modReq);
connection.close();
// check that we actually changed the admin connection password
connection = new LdapNetworkConnection("localhost", getLdapServer().getPort());
connection.bind("uid=admin,ou=system", NEW_CONNECTION_PASSWORD);
connection.close();
}
Aggregations