mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8647 added new api linkLdapToDomain
also added the required dao, table and vo
This commit is contained in:
parent
0680648036
commit
e3ddde841e
@ -771,6 +771,7 @@ deleteLdapConfiguration=3
|
||||
listLdapUsers=3
|
||||
ldapCreateAccount=3
|
||||
importLdapUsers=3
|
||||
linkDomainToLdap=3
|
||||
|
||||
|
||||
#### juniper-contrail commands
|
||||
|
||||
@ -35,5 +35,6 @@
|
||||
<bean id="LdapConfigurationDao"
|
||||
class="org.apache.cloudstack.ldap.dao.LdapConfigurationDaoImpl" />
|
||||
<bean id="LdapConfiguration" class="org.apache.cloudstack.ldap.LdapConfiguration" />
|
||||
<bean id="LdapTrustMapDao" class="org.apache.cloudstack.ldap.dao.LdapTrustMapDaoImpl" />
|
||||
|
||||
</beans>
|
||||
|
||||
@ -20,8 +20,10 @@ package org.apache.cloudstack.api.command;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
@ -32,7 +34,8 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "linkDomainToLdap", description = "link an existing cloudstack domain to group or OU in ldap", responseObject = LinkDomainToLdapResponse.class, since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "linkDomainToLdap", description = "link an existing cloudstack domain to group or OU in ldap", responseObject = LinkDomainToLdapResponse.class, since = "4.6.0",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class LinkDomainToLdapCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(LinkDomainToLdapCmd.class.getName());
|
||||
private static final String s_name = "linkdomaintoldapresponse";
|
||||
@ -55,7 +58,14 @@ public class LinkDomainToLdapCmd extends BaseCmd {
|
||||
@Override
|
||||
public void execute() throws ServerApiException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
try {
|
||||
LinkDomainToLdapResponse response = _ldapManager.linkDomainToLdap(domainId, type, name);
|
||||
response.setObjectName("LinkDomainToLdap");
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
} catch (final InvalidParameterValueException e) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -25,6 +25,7 @@ import org.apache.cloudstack.api.response.LdapUserResponse;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import org.apache.cloudstack.api.response.LinkDomainToLdapResponse;
|
||||
|
||||
public interface LdapManager extends PluggableService {
|
||||
|
||||
@ -49,4 +50,6 @@ public interface LdapManager extends PluggableService {
|
||||
Pair<List<? extends LdapConfigurationVO>, Integer> listConfigurations(LdapListConfigurationCmd cmd);
|
||||
|
||||
List<LdapUser> searchUsers(String query) throws NoLdapUserMatchingQueryException;
|
||||
|
||||
LinkDomainToLdapResponse linkDomainToLdap(Long domainId, String type, String name);
|
||||
}
|
||||
@ -25,6 +25,9 @@ import javax.inject.Inject;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
|
||||
import org.apache.cloudstack.api.command.LinkDomainToLdapCmd;
|
||||
import org.apache.cloudstack.api.response.LinkDomainToLdapResponse;
|
||||
import org.apache.cloudstack.ldap.dao.LdapTrustMapDao;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -61,6 +64,9 @@ public class LdapManagerImpl implements LdapManager, LdapValidator {
|
||||
|
||||
@Inject LdapUserManagerFactory _ldapUserManagerFactory;
|
||||
|
||||
@Inject
|
||||
LdapTrustMapDao _ldapTrustMapDao;
|
||||
|
||||
|
||||
public LdapManagerImpl() {
|
||||
super();
|
||||
@ -168,6 +174,7 @@ public class LdapManagerImpl implements LdapManager, LdapValidator {
|
||||
cmdList.add(LdapImportUsersCmd.class);
|
||||
cmdList.add(LDAPConfigCmd.class);
|
||||
cmdList.add(LDAPRemoveCmd.class);
|
||||
cmdList.add(LinkDomainToLdapCmd.class);
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
@ -243,4 +250,11 @@ public class LdapManagerImpl implements LdapManager, LdapValidator {
|
||||
closeContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkDomainToLdapResponse linkDomainToLdap(Long domainId, String type, String name) {
|
||||
// TODO Auto-generated method stub
|
||||
LdapTrustMapVO ldapTrustMapVO = _ldapTrustMapDao.persist(new LdapTrustMapVO(domainId, type, name));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.ldap;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name = "ldap_trust_map")
|
||||
public class LdapTrustMapVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "domain_id")
|
||||
private long domainId;
|
||||
|
||||
public LdapTrustMapVO(long domainId, String type, String name) {
|
||||
this.domainId = domainId;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public LdapTrustMapVO() {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.ldap.dao;
|
||||
|
||||
import org.apache.cloudstack.ldap.LdapTrustMapVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface LdapTrustMapDao extends GenericDao<LdapTrustMapVO, Long> {
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.ldap.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.ldap.LdapTrustMapVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
@Component
|
||||
@Local(value = {LdapTrustMapDao.class})
|
||||
public class LdapTrustMapDaoImpl extends GenericDaoBase<LdapTrustMapVO, Long> implements LdapTrustMapDao {
|
||||
public LdapTrustMapDaoImpl() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@ -399,3 +399,13 @@ CREATE TABLE `cloud`.`external_bigswitch_bcf_devices` (
|
||||
CONSTRAINT `fk_external_bigswitch_bcf_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`ldap_trust_map` (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` bigint unsigned NOT NULL,
|
||||
`type` varchar(10) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_ldap_trust_map__domain_id` (`id`),
|
||||
KEY `fk_ldap_trust_map__domain_id` (`domain_id`),
|
||||
CONSTRAINT `fk_ldap_trust_map__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user