WebUI mit lokalem Server starten
This commit is contained in:
parent
53ad73e825
commit
33ec937904
@ -11,9 +11,10 @@ import javax.script.ScriptEngine;
|
|||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
import de.hsadmin.jscli.cas.TicketProviderFactory;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.console.ConsoleWrapper;
|
import de.hsadmin.jscli.console.ConsoleWrapper;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
import de.hsadmin.jscli.exception.JSCliException;
|
||||||
|
import de.hsadmin.login.cas.TicketProviderFactory;
|
||||||
|
|
||||||
public class ScriptClient {
|
public class ScriptClient {
|
||||||
|
|
||||||
@ -22,51 +23,55 @@ public class ScriptClient {
|
|||||||
|
|
||||||
public ScriptClient(final ConsoleWrapper console, final String user, final String runAs, final String... arguments) throws JSCliException {
|
public ScriptClient(final ConsoleWrapper console, final String user, final String runAs, final String... arguments) throws JSCliException {
|
||||||
final RpcClient rpcClient = new RpcClient();
|
final RpcClient rpcClient = new RpcClient();
|
||||||
engine = new ScriptEngineManager().getEngineByName("js");
|
|
||||||
engine.put("casgrantingticket", TicketProviderFactory.getInstance(console, user, runAs));
|
|
||||||
engine.put("xmlrpcclient", rpcClient);
|
|
||||||
engine.put("xmlrpcLastResult", null);
|
|
||||||
completionStrings = new HashSet<String>();
|
|
||||||
completionStrings.add("set");
|
|
||||||
completionStrings.add("where");
|
|
||||||
considerArguments(arguments);
|
|
||||||
try {
|
try {
|
||||||
final InputStream inputResource = getClass().getClassLoader().getResourceAsStream("js/functions.js");
|
engine = new ScriptEngineManager().getEngineByName("js");
|
||||||
engine.eval(new InputStreamReader(inputResource));
|
engine.put("casgrantingticket", TicketProviderFactory.getInstance(console, user, runAs));
|
||||||
} catch (ScriptException e) {
|
engine.put("xmlrpcclient", rpcClient);
|
||||||
throw new JSCliException(e);
|
engine.put("xmlrpcLastResult", null);
|
||||||
}
|
completionStrings = new HashSet<String>();
|
||||||
final List<String> methods = rpcClient.listMethods();
|
completionStrings.add("set");
|
||||||
for (final String method : methods) {
|
completionStrings.add("where");
|
||||||
final String[] parts = method.split("\\.");
|
considerArguments(arguments);
|
||||||
if (parts.length == 2) {
|
try {
|
||||||
final String module = parts[0];
|
final InputStream inputResource = getClass().getClassLoader().getResourceAsStream("js/functions.js");
|
||||||
final String function = parts[1];
|
engine.eval(new InputStreamReader(inputResource));
|
||||||
if ("system".equals(module) || "getModuleLookup".equals(function) || "createValueObject".equals(function)) {
|
} catch (ScriptException e) {
|
||||||
continue;
|
throw new JSCliException(e);
|
||||||
}
|
}
|
||||||
completionStrings.add(module);
|
final List<String> methods = rpcClient.listMethods();
|
||||||
final String jsFunctionIdent;
|
for (final String method : methods) {
|
||||||
if ("delete".equals(function)) {
|
final String[] parts = method.split("\\.");
|
||||||
jsFunctionIdent = module + "['remove']";
|
if (parts.length == 2) {
|
||||||
completionStrings.add(module + ".remove");
|
final String module = parts[0];
|
||||||
} else {
|
final String function = parts[1];
|
||||||
jsFunctionIdent = module + "['" + function + "']";
|
if ("system".equals(module) || "getModuleLookup".equals(function) || "createValueObject".equals(function)) {
|
||||||
completionStrings.add(module + "." + function);
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
completionStrings.add(module);
|
||||||
engine.eval(
|
final String jsFunctionIdent;
|
||||||
"if (typeof " + module + " === 'undefined')" +
|
if ("delete".equals(function)) {
|
||||||
" { var " + module + " = { }; };\n" +
|
jsFunctionIdent = module + "['remove']";
|
||||||
jsFunctionIdent +
|
completionStrings.add(module + ".remove");
|
||||||
" = function(json) { return hsaModuleCall('" + module + "', '" + function + "', json); }"
|
} else {
|
||||||
);
|
jsFunctionIdent = module + "['" + function + "']";
|
||||||
} catch (ScriptException e) {
|
completionStrings.add(module + "." + function);
|
||||||
e.printStackTrace();
|
}
|
||||||
|
try {
|
||||||
|
engine.eval(
|
||||||
|
"if (typeof " + module + " === 'undefined')" +
|
||||||
|
" { var " + module + " = { }; };\n" +
|
||||||
|
jsFunctionIdent +
|
||||||
|
" = function(json) { return hsaModuleCall('" + module + "', '" + function + "', json); }"
|
||||||
|
);
|
||||||
|
} catch (ScriptException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.codeCompletion(getCodeCompletionStrings());
|
||||||
|
} catch (TechnicalException e) {
|
||||||
|
throw new JSCliException(e);
|
||||||
}
|
}
|
||||||
console.codeCompletion(getCodeCompletionStrings());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getCodeCompletionStrings() {
|
public String[] getCodeCompletionStrings() {
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package de.hsadmin.jscli;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
|
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public interface TicketProvider {
|
|
||||||
|
|
||||||
public String getTicket() throws JSCliException, FileNotFoundException;
|
|
||||||
|
|
||||||
public String getRunAs();
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package de.hsadmin.jscli.cas;
|
|
||||||
|
|
||||||
import de.hsadmin.common.config.Config;
|
|
||||||
import de.hsadmin.common.error.TechnicalException;
|
|
||||||
import de.hsadmin.jscli.TicketProvider;
|
|
||||||
import de.hsadmin.jscli.console.PasswordReader;
|
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public class TicketProviderFactory {
|
|
||||||
|
|
||||||
private static final String HOSTSHARING_LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
|
||||||
private static final String HOSTSHARING_BACKEND_URL = "https://config.hostsharing.net:443/hsar/backend";
|
|
||||||
|
|
||||||
public static TicketProvider getInstance(final PasswordReader console, final String user, final String runAs) throws JSCliException
|
|
||||||
{
|
|
||||||
Config config;
|
|
||||||
try {
|
|
||||||
config = Config.getInstance();
|
|
||||||
final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
|
|
||||||
final String loginURL = config.getProperty("loginURL", HOSTSHARING_LOGIN_URL);
|
|
||||||
if ("TestUmgebung".equalsIgnoreCase(loginURL)) {
|
|
||||||
return new TestTicketProvider(user, runAs);
|
|
||||||
} else {
|
|
||||||
return new CASTicketProvider(console, user, runAs, backendURL, loginURL);
|
|
||||||
}
|
|
||||||
} catch (TechnicalException e) {
|
|
||||||
throw new JSCliException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -3,7 +3,9 @@ package de.hsadmin.jscli.console;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
import de.hsadmin.jscli.exception.JSCliException;
|
||||||
|
import de.hsadmin.login.cas.PasswordReader;
|
||||||
import jline.console.ConsoleReader;
|
import jline.console.ConsoleReader;
|
||||||
import jline.console.completer.StringsCompleter;
|
import jline.console.completer.StringsCompleter;
|
||||||
import jline.console.history.FileHistory;
|
import jline.console.history.FileHistory;
|
||||||
@ -38,25 +40,25 @@ public class ConsoleWrapper implements PasswordReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(final String text) throws JSCliException {
|
public void println(final String text) throws TechnicalException {
|
||||||
try {
|
try {
|
||||||
if (cons != null) {
|
if (cons != null) {
|
||||||
cons.println(text);
|
cons.println(text);
|
||||||
} else {
|
} else {
|
||||||
throw new JSCliException("cannot write console");
|
throw new TechnicalException("cannot write console");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readPassword() throws JSCliException {
|
public String readPassword() throws TechnicalException {
|
||||||
try {
|
try {
|
||||||
final String pw = cons.readLine("Password: ", new Character('*'));
|
final String pw = cons.readLine("Password: ", new Character('*'));
|
||||||
cons.setPrompt(prompt);
|
cons.setPrompt(prompt);
|
||||||
return pw;
|
return pw;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package de.hsadmin.jscli.console;
|
|
||||||
|
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public interface PasswordReader {
|
|
||||||
|
|
||||||
public String readPassword() throws JSCliException;
|
|
||||||
|
|
||||||
public void println(final String text) throws JSCliException;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import de.hsadmin.xmlrpc.AbstractRemote;
|
||||||
|
import de.hsadmin.xmlrpc.Remote;
|
||||||
|
|
||||||
|
public class RoleRemote extends AbstractRemote<RoleVO> implements Remote {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getModuleLookup() {
|
||||||
|
return "RoleServiceLocal";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import de.hsadmin.module.property.StringProperty;
|
||||||
|
|
||||||
|
@Stateless
|
||||||
|
public class RoleService extends AbstractModule<RoleVO> implements RoleServiceLocal {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RoleVO buildVO() throws TechnicalException {
|
||||||
|
return new RoleVO();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@RequiredScope({ @ScopePolicy(Role.NONE) })
|
||||||
|
public RoleVO create(RequestContext requestContext, RoleVO prototype) throws UserException, TechnicalException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@RequiredScope({ @ScopePolicy(Role.ANY) })
|
||||||
|
public List<RoleVO> read(RequestContext requestContext, RoleVO criteria) throws UserException, TechnicalException {
|
||||||
|
final Role loginRole = requestContext.getLoginRole();
|
||||||
|
final ArrayList<RoleVO> userRoles = new ArrayList<RoleVO>();
|
||||||
|
final RoleVO roleVO = buildVO();
|
||||||
|
roleVO.setRole(loginRole.name());
|
||||||
|
((StringProperty) roleVO.get("role")).setValue(loginRole.name());
|
||||||
|
userRoles.add(roleVO);
|
||||||
|
return userRoles;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@RequiredScope({ @ScopePolicy(Role.NONE) })
|
||||||
|
public List<RoleVO> update(RequestContext requestContext, RoleVO criteria, RoleVO prototype)
|
||||||
|
throws UserException, TechnicalException {
|
||||||
|
return new ArrayList<RoleVO>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@RequiredScope({ @ScopePolicy(Role.NONE) })
|
||||||
|
public void delete(RequestContext requestContext, RoleVO criteria) throws UserException, TechnicalException {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import javax.ejb.Local;
|
||||||
|
|
||||||
|
import de.hsadmin.module.Module;
|
||||||
|
|
||||||
|
@Local
|
||||||
|
public interface RoleServiceLocal extends Module<RoleVO> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.module.ValueObject;
|
||||||
|
import de.hsadmin.module.impl.AbstractVO;
|
||||||
|
import de.hsadmin.module.property.ReadWrite;
|
||||||
|
import de.hsadmin.module.property.ReadWritePolicy;
|
||||||
|
import de.hsadmin.module.property.Required;
|
||||||
|
|
||||||
|
public class RoleVO extends AbstractVO implements ValueObject {
|
||||||
|
|
||||||
|
@ReadWrite(ReadWritePolicy.READ)
|
||||||
|
@Required(true)
|
||||||
|
@Size(min=1,max=24)
|
||||||
|
private String role;
|
||||||
|
|
||||||
|
public RoleVO() throws TechnicalException {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(String role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
role=de.hsadmin.service.customer.RoleRemote
|
||||||
customer=de.hsadmin.service.customer.CustomerRemote
|
customer=de.hsadmin.service.customer.CustomerRemote
|
||||||
contact=de.hsadmin.service.customer.ContactRemote
|
contact=de.hsadmin.service.customer.ContactRemote
|
||||||
mandat=de.hsadmin.service.customer.SEPADirectDebitRemote
|
mandat=de.hsadmin.service.customer.SEPADirectDebitRemote
|
||||||
|
@ -8,6 +8,7 @@ import de.hsadmin.common.config.Config;
|
|||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserError;
|
import de.hsadmin.common.error.UserError;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.login.cas.TicketValidatorFactory;
|
||||||
|
|
||||||
@Stateless
|
@Stateless
|
||||||
public class LoginService implements LoginServiceLocal {
|
public class LoginService implements LoginServiceLocal {
|
||||||
@ -15,8 +16,6 @@ public class LoginService implements LoginServiceLocal {
|
|||||||
@PersistenceContext(name = "hsar")
|
@PersistenceContext(name = "hsar")
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
private TicketValidator ticketValidator;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestContext createContext(final String ticket, final String runAsUser) throws UserException, TechnicalException {
|
public RequestContext createContext(final String ticket, final String runAsUser) throws UserException, TechnicalException {
|
||||||
if (ticket != null && !ticket.isEmpty()) {
|
if (ticket != null && !ticket.isEmpty()) {
|
||||||
@ -74,21 +73,8 @@ public class LoginService implements LoginServiceLocal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String validateTicket(final String ticket) throws TechnicalException, UserException {
|
private String validateTicket(final String ticket) throws TechnicalException, UserException {
|
||||||
final TicketValidator ticketValidator = getTicketValidator();
|
final TicketValidator ticketValidator = TicketValidatorFactory.getTicketValidator();
|
||||||
return ticketValidator.validate(ticket);
|
return ticketValidator.validate(ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TicketValidator getTicketValidator() throws TechnicalException {
|
|
||||||
if (ticketValidator == null) {
|
|
||||||
try {
|
|
||||||
final String property = Config.getInstance().getProperty(Config.TICKETVALIDATOR_CLASS);
|
|
||||||
final Class<?> validatorClass = Class.forName(property);
|
|
||||||
ticketValidator = (TicketValidator) validatorClass.newInstance();
|
|
||||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
|
||||||
throw new TechnicalException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ticketValidator;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
11
framework/src/main/java/de/hsadmin/login/TicketProvider.java
Normal file
11
framework/src/main/java/de/hsadmin/login/TicketProvider.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package de.hsadmin.login;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
|
||||||
|
public interface TicketProvider {
|
||||||
|
|
||||||
|
public String getTicket() throws TechnicalException;
|
||||||
|
|
||||||
|
public String getRunAs();
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package de.hsadmin.jscli.cas;
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -20,9 +19,7 @@ import javax.net.ssl.HttpsURLConnection;
|
|||||||
|
|
||||||
import de.hsadmin.common.config.Config;
|
import de.hsadmin.common.config.Config;
|
||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.TicketProvider;
|
import de.hsadmin.login.TicketProvider;
|
||||||
import de.hsadmin.jscli.console.PasswordReader;
|
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public class CASTicketProvider implements TicketProvider {
|
public class CASTicketProvider implements TicketProvider {
|
||||||
|
|
||||||
@ -34,7 +31,7 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
|
|
||||||
private String grantingTicket;
|
private String grantingTicket;
|
||||||
|
|
||||||
public CASTicketProvider(final PasswordReader console, final String user, final String runAs, final String backendURL, final String loginURL) throws JSCliException {
|
public CASTicketProvider(final PasswordReader console, final String user, final String runAs, final String backendURL, final String loginURL) throws TechnicalException {
|
||||||
this.passwordReader = console;
|
this.passwordReader = console;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.runAs = runAs;
|
this.runAs = runAs;
|
||||||
@ -44,7 +41,7 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTicket() throws JSCliException {
|
public String getTicket() throws TechnicalException {
|
||||||
try {
|
try {
|
||||||
final String encodedParams =
|
final String encodedParams =
|
||||||
URLEncoder.encode("service", "UTF-8") + "=" + URLEncoder.encode(backendURL, "UTF-8");
|
URLEncoder.encode("service", "UTF-8") + "=" + URLEncoder.encode(backendURL, "UTF-8");
|
||||||
@ -64,14 +61,14 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
}
|
}
|
||||||
trails++;
|
trails++;
|
||||||
if (trails > 3) {
|
if (trails > 3) {
|
||||||
throw new JSCliException("exceeded number of login attempts");
|
throw new TechnicalException("exceeded number of login attempts");
|
||||||
}
|
}
|
||||||
urlString = getGrantingTicket();
|
urlString = getGrantingTicket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +77,7 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
return runAs;
|
return runAs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGrantingTicket() throws JSCliException {
|
private String getGrantingTicket() throws TechnicalException {
|
||||||
grantingTicket = null;
|
grantingTicket = null;
|
||||||
try {
|
try {
|
||||||
String password = Config.getInstance().getProperty(user + ".passWord");
|
String password = Config.getInstance().getProperty(user + ".passWord");
|
||||||
@ -93,25 +90,21 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
+ "=" + URLEncoder.encode(password, "UTF-8");
|
+ "=" + URLEncoder.encode(password, "UTF-8");
|
||||||
grantingTicket = requestForGrantingTicket(loginURL, encodedParams);
|
grantingTicket = requestForGrantingTicket(loginURL, encodedParams);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new JSCliException("cas server not available: " + loginURL);
|
|
||||||
} catch (TechnicalException e) {
|
|
||||||
throw new JSCliException(e);
|
|
||||||
}
|
}
|
||||||
return grantingTicket;
|
return grantingTicket;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readPasswordFromConsole() throws JSCliException {
|
private String readPasswordFromConsole() throws TechnicalException {
|
||||||
return passwordReader.readPassword();
|
return passwordReader.readPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String requestForGrantingTicket(final String urlString, final String encodedParams) throws JSCliException, FileNotFoundException {
|
private String requestForGrantingTicket(final String urlString, final String encodedParams) throws TechnicalException {
|
||||||
try {
|
try {
|
||||||
final HttpsURLConnection connection = doConnect(urlString, encodedParams);
|
final HttpsURLConnection connection = doConnect(urlString, encodedParams);
|
||||||
return connection.getHeaderField("Location");
|
return connection.getHeaderField("Location");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +141,7 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readFiledGrantingTicket() throws JSCliException {
|
private void readFiledGrantingTicket() throws TechnicalException {
|
||||||
final File file = getTicketFile();
|
final File file = getTicketFile();
|
||||||
final Properties properties = loadProperties(file);
|
final Properties properties = loadProperties(file);
|
||||||
final String filedTicket = properties.getProperty(user);
|
final String filedTicket = properties.getProperty(user);
|
||||||
@ -162,25 +155,25 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
return new File(ticketFileName);
|
return new File(ticketFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveProperties(final String filedTicket, final File file) throws JSCliException {
|
private void saveProperties(final String filedTicket, final File file) throws TechnicalException {
|
||||||
final Properties properties = loadProperties(file);
|
final Properties properties = loadProperties(file);
|
||||||
if (filedTicket != null) {
|
if (filedTicket != null) {
|
||||||
properties.setProperty(user, filedTicket);
|
properties.setProperty(user, filedTicket);
|
||||||
try {
|
try {
|
||||||
properties.store(new FileOutputStream(file), "stored cas tickets");
|
properties.store(new FileOutputStream(file), "stored cas tickets");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Properties loadProperties(final File file) throws JSCliException {
|
private Properties loadProperties(final File file) throws TechnicalException {
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
if (file.isFile() && file.canRead()) {
|
if (file.isFile() && file.canRead()) {
|
||||||
try {
|
try {
|
||||||
properties.load(new FileReader(file));
|
properties.load(new FileReader(file));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
@ -1,4 +1,4 @@
|
|||||||
package de.hsadmin.login;
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -11,6 +11,7 @@ import de.hsadmin.common.config.Config;
|
|||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserError;
|
import de.hsadmin.common.error.UserError;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.login.TicketValidator;
|
||||||
|
|
||||||
public class CASTicketValidator implements TicketValidator {
|
public class CASTicketValidator implements TicketValidator {
|
||||||
|
|
||||||
@ -29,15 +30,16 @@ public class CASTicketValidator implements TicketValidator {
|
|||||||
throw new TechnicalException("TicketValidator is not initialized.");
|
throw new TechnicalException("TicketValidator is not initialized.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
URL url = new URL(proxyValidateURL + "?service=" + proxyServiceURL + "&ticket=" + ticket);
|
final URL url = new URL(proxyValidateURL + "?service=" + proxyServiceURL + "&ticket=" + ticket);
|
||||||
URLConnection httpConnection = url.openConnection();
|
final URLConnection httpConnection = url.openConnection();
|
||||||
httpConnection.connect();
|
httpConnection.connect();
|
||||||
InputStream inputStream = httpConnection.getInputStream();
|
final InputStream inputStream = httpConnection.getInputStream();
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
String nextLine = reader.readLine();
|
String nextLine = reader.readLine();
|
||||||
while (nextLine != null) {
|
while (nextLine != null) {
|
||||||
if (nextLine.contains("<cas:user>")) {
|
if (nextLine.contains("<cas:user>")) {
|
||||||
String user = extractUser(nextLine);
|
String user = extractUser(nextLine);
|
||||||
|
reader.close();
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
|
||||||
|
public interface PasswordReader {
|
||||||
|
|
||||||
|
public String readPassword() throws TechnicalException;
|
||||||
|
|
||||||
|
public void println(final String text) throws TechnicalException;
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,7 @@
|
|||||||
package de.hsadmin.jscli.cas;
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.login.TicketProvider;
|
||||||
import de.hsadmin.jscli.TicketProvider;
|
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public class TestTicketProvider implements TicketProvider {
|
public class TestTicketProvider implements TicketProvider {
|
||||||
|
|
||||||
@ -16,7 +14,7 @@ public class TestTicketProvider implements TicketProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTicket() throws JSCliException, FileNotFoundException {
|
public String getTicket() throws TechnicalException {
|
||||||
return grantingTicket;
|
return grantingTicket;
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,6 @@
|
|||||||
package de.hsadmin.login;
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
|
import de.hsadmin.login.TicketValidator;
|
||||||
|
|
||||||
public class TestTicketValidator implements TicketValidator {
|
public class TestTicketValidator implements TicketValidator {
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
|
import de.hsadmin.common.config.Config;
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.login.TicketProvider;
|
||||||
|
|
||||||
|
public class TicketProviderFactory {
|
||||||
|
|
||||||
|
private static final String HOSTSHARING_LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
||||||
|
private static final String HOSTSHARING_BACKEND_URL = "https://config.hostsharing.net:443/hsar/backend";
|
||||||
|
|
||||||
|
public static TicketProvider getInstance(final PasswordReader console, final String user, final String runAs) throws TechnicalException
|
||||||
|
{
|
||||||
|
final Config config = Config.getInstance();
|
||||||
|
final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
|
||||||
|
final String loginURL = config.getProperty("loginURL", HOSTSHARING_LOGIN_URL);
|
||||||
|
if ("TestUmgebung".equalsIgnoreCase(loginURL)) {
|
||||||
|
return new TestTicketProvider(user, runAs);
|
||||||
|
} else {
|
||||||
|
return new CASTicketProvider(console, user, runAs, backendURL, loginURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
|
import de.hsadmin.common.config.Config;
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.login.TicketValidator;
|
||||||
|
|
||||||
|
public class TicketValidatorFactory {
|
||||||
|
|
||||||
|
public static TicketValidator getTicketValidator() throws TechnicalException {
|
||||||
|
TicketValidator ticketValidator = null;
|
||||||
|
if (ticketValidator == null) {
|
||||||
|
try {
|
||||||
|
final String property = Config.getInstance().getProperty(Config.TICKETVALIDATOR_CLASS);
|
||||||
|
final Class<?> validatorClass = Class.forName(property);
|
||||||
|
ticketValidator = (TicketValidator) validatorClass.newInstance();
|
||||||
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
|
throw new TechnicalException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ticketValidator;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
5
web/hsadmin.properties
Normal file
5
web/hsadmin.properties
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
backendURL=https://config.hostsharing.net:443/hsar/backend
|
||||||
|
;xmlrpcURL=https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin
|
||||||
|
;loginURL=https://login.hostsharing.net:443/cas/v1/tickets
|
||||||
|
xmlrpcURL=http://localhost:8080/cust-webapp/xmlrpc/hsadmin
|
||||||
|
loginURL=TestUmgebung
|
@ -25,6 +25,12 @@
|
|||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>framework</artifactId>
|
<artifactId>framework</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.xmlrpc</groupId>
|
||||||
|
<artifactId>xmlrpc-server</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -96,6 +102,7 @@
|
|||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<path>/</path>
|
<path>/</path>
|
||||||
|
<port>8081</port>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
90
web/src/main/java/de/hsadmin/model/CASTicketService.java
Normal file
90
web/src/main/java/de/hsadmin/model/CASTicketService.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
package de.hsadmin.model;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
import de.hsadmin.common.config.Config;
|
||||||
|
import de.hsadmin.rpc.RpcException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for service tickets.
|
||||||
|
* Hostsharing uses the CAS authentication service to authenticate
|
||||||
|
* users of hostsharing services. This class is used to create a
|
||||||
|
* "ticket granting ticket" for a session and service ticket for
|
||||||
|
* individual service calls.
|
||||||
|
*/
|
||||||
|
class CASTicketService implements Serializable, TicketService {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGrantingTicket(final String user, final String password) throws RpcException {
|
||||||
|
String ticket = null;
|
||||||
|
try {
|
||||||
|
final Config conf = Config.getInstance();
|
||||||
|
final String userParam = "username=" + URLEncoder.encode(user, "UTF-8");
|
||||||
|
final String passwordParam = "password=" + URLEncoder.encode(password, "UTF-8");
|
||||||
|
final String encodedData = userParam + "&" + passwordParam;
|
||||||
|
final String casUrl = conf.getProperty("loginURL");
|
||||||
|
final URL url = new URL(casUrl);
|
||||||
|
|
||||||
|
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setAllowUserInteraction(false);
|
||||||
|
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
|
||||||
|
writer.write(encodedData);
|
||||||
|
writer.close();
|
||||||
|
connection.connect();
|
||||||
|
ticket = connection.getHeaderField("Location");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RpcException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServiceTicket(String grantingTicket) throws RpcException {
|
||||||
|
String ticket = null;
|
||||||
|
try {
|
||||||
|
final Config conf = Config.getInstance();
|
||||||
|
final String backendURL = conf.getProperty("backendURL");
|
||||||
|
final String serviceParam = "service=" + URLEncoder.encode(backendURL, "UTF-8");
|
||||||
|
final URL url = new URL(grantingTicket);
|
||||||
|
|
||||||
|
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setAllowUserInteraction(false);
|
||||||
|
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
|
||||||
|
writer.write(serviceParam);
|
||||||
|
writer.close();
|
||||||
|
connection.connect();
|
||||||
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
ticket = reader.readLine();
|
||||||
|
String readLine = reader.readLine();
|
||||||
|
do {
|
||||||
|
readLine = reader.readLine();
|
||||||
|
} while (readLine != null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RpcException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
web/src/main/java/de/hsadmin/model/TestTicketService.java
Normal file
21
web/src/main/java/de/hsadmin/model/TestTicketService.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package de.hsadmin.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import de.hsadmin.rpc.RpcException;
|
||||||
|
|
||||||
|
public class TestTicketService implements TicketService, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGrantingTicket(final String user, final String password) throws RpcException {
|
||||||
|
return "granting:" + user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServiceTicket(final String grantingTicket) throws RpcException {
|
||||||
|
return "user" + grantingTicket.substring(grantingTicket.indexOf(':'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,88 +1,11 @@
|
|||||||
package de.hsadmin.model;
|
package de.hsadmin.model;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
|
|
||||||
import de.hsadmin.common.config.Config;
|
|
||||||
import de.hsadmin.rpc.RpcException;
|
import de.hsadmin.rpc.RpcException;
|
||||||
|
|
||||||
/**
|
public interface TicketService {
|
||||||
* Helper for service tickets.
|
|
||||||
* Hostsharing uses the CAS authentication service to authenticate
|
|
||||||
* users of hostsharing services. This class is used to create a
|
|
||||||
* "ticket granting ticket" for a session and service ticket for
|
|
||||||
* individual service calls.
|
|
||||||
*/
|
|
||||||
public class TicketService implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
String getGrantingTicket(String user, String password) throws RpcException;
|
||||||
|
|
||||||
public String getGrantingTicket(final String user, final String password) throws RpcException {
|
String getServiceTicket(String grantingTicket) throws RpcException;
|
||||||
String ticket = null;
|
|
||||||
try {
|
|
||||||
final Config conf = Config.getInstance();
|
|
||||||
final String userParam = "username=" + URLEncoder.encode(user, "UTF-8");
|
|
||||||
final String passwordParam = "password=" + URLEncoder.encode(password, "UTF-8");
|
|
||||||
final String encodedData = userParam + "&" + passwordParam;
|
|
||||||
final String casUrl = conf.getProperty("loginURL");
|
|
||||||
final URL url = new URL(casUrl);
|
|
||||||
|
|
||||||
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
}
|
||||||
connection.setRequestMethod("POST");
|
|
||||||
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
||||||
connection.setDoInput(true);
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
connection.setUseCaches(false);
|
|
||||||
connection.setAllowUserInteraction(false);
|
|
||||||
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
|
|
||||||
writer.write(encodedData);
|
|
||||||
writer.close();
|
|
||||||
connection.connect();
|
|
||||||
ticket = connection.getHeaderField("Location");
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RpcException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServiceTicket(String grantingTicket) throws RpcException {
|
|
||||||
String ticket = null;
|
|
||||||
try {
|
|
||||||
final Config conf = Config.getInstance();
|
|
||||||
final String backendURL = conf.getProperty("backendURL");
|
|
||||||
final String serviceParam = "service=" + URLEncoder.encode(backendURL, "UTF-8");
|
|
||||||
final URL url = new URL(grantingTicket);
|
|
||||||
|
|
||||||
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
|
||||||
connection.setRequestMethod("POST");
|
|
||||||
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
||||||
connection.setDoInput(true);
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
connection.setUseCaches(false);
|
|
||||||
connection.setAllowUserInteraction(false);
|
|
||||||
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
|
|
||||||
writer.write(serviceParam);
|
|
||||||
writer.close();
|
|
||||||
connection.connect();
|
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
||||||
ticket = reader.readLine();
|
|
||||||
String readLine = reader.readLine();
|
|
||||||
do {
|
|
||||||
readLine = reader.readLine();
|
|
||||||
} while (readLine != null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RpcException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
16
web/src/main/java/de/hsadmin/model/TicketServiceFactory.java
Normal file
16
web/src/main/java/de/hsadmin/model/TicketServiceFactory.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package de.hsadmin.model;
|
||||||
|
|
||||||
|
import de.hsadmin.common.config.Config;
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
|
||||||
|
public class TicketServiceFactory {
|
||||||
|
|
||||||
|
public static TicketService getTicketService() throws TechnicalException {
|
||||||
|
final String loginURL = Config.getInstance().getProperty("loginURL");
|
||||||
|
if ("TestUmgebung".equals(loginURL)) {
|
||||||
|
return new TestTicketService();
|
||||||
|
}
|
||||||
|
return new CASTicketService();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,9 @@ import org.apache.xmlrpc.XmlRpcException;
|
|||||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||||
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.model.TicketService;
|
import de.hsadmin.model.TicketService;
|
||||||
|
import de.hsadmin.model.TicketServiceFactory;
|
||||||
|
|
||||||
public class ModulesManagerFactory {
|
public class ModulesManagerFactory {
|
||||||
|
|
||||||
@ -26,8 +28,8 @@ public class ModulesManagerFactory {
|
|||||||
|
|
||||||
public ModulesManager newModulesManager(final String... serverURLs) throws RpcException {
|
public ModulesManager newModulesManager(final String... serverURLs) throws RpcException {
|
||||||
final ModulesManager moduleManager = new ModulesManager();
|
final ModulesManager moduleManager = new ModulesManager();
|
||||||
final TicketService ticketService = new TicketService();
|
|
||||||
try {
|
try {
|
||||||
|
final TicketService ticketService = TicketServiceFactory.getTicketService();;
|
||||||
for (final String servername : serverURLs)
|
for (final String servername : serverURLs)
|
||||||
{
|
{
|
||||||
final XmlRpcClient rpcClient = new XmlRpcClient();
|
final XmlRpcClient rpcClient = new XmlRpcClient();
|
||||||
@ -63,7 +65,7 @@ public class ModulesManagerFactory {
|
|||||||
moduleManager.module(moduleName).add(propInfo);
|
moduleManager.module(moduleName).add(propInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException | XmlRpcException e) {
|
} catch (MalformedURLException | XmlRpcException | TechnicalException e) {
|
||||||
throw new RpcException(e);
|
throw new RpcException(e);
|
||||||
}
|
}
|
||||||
return moduleManager;
|
return moduleManager;
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
package de.hsadmin.web;
|
package de.hsadmin.web;
|
||||||
|
|
||||||
|
import de.hsadmin.login.Role;
|
||||||
|
|
||||||
public class EntryPointsFactory extends AbstractEntryPointsFactory {
|
public class EntryPointsFactory extends AbstractEntryPointsFactory {
|
||||||
|
|
||||||
|
// FIXME: Domain-Modul zum Testen auskommentiert (ph)
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getEntryPointNames(final String role) {
|
public String[] getEntryPointNames(final String role) {
|
||||||
if ("HOSTMASTER".equals(role)) {
|
|
||||||
return new String[] { "customer", "pac", "domain" };
|
if (Role.SYSTEM.name().equals(role)) {
|
||||||
|
return new String[] { "customer", "pac" };
|
||||||
|
// return new String[] { "customer", "pac", "domain" };
|
||||||
}
|
}
|
||||||
if ("CUSTOMER".equals(role)) {
|
if (Role.CUSTOMER.name().equals(role)) {
|
||||||
return new String[] { "customer", "pac", "domain" };
|
return new String[] { "customer", "pac" };
|
||||||
|
// return new String[] { "customer", "pac", "domain" };
|
||||||
}
|
}
|
||||||
if ("PAC_ADMIN_DW".equals(role)) {
|
if (Role.PACKET.name().equals(role)) {
|
||||||
return new String[] { "pac", "domain" };
|
return new String[] { "pac" };
|
||||||
|
// return new String[] { "pac", "domain" };
|
||||||
}
|
}
|
||||||
if ("DOM_ADMIN".equals(role)) {
|
if (Role.DOMAIN.name().equals(role)) {
|
||||||
return new String[] { "domain" };
|
// return new String[] { "domain" };
|
||||||
}
|
}
|
||||||
return new String[] { };
|
return new String[] { };
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,9 @@ import com.vaadin.ui.UI;
|
|||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.model.TicketService;
|
import de.hsadmin.model.TicketService;
|
||||||
|
import de.hsadmin.model.TicketServiceFactory;
|
||||||
|
|
||||||
@Title("HSAdmin Web")
|
@Title("HSAdmin Web")
|
||||||
@Theme(ValoTheme.THEME_NAME)
|
@Theme(ValoTheme.THEME_NAME)
|
||||||
@ -23,7 +25,7 @@ public class HSAdminUI extends UI {
|
|||||||
@VaadinServletConfiguration(productionMode = false, ui = HSAdminUI.class)
|
@VaadinServletConfiguration(productionMode = false, ui = HSAdminUI.class)
|
||||||
public static class Servlet extends VaadinServlet {
|
public static class Servlet extends VaadinServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,10 +37,12 @@ public class HSAdminUI extends UI {
|
|||||||
setSizeFull();
|
setSizeFull();
|
||||||
layout = new VerticalLayout();
|
layout = new VerticalLayout();
|
||||||
layout.setSizeFull();
|
layout.setSizeFull();
|
||||||
|
try {
|
||||||
ticketService = new TicketService();
|
ticketService = TicketServiceFactory.getTicketService();
|
||||||
UI.getCurrent().addWindow(new LoginWindow(this, ticketService));
|
UI.getCurrent().addWindow(new LoginWindow(this, ticketService));
|
||||||
|
} catch (TechnicalException e) {
|
||||||
|
// dont care
|
||||||
|
}
|
||||||
setContent(layout);
|
setContent(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user