xmlrpc remote fpr ldap user

This commit is contained in:
Peter Hormanns 2018-08-29 18:21:16 +02:00
parent 9f47eba454
commit 75df8a9a85
9 changed files with 152 additions and 40 deletions

View File

@ -0,0 +1,12 @@
package de.hsadmin.service.ldap;
import de.hsadmin.xmlrpc.AbstractRemote;
public class LdapUserRemote extends AbstractRemote<LdapUserVO> {
@Override
protected String getModuleLookup() {
return "LdapUserServiceLocal";
}
}

View File

@ -3,6 +3,11 @@ package de.hsadmin.service.ldap;
import javax.ejb.Stateless;
import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.common.error.UserException;
import de.hsadmin.login.RequestContext;
import de.hsadmin.login.RequiredScope;
import de.hsadmin.login.Role;
import de.hsadmin.login.ScopePolicy;
import de.hsadmin.module.impl.AbstractModule;
@Stateless
@ -13,4 +18,12 @@ public class LdapUserService extends AbstractModule<LdapUserVO> implements LdapU
return new LdapUserVO();
}
@Override
@RequiredScope({ @ScopePolicy(Role.SYSTEM), @ScopePolicy(value=Role.CUSTOMER, property="customer") })
public LdapUserVO create(RequestContext requestContext, LdapUserVO prototype)
throws UserException, TechnicalException
{
return super.create(requestContext, prototype);
}
}

View File

@ -13,42 +13,48 @@ import de.hsadmin.module.property.StringSet;
public class LdapUserVO extends AbstractVO {
@Required(true)
@ReadWrite(ReadWritePolicy.WRITEONCE)
@Search(SearchPolicy.EQUALS)
@Pattern(regexp="[a-z0-9]{3}")
private String customer; // refers to customer
@Required(true)
@ReadWrite(ReadWritePolicy.WRITEONCE)
@Search(SearchPolicy.EQUALS)
@Pattern(regexp="[a-z0-9]{3}\\-[a-z0-9]+")
private String uid;
private String username; // ldap uid
@ReadWrite(ReadWritePolicy.READWRITE)
private String userPassword;
private String password; // ldap userPassword
@Required(true)
@ReadWrite(ReadWritePolicy.READWRITE)
@Search(SearchPolicy.EQUALS)
private String sn;
private String surname; // ldap sn
@ReadWrite(ReadWritePolicy.READWRITE)
@Search(SearchPolicy.EQUALS)
private String givenName;
private String givenname; // ldap givenName
@Required(true)
@ReadWrite(ReadWritePolicy.READWRITE)
@Search(SearchPolicy.EQUALS)
@Pattern(regexp="[a-zA-Z0-9\\.\\-\\_]*@[a-z0-9äöüß\\.\\-]*")
private String mail;
private String mail; // ldap mail
@ReadWrite(ReadWritePolicy.READWRITE)
@Pattern(regexp="[\\+\\d\\-\\ \\(\\)\\/]*")
private String mobile;
private String mobile; // ldap mobile
@ReadWrite(ReadWritePolicy.READWRITE)
@Pattern(regexp="[\\+\\d\\-\\ \\(\\)\\/]*")
private String homePhone;
private String phone; // ldap homePhone
@ReadWrite(ReadWritePolicy.READWRITE)
@Search(SearchPolicy.EQUALS)
@Pattern(regexp="[a-z0-9]*")
private String nickName;
private String nickname; // ldap nickName
@ReadWrite(ReadWritePolicy.READWRITE)
private StringSet sshPublicKey;
@ -57,36 +63,44 @@ public class LdapUserVO extends AbstractVO {
super();
}
public String getUid() {
return uid;
public String getCustomer() {
return customer;
}
public void setUid(String uid) {
this.uid = uid;
public void setCustomer(String customer) {
this.customer = customer;
}
public String getUserPassword() {
return userPassword;
public String getUsername() {
return username;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
public void setUsername(String uid) {
this.username = uid;
}
public String getSn() {
return sn;
public String getPassword() {
return password;
}
public void setSn(String sn) {
this.sn = sn;
public void setPassword(String userPassword) {
this.password = userPassword;
}
public String getGivenName() {
return givenName;
public String getSurname() {
return surname;
}
public void setGivenName(String givenName) {
this.givenName = givenName;
public void setSurname(String sn) {
this.surname = sn;
}
public String getGivenname() {
return givenname;
}
public void setGivenname(String givenName) {
this.givenname = givenName;
}
public String getMail() {
@ -105,20 +119,20 @@ public class LdapUserVO extends AbstractVO {
this.mobile = mobile;
}
public String getHomePhone() {
return homePhone;
public String getPhone() {
return phone;
}
public void setHomePhone(String homePhone) {
this.homePhone = homePhone;
public void setPhone(String homePhone) {
this.phone = homePhone;
}
public String getNickName() {
return nickName;
public String getNickname() {
return nickname;
}
public void setNickName(String nickName) {
this.nickName = nickName;
public void setNickname(String nickName) {
this.nickname = nickName;
}
public StringSet getSshPublicKey() {

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="hsar">
<jta-data-source>HsarDataSource</jta-data-source>
<class>de.hsadmin.bo.customer.Contact</class>
<class>de.hsadmin.bo.customer.Customer</class>
<class>de.hsadmin.bo.customer.MemberShare</class>
<class>de.hsadmin.bo.customer.MemberAsset</class>
<class>de.hsadmin.bo.customer.SEPADirectDebit</class>
<class>de.hsadmin.bo.domain.Domain</class>
<class>de.hsadmin.bo.domain.DomainOption</class>
<class>de.hsadmin.bo.domain.EMailAddress</class>
<class>de.hsadmin.bo.pac.BaseComponent</class>
<class>de.hsadmin.bo.pac.BasePac</class>
<class>de.hsadmin.bo.pac.Component</class>
<class>de.hsadmin.bo.pac.EMailAlias</class>
<class>de.hsadmin.bo.pac.Hive</class>
<class>de.hsadmin.bo.pac.INetAddress</class>
<class>de.hsadmin.bo.pac.Pac</class>
<class>de.hsadmin.bo.pac.PacComponent</class>
<class>de.hsadmin.bo.pac.UnixUser</class>
</persistence-unit>
</persistence>

View File

@ -0,0 +1,2 @@
ldapuser=de.hsadmin.service.ldap.LdapUserRemote
property=de.hsadmin.service.property.PropertyRemote

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>XmlRpcServlet</servlet-name>
<servlet-class>de.hsadmin.xmlrpc.HSXmlRpcServlet</servlet-class>
<init-param>
<param-name>enabledForExtensions</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc/*</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -14,23 +14,32 @@ import de.hsadmin.module.property.StringProperty;
public class ValidationTest {
private static final String CUSTOMER = "customer";
private static final String LDAP_SN = "surname";
private static final String LDAP_MAIL = "mail";
private static final String LDAP_UID = "username";
private LdapUserVO vo;
private ValidationDelegate<LdapUserVO> val;
@Before
public void setUp() throws Exception {
vo = new LdapUserVO();
final String custOk = "abc";
final String uidOk = "abc-someuid";
final String mailOk = "someone@example.org";
final String snOk = "Mustermann";
((StringProperty) vo.get("uid")).setValue(uidOk);
String uid = vo.getUid();
((StringProperty) vo.get(CUSTOMER)).setValue(custOk);
String cust = vo.getCustomer();
assertEquals(custOk, cust);
((StringProperty) vo.get(LDAP_UID)).setValue(uidOk);
String uid = vo.getUsername();
assertEquals(uidOk, uid);
((StringProperty) vo.get("mail")).setValue(mailOk);
((StringProperty) vo.get(LDAP_MAIL)).setValue(mailOk);
String mail = vo.getMail();
assertEquals(mailOk, mail);
((StringProperty) vo.get("sn")).setValue(snOk);
String sn = vo.getSn();
((StringProperty) vo.get(LDAP_SN)).setValue(snOk);
String sn = vo.getSurname();
assertEquals(snOk, sn);
val = new ValidationDelegate<LdapUserVO>();
}
@ -49,8 +58,8 @@ public class ValidationTest {
}
final String uidFail = "ac-someuid";
try {
((StringProperty) vo.get("uid")).setValue(uidFail);
String uid = vo.getUid();
((StringProperty) vo.get(LDAP_UID)).setValue(uidFail);
String uid = vo.getUsername();
assertEquals(uidFail, uid);
val.checkPrototypeIsCreateable(vo);
fail("expect UserException");
@ -68,7 +77,7 @@ public class ValidationTest {
public void testSetMail() {
final String mailFail = "someuid";
try {
((StringProperty) vo.get("mail")).setValue(mailFail);
((StringProperty) vo.get(LDAP_MAIL)).setValue(mailFail);
String mail = vo.getMail();
assertEquals(mailFail, mail);
val.checkPrototypeIsCreateable(vo);

View File

@ -0,0 +1,6 @@
ticketvalidator.class=de.hsadmin.login.cas.TestTicketValidator
cas.validate.url=https://login.hostsharing.net:443/cas/proxyValidate
cas.service.url=https://config.hostsharing.net:443/hsar/backend
accountprefix.hostmaster=hsh01
accountprefix.customer=hsh00
domainpostfix.pacdomain=hostsharing.net

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<Resource id="HsarDataSource" type="javax.sql.DataSource">
JtaManager = true
JdbcDriver = org.postgresql.Driver
JdbcUrl = jdbc:postgresql://localhost:5432/hsadmin_db
UserName = hsadmin_dbuser
Password = SelfDefinedPassword
</Resource>
</tomee>