http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDestroyException.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDestroyException.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDestroyException.java deleted file mode 100644 index 42de7d1..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDestroyException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - */ -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import javax.xml.ws.WebFault; - - -/** - * Exception that is thrown to indicate that the user is not permitted to - * destroy something. - * - * @author Donal Fellows - */ -@WebFault(name = "NoDestroyFault") -public class NoDestroyException extends NoUpdateException { - private static final long serialVersionUID = 6207448533265237933L; - - public NoDestroyException() { - super("not permitted to destroy"); - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDirectoryEntryException.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDirectoryEntryException.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDirectoryEntryException.java deleted file mode 100644 index 32300d1..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoDirectoryEntryException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - */ -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import javax.xml.ws.WebFault; - -/** - * Indicates that the file or directory name was not recognized. - * - * @author Donal Fellows - */ -@WebFault(name = "NoDirectoryEntryFault") -@SuppressWarnings("serial") -public class NoDirectoryEntryException extends Exception { - public NoDirectoryEntryException(String msg) { - super(msg); - } - public NoDirectoryEntryException(String msg,Exception cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoListenerException.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoListenerException.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoListenerException.java deleted file mode 100644 index ef84e9e..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoListenerException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - */ -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.WebFault; - -/** - * Exception thrown to indicate that no listener by that name exists, or that - * some other problem with listeners has occurred. - * - * @author Donal Fellows - */ -@WebFault(name = "NoListenerFault") -@XmlSeeAlso(BadPropertyValueException.class) -public class NoListenerException extends Exception { - private static final long serialVersionUID = -2550897312787546547L; - - public NoListenerException() { - super("no such listener"); - } - - public NoListenerException(String msg) { - super(msg); - } - - public NoListenerException(String msg, Throwable t) { - super(msg, t); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoUpdateException.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoUpdateException.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoUpdateException.java deleted file mode 100644 index 5e972dd..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NoUpdateException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - */ -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.WebFault; - -/** - * Exception that is thrown to indicate that the user is not permitted to update - * something. - * - * @author Donal Fellows - */ -@WebFault(name = "NoUpdateFault") -@XmlSeeAlso( { NoCreateException.class, NoDestroyException.class, BadStateChangeException.class }) -public class NoUpdateException extends Exception { - private static final long serialVersionUID = 4230987102653846379L; - - public NoUpdateException() { - super("not permitted to update"); - } - - public NoUpdateException(String msg) { - super(msg); - } - - public NoUpdateException(String string, Throwable e) { - super(string, e); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NotOwnerException.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NotOwnerException.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NotOwnerException.java deleted file mode 100644 index 29e00b7..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/NotOwnerException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - */ -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import javax.xml.ws.WebFault; - -/** - * An exception thrown when an operation is attempted which only the owner is - * permitted to do. Notably, permissions may <i>only</i> be manipulated by the - * owner. - * - * @author Donal Fellows - */ -@WebFault(name = "NotOwnerFault") -@SuppressWarnings("serial") -public class NotOwnerException extends Exception { - public NotOwnerException() { - super("not permitted; not the owner"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/OverloadedException.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/OverloadedException.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/OverloadedException.java deleted file mode 100644 index bd34659..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/OverloadedException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - */ -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import javax.xml.ws.WebFault; - -/** - * Exception that is thrown to indicate that the state change requested for a - * run is currently impossible due to excessive server load. - * - * @author Donal Fellows - */ -@WebFault(name = "OverloadedFault") -public class OverloadedException extends BadStateChangeException { - private static final long serialVersionUID = 490826388447601776L; - - public OverloadedException() { - super("server too busy; try later please"); - } - - public OverloadedException(Throwable t) { - super("server too busy; try later please", t); - } - - public OverloadedException(String msg, Throwable t) { - super(msg, t); - } - - public OverloadedException(String message) { - super(message); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/UnknownRunException.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/UnknownRunException.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/UnknownRunException.java deleted file mode 100644 index af717ab..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/UnknownRunException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - */ -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import javax.xml.ws.WebFault; - -/** - * Exception thrown to indicate that the handle of the run is unknown (or - * unacceptable to the current user). - * - * @author Donal Fellows - */ -@WebFault(name = "UnknownRunFault") -public class UnknownRunException extends Exception { - private static final long serialVersionUID = -3028749401786242841L; - - public UnknownRunException() { - super("unknown run UUID"); - } - - public UnknownRunException(Throwable t) { - super("implementation problems", t); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/package-info.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/package-info.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/package-info.java deleted file mode 100644 index b2284ee..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/exceptions/package-info.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - */ -/** - * This package contains the exceptions/faults thrown by Taverna Server. - * @author Donal Fellows - */ -@XmlSchema(namespace = SERVER, elementFormDefault = QUALIFIED, attributeFormDefault = QUALIFIED, xmlns = { - @XmlNs(prefix = "xlink", namespaceURI = XLINK), - @XmlNs(prefix = "ts", namespaceURI = SERVER), - @XmlNs(prefix = "ts-rest", namespaceURI = SERVER_REST), - @XmlNs(prefix = "ts-soap", namespaceURI = SERVER_SOAP), - @XmlNs(prefix = "feed", namespaceURI = FEED), - @XmlNs(prefix = "admin", namespaceURI = ADMIN) }) -package org.taverna.server.master.exceptions; -/* - * 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. - */ - -import static javax.xml.bind.annotation.XmlNsForm.QUALIFIED; -import static org.taverna.server.master.common.Namespaces.ADMIN; -import static org.taverna.server.master.common.Namespaces.FEED; -import static org.taverna.server.master.common.Namespaces.SERVER; -import static org.taverna.server.master.common.Namespaces.SERVER_REST; -import static org.taverna.server.master.common.Namespaces.SERVER_SOAP; -import static org.taverna.server.master.common.Namespaces.XLINK; - -import javax.xml.bind.annotation.XmlNs; -import javax.xml.bind.annotation.XmlSchema; - http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/Facade.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/Facade.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/Facade.java deleted file mode 100644 index 3031520..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/Facade.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - */ -package org.taverna.server.master.facade; -/* - * 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. - */ - -import static javax.ws.rs.core.MediaType.TEXT_HTML_TYPE; -import static javax.ws.rs.core.Response.ok; - -import java.io.IOException; -import java.net.URL; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Required; -import org.taverna.server.master.utils.Contextualizer; - -/** - * This is a simple class that is used to serve up a file (with a simple - * substitution applied) as the root of the T2Server webapp. - * - * @author Donal Fellows - */ -@Path("/") -public class Facade { - private Log log = LogFactory.getLog("Taverna.Server.Utils"); - private String welcome; - private Contextualizer contextualizer; - - /** - * Set what resource file to use as the template for the response. - * - * @param file - * The file from which to load the data (presumed HTML) to serve - * up as the root content. - * @throws IOException - * If the file doesn't exist. - */ - public void setFile(String file) throws IOException { - URL full = Facade.class.getResource(file); - log.info("setting " + full + " as source of root page"); - this.welcome = IOUtils.toString(full); - } - - @Required - public void setContextualizer(Contextualizer contextualizer) { - this.contextualizer = contextualizer; - } - - /** - * Serve up some HTML as the root of the service. - * - * @param ui - * A reference to how we were accessed by the service. - * @return The response, containing the HTML. - */ - @GET - @Path("{dummy:.*}") - @Produces("text/html") - public Response get(@Context UriInfo ui) { - return ok(contextualizer.contextualize(ui, welcome), TEXT_HTML_TYPE) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/package-info.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/package-info.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/package-info.java deleted file mode 100644 index 2d8f4ef..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/facade/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - */ -/** - * Simple facade used at the top level of the Taverna Server in order to - * provide an entry splash page. - */ -package org.taverna.server.master.facade; -/* - * 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. - */ http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ConfigurableRunFactory.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ConfigurableRunFactory.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ConfigurableRunFactory.java deleted file mode 100644 index 7a4124d..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ConfigurableRunFactory.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - */ -package org.taverna.server.master.factories; -/* - * 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. - */ - -/** - * Interface to run factories for the purpose of configuration. - * - * @author Donal Fellows - */ -public interface ConfigurableRunFactory extends RunFactory { - /** Where is the registry? Getter */ - String getRegistryHost(); - - /** Where is the registry? Setter */ - void setRegistryHost(String host); - - /** Where is the registry? Getter */ - int getRegistryPort(); - - /** Where is the registry? Setter */ - void setRegistryPort(int port); - - /** How much can be done at once? Getter */ - int getMaxRuns(); - - /** How much can be done at once? Setter */ - void setMaxRuns(int maxRuns); - - /** How long will things live? Getter */ - int getDefaultLifetime(); - - /** How long will things live? Setter */ - void setDefaultLifetime(int defaultLifetime); - - /** How often do we probe for info? Getter */ - int getSleepTime(); - - /** How often do we probe for info? Setter */ - void setSleepTime(int sleepTime); - - /** How long do we allow for actions? Getter */ - int getWaitSeconds(); - - /** How long do we allow for actions? Setter */ - void setWaitSeconds(int seconds); - - /** How do we start the workflow engine? Getter */ - String getExecuteWorkflowScript(); - - /** How do we start the workflow engine? Setter */ - void setExecuteWorkflowScript(String executeWorkflowScript); - - /** How do we start the file system access process? Getter */ - String getServerWorkerJar(); - - /** How do we start the file system access process? Setter */ - void setServerWorkerJar(String serverWorkerJar); - - /** - * How do we start the file system access process? Extra arguments to pass. - * Getter - */ - String[] getExtraArguments(); - - /** - * How do we start the file system access process? Extra arguments to pass. - * Setter - */ - void setExtraArguments(String[] firstArguments); - - /** Where is Java? Getter */ - String getJavaBinary(); - - /** Where is Java? Setter */ - void setJavaBinary(String javaBinary); - - /** Where do we get passwords from? Getter */ - String getPasswordFile(); - - /** Where do we get passwords from? Setter */ - void setPasswordFile(String newValue); - - /** How do we switch users? Getter */ - String getServerForkerJar(); - - /** How do we switch users? Setter */ - void setServerForkerJar(String newValue); - - /** How many runs have there been? */ - int getTotalRuns(); - - /** How long did the last subprocess startup take? */ - int getLastStartupCheckCount(); - - /** What are the current runs? */ - String[] getCurrentRunNames(); - - /** What is the RMI ID of the factory process? */ - String getFactoryProcessName(); - - /** What was the last observed exit code? */ - Integer getLastExitCode(); - - /** What factory process to use for a particular user? */ - String[] getFactoryProcessMapping(); - - /** How many runs can be operating at once? Setter */ - void setOperatingLimit(int operatingLimit); - - /** How many runs can be operating at once? Getter */ - int getOperatingLimit(); - - /** - * How many runs are actually operating? - * - * @throws Exception - * if anything goes wrong - */ - int getOperatingCount() throws Exception; - - /** How do we start the RMI registry process? Getter */ - String getRmiRegistryJar(); - - /** How do we start the RMI registry process? Setter */ - void setRmiRegistryJar(String rmiRegistryJar); - - boolean getGenerateProvenance(); - - void setGenerateProvenance(boolean generateProvenance); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ListenerFactory.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ListenerFactory.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ListenerFactory.java deleted file mode 100644 index bb83401..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/ListenerFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - */ -package org.taverna.server.master.factories; -/* - * 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. - */ - -import java.util.List; - -import org.taverna.server.master.exceptions.NoListenerException; -import org.taverna.server.master.interfaces.Listener; -import org.taverna.server.master.interfaces.TavernaRun; - -/** - * How to make event listeners of various types that are attached to a workflow - * instance. - * - * @author Donal Fellows - */ -public interface ListenerFactory { - /** - * Make an event listener. - * - * @param run - * The workflow instance to attach the event listener to. - * @param listenerType - * The type of event listener to create. Must be one of the - * strings returned by {@link #getSupportedListenerTypes()}. - * @param configuration - * A configuration document to pass to the listener. - * @return The event listener that was created. - * @throws NoListenerException - * If the <b>listenerType</b> is unrecognized or the - * <b>configuration</b> is bad in some way. - */ - public Listener makeListener(TavernaRun run, String listenerType, - String configuration) throws NoListenerException; - - /** - * What types of listener are supported? Note that we assume that the list - * of types is the same for all users and all workflow instances. - * - * @return A list of supported listener types. - */ - public List<String> getSupportedListenerTypes(); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/RunFactory.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/RunFactory.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/RunFactory.java deleted file mode 100644 index d048f70..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/RunFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - */ -package org.taverna.server.master.factories; -/* - * 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. - */ - -import org.taverna.server.master.common.Workflow; -import org.taverna.server.master.exceptions.NoCreateException; -import org.taverna.server.master.interfaces.TavernaRun; -import org.taverna.server.master.utils.UsernamePrincipal; - -/** - * How to construct a Taverna Server Workflow Run. - * - * @author Donal Fellows - */ -public interface RunFactory { - /** - * Make a Taverna Server workflow run that is bound to a particular user - * (the "creator") and able to run a particular workflow. - * - * @param creator - * The user creating the workflow instance. - * @param workflow - * The workflow to instantiate - * @return An object representing the run. - * @throws NoCreateException - * On failure. - */ - TavernaRun create(UsernamePrincipal creator, Workflow workflow) - throws NoCreateException; - - /** - * Check whether the factory is permitting runs to actually start operating. - * - * @return Whether a run should start. - */ - boolean isAllowingRunsToStart(); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/package-info.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/package-info.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/package-info.java deleted file mode 100644 index 56ba1e2..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/factories/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - */ -/** - * These interfaces define the principal way for the <i>factories</i> of - * worker classes to be invoked. - */ -package org.taverna.server.master.factories; -/* - * 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. - */ http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/AuthorityDerivedIDMapper.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/AuthorityDerivedIDMapper.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/AuthorityDerivedIDMapper.java deleted file mode 100644 index 4fd5312..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/AuthorityDerivedIDMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - */ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import static org.taverna.server.master.defaults.Default.AUTHORITY_PREFIX; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.context.SecurityContextHolder; -import org.taverna.server.master.interfaces.LocalIdentityMapper; -import org.taverna.server.master.utils.UsernamePrincipal; - -/** - * Extracts the local user id from the set of Spring Security authorities - * granted to the current user. This is done by scanning the set of authorities - * to see if any of them start with the substring listed in the <tt>prefix</tt> - * property; the username is the rest of the authority string in that case. - * - * @author Donal Fellows - */ -public class AuthorityDerivedIDMapper implements LocalIdentityMapper { - private String prefix = AUTHORITY_PREFIX; - - public String getPrefix() { - return prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - @Override - public String getUsernameForPrincipal(UsernamePrincipal user) { - Authentication auth = SecurityContextHolder.getContext() - .getAuthentication(); - if (auth == null || !auth.isAuthenticated()) - return null; - for (GrantedAuthority authority : auth.getAuthorities()) { - String token = authority.getAuthority(); - if (token == null) - continue; - if (token.startsWith(prefix)) - return token.substring(prefix.length()); - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/CompositeIDMapper.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/CompositeIDMapper.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/CompositeIDMapper.java deleted file mode 100644 index f0a6f4c..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/CompositeIDMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - */ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import static org.apache.commons.logging.LogFactory.getLog; - -import java.util.List; -import java.util.Map.Entry; - -import org.apache.commons.logging.Log; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.taverna.server.master.interfaces.LocalIdentityMapper; -import org.taverna.server.master.utils.UsernamePrincipal; - -/** - * An identity mapper that composes the results from other mappers, using the - * identity mappers in order until one can provide a non-<tt>null</tt> answer. - * - * @author Donal Fellows. - */ -public class CompositeIDMapper implements LocalIdentityMapper, - ApplicationContextAware { - private Log log = getLog("Taverna.Server.IdentityMapper"); - private List<LocalIdentityMapper> mappers; - private ApplicationContext context; - - /** - * @param mappers - * The list of mappers to delegate to. Order is significant. - */ - public void setIdentityMappers(List<LocalIdentityMapper> mappers) { - this.mappers = mappers; - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) - throws BeansException { - context = applicationContext; - } - - @Override - public String getUsernameForPrincipal(UsernamePrincipal user) { - if (mappers == null) - return null; - for (LocalIdentityMapper m : mappers) { - String u = m.getUsernameForPrincipal(user); - if (u == null) - continue; - for (Entry<String, ? extends LocalIdentityMapper> entry : context - .getBeansOfType(m.getClass()).entrySet()) - if (m == entry.getValue()) { - log.info("used " + entry.getKey() + " LIM to map " + user - + " to " + u); - break; - } - return u; - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/ConstantIDMapper.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/ConstantIDMapper.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/ConstantIDMapper.java deleted file mode 100644 index bf48fc7..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/ConstantIDMapper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - */ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import org.taverna.server.master.interfaces.LocalIdentityMapper; -import org.taverna.server.master.utils.UsernamePrincipal; - -/** - * A trivial principal to user mapper that always uses the same ID. - * @author Donal Fellows - */ -public class ConstantIDMapper implements LocalIdentityMapper { - private String id; - - /** - * Sets what local user ID all users should be mapped to. - * - * @param id - * The local user ID. - */ - public void setConstantId(String id) { - this.id = id; - } - - @Override - public String getUsernameForPrincipal(UsernamePrincipal user) { - return id; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/NameIDMapper.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/NameIDMapper.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/NameIDMapper.java deleted file mode 100644 index 9d11cfd..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/NameIDMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - */ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import static java.util.regex.Pattern.compile; - -import java.security.Principal; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -import org.taverna.server.master.interfaces.LocalIdentityMapper; -import org.taverna.server.master.utils.UsernamePrincipal; - -/** - * A trivial identity mapper that just uses the name out of the - * {@link Principal}, or uses a regular expression to extract it from the string - * representation of the principal. - * - * @author Donal Fellows - */ -public class NameIDMapper implements LocalIdentityMapper { - private Pattern pat; - - /** - * @param regexp - * The regular expression to use. The first capturing group - * within the RE will be the result of the extraction. - * @throws PatternSyntaxException - * If the pattern is invalid. - */ - public void setRegexp(String regexp) throws PatternSyntaxException { - pat = compile(regexp); - } - - @Override - public String getUsernameForPrincipal(UsernamePrincipal user) { - if (pat != null) { - Matcher m = pat.matcher(user.toString()); - if (m.find() && m.groupCount() > 0) { - return m.group(1); - } - return null; - } - return user.getName(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/StrippedDownAuthProvider.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/StrippedDownAuthProvider.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/StrippedDownAuthProvider.java deleted file mode 100644 index dc489ae..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/StrippedDownAuthProvider.java +++ /dev/null @@ -1,294 +0,0 @@ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.PreDestroy; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Required; -import org.springframework.security.authentication.AccountExpiredException; -import org.springframework.security.authentication.AuthenticationProvider; -import org.springframework.security.authentication.AuthenticationServiceException; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.authentication.CredentialsExpiredException; -import org.springframework.security.authentication.DisabledException; -import org.springframework.security.authentication.LockedException; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.taverna.server.master.utils.CallTimeLogger.PerfLogged; - -/** - * A stripped down version of a - * {@link org.springframework.security.authentication.dao.DaoAuthenticationProvider - * DaoAuthenticationProvider}/ - * {@link org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider - * AbstractUserDetailsAuthenticationProvider} that avoids much of the overhead - * associated with that class. - */ -public class StrippedDownAuthProvider implements AuthenticationProvider { - /** - * The plaintext password used to perform - * {@link PasswordEncoder#isPasswordValid(String, String, Object)} on when - * the user is not found to avoid SEC-2056. - */ - private static final String USER_NOT_FOUND_PASSWORD = "userNotFoundPassword"; - - /** - * The password used to perform - * {@link PasswordEncoder#isPasswordValid(String, String, Object)} on when - * the user is not found to avoid SEC-2056. This is necessary, because some - * {@link PasswordEncoder} implementations will short circuit if the - * password is not in a valid format. - */ - private String userNotFoundEncodedPassword; - private UserDetailsService userDetailsService; - private PasswordEncoder passwordEncoder; - private Map<String, AuthCacheEntry> authCache = new HashMap<>(); - protected final Log logger = LogFactory.getLog(getClass()); - - private static class AuthCacheEntry { - private String creds; - private long timestamp; - private static final long VALIDITY = 1000 * 60 * 20; - AuthCacheEntry(String credentials) { - creds = credentials; - timestamp = System.currentTimeMillis(); - } - boolean valid(String password) { - return creds.equals(password) && timestamp+VALIDITY > System.currentTimeMillis(); - } - } - - @PerfLogged - @Override - public Authentication authenticate(Authentication authentication) - throws AuthenticationException { - - if (!(authentication instanceof UsernamePasswordAuthenticationToken)) - throw new IllegalArgumentException( - "can only authenticate against username+password"); - UsernamePasswordAuthenticationToken auth = (UsernamePasswordAuthenticationToken) authentication; - - // Determine username - String username = (auth.getPrincipal() == null) ? "NONE_PROVIDED" - : auth.getName(); - - UserDetails user; - - try { - user = retrieveUser(username, auth); - if (user == null) - throw new IllegalStateException( - "retrieveUser returned null - a violation of the interface contract"); - } catch (UsernameNotFoundException notFound) { - if (logger.isDebugEnabled()) - logger.debug("User '" + username + "' not found", notFound); - throw new BadCredentialsException("Bad credentials"); - } - - // Pre-auth - if (!user.isAccountNonLocked()) - throw new LockedException("User account is locked"); - if (!user.isEnabled()) - throw new DisabledException("User account is disabled"); - if (!user.isAccountNonExpired()) - throw new AccountExpiredException("User account has expired"); - Object credentials = auth.getCredentials(); - if (credentials == null) { - logger.debug("Authentication failed: no credentials provided"); - - throw new BadCredentialsException("Bad credentials"); - } - - String providedPassword = credentials.toString(); - boolean matched = false; - synchronized (authCache) { - AuthCacheEntry pw = authCache.get(username); - if (pw != null && providedPassword != null) { - if (pw.valid(providedPassword)) - matched = true; - else - authCache.remove(username); - } - } - // Auth - if (!matched) { - if (!passwordEncoder.matches(providedPassword, user.getPassword())) { - logger.debug("Authentication failed: password does not match stored value"); - - throw new BadCredentialsException("Bad credentials"); - } - if (providedPassword != null) - synchronized (authCache) { - authCache.put(username, new AuthCacheEntry(providedPassword)); - } - } - - // Post-auth - if (!user.isCredentialsNonExpired()) - throw new CredentialsExpiredException( - "User credentials have expired"); - - return createSuccessAuthentication(user, auth, user); - } - - @PreDestroy - void clearCache() { - authCache.clear(); - } - - /** - * Creates a successful {@link Authentication} object. - * <p> - * Protected so subclasses can override. - * </p> - * <p> - * Subclasses will usually store the original credentials the user supplied - * (not salted or encoded passwords) in the returned - * <code>Authentication</code> object. - * </p> - * - * @param principal - * that should be the principal in the returned object (defined - * by the {@link #isForcePrincipalAsString()} method) - * @param authentication - * that was presented to the provider for validation - * @param user - * that was loaded by the implementation - * - * @return the successful authentication token - */ - private Authentication createSuccessAuthentication(Object principal, - Authentication authentication, UserDetails user) { - /* - * Ensure we return the original credentials the user supplied, so - * subsequent attempts are successful even with encoded passwords. Also - * ensure we return the original getDetails(), so that future - * authentication events after cache expiry contain the details - */ - UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken( - principal, authentication.getCredentials(), - user.getAuthorities()); - result.setDetails(authentication.getDetails()); - - return result; - } - - @Override - public boolean supports(Class<?> authentication) { - return UsernamePasswordAuthenticationToken.class - .isAssignableFrom(authentication); - } - - /** - * Allows subclasses to actually retrieve the <code>UserDetails</code> from - * an implementation-specific location, with the option of throwing an - * <code>AuthenticationException</code> immediately if the presented - * credentials are incorrect (this is especially useful if it is necessary - * to bind to a resource as the user in order to obtain or generate a - * <code>UserDetails</code>). - * <p> - * Subclasses are not required to perform any caching, as the - * <code>AbstractUserDetailsAuthenticationProvider</code> will by default - * cache the <code>UserDetails</code>. The caching of - * <code>UserDetails</code> does present additional complexity as this means - * subsequent requests that rely on the cache will need to still have their - * credentials validated, even if the correctness of credentials was assured - * by subclasses adopting a binding-based strategy in this method. - * Accordingly it is important that subclasses either disable caching (if - * they want to ensure that this method is the only method that is capable - * of authenticating a request, as no <code>UserDetails</code> will ever be - * cached) or ensure subclasses implement - * {@link #additionalAuthenticationChecks(UserDetails, UsernamePasswordAuthenticationToken)} - * to compare the credentials of a cached <code>UserDetails</code> with - * subsequent authentication requests. - * </p> - * <p> - * Most of the time subclasses will not perform credentials inspection in - * this method, instead performing it in - * {@link #additionalAuthenticationChecks(UserDetails, UsernamePasswordAuthenticationToken)} - * so that code related to credentials validation need not be duplicated - * across two methods. - * </p> - * - * @param username - * The username to retrieve - * @param authentication - * The authentication request, which subclasses <em>may</em> need - * to perform a binding-based retrieval of the - * <code>UserDetails</code> - * - * @return the user information (never <code>null</code> - instead an - * exception should the thrown) - * - * @throws AuthenticationException - * if the credentials could not be validated (generally a - * <code>BadCredentialsException</code>, an - * <code>AuthenticationServiceException</code> or - * <code>UsernameNotFoundException</code>) - */ - private UserDetails retrieveUser(String username, - UsernamePasswordAuthenticationToken authentication) - throws AuthenticationException { - try { - return userDetailsService.loadUserByUsername(username); - } catch (UsernameNotFoundException notFound) { - if (authentication.getCredentials() != null) { - String presentedPassword = authentication.getCredentials() - .toString(); - passwordEncoder.matches(presentedPassword, - userNotFoundEncodedPassword); - } - throw notFound; - } catch (AuthenticationException e) { - throw e; - } catch (Exception repositoryProblem) { - throw new AuthenticationServiceException( - repositoryProblem.getMessage(), repositoryProblem); - } - } - - /** - * Sets the PasswordEncoder instance to be used to encode and validate - * passwords. - */ - @Required - public void setPasswordEncoder(PasswordEncoder passwordEncoder) { - if (passwordEncoder == null) - throw new IllegalArgumentException("passwordEncoder cannot be null"); - - this.passwordEncoder = passwordEncoder; - this.userNotFoundEncodedPassword = passwordEncoder - .encode(USER_NOT_FOUND_PASSWORD); - } - - @Required - public void setUserDetailsService(UserDetailsService userDetailsService) { - if (userDetailsService == null) - throw new IllegalStateException("A UserDetailsService must be set"); - this.userDetailsService = userDetailsService; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/User.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/User.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/User.java deleted file mode 100644 index 1fdf2bf..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/User.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - */ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import static org.taverna.server.master.common.Roles.ADMIN; -import static org.taverna.server.master.common.Roles.USER; -import static org.taverna.server.master.defaults.Default.AUTHORITY_PREFIX; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.Query; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -/** - * The representation of a user in the database. - * <p> - * A user consists logically of a (non-ordered) tuple of items: - * <ul> - * <li>The {@linkplain #getUsername() user name}, - * <li>The {@linkplain #getPassword() user's password} (salted, encoded), - * <li>Whether the user is {@linkplain #isEnabled() enabled} (i.e., able to log - * in), - * <li>Whether the user has {@linkplain #isAdmin() administrative privileges}, and - * <li>What {@linkplain #getLocalUsername() system (Unix) account} the user's - * workflows will run as; separation between different users that are mapped to - * the same system account is nothing like as strongly enforced. - * </ul> - * - * @author Donal Fellows - */ -@PersistenceCapable(schema = "USERS", table = "LIST") -@Query(name = "users", language = "SQL", value = "SELECT id FROM USERS.LIST ORDER BY id", resultClass = String.class) -@XmlRootElement -@XmlType(name = "User", propOrder = {}) -@SuppressWarnings("serial") -public class User implements UserDetails { - @XmlElement - @Persistent - private boolean disabled; - @XmlElement(name = "username", required = true) - @Persistent(primaryKey = "true") - private String id; - @XmlElement(name = "password", required = true) - @Persistent(column = "password") - private String encodedPassword; - @XmlElement - @Persistent - private boolean admin; - @XmlElement - @Persistent - private String localUsername; - - @Override - public Collection<GrantedAuthority> getAuthorities() { - List<GrantedAuthority> auths = new ArrayList<>(); - auths.add(new LiteralGrantedAuthority(USER)); - if (admin) - auths.add(new LiteralGrantedAuthority(ADMIN)); - if (localUsername != null) - auths.add(new LiteralGrantedAuthority(AUTHORITY_PREFIX - + localUsername)); - return auths; - } - - @Override - public String getPassword() { - return encodedPassword; - } - - @Override - public String getUsername() { - return id; - } - - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @Override - public boolean isEnabled() { - return !disabled; - } - - void setDisabled(boolean disabled) { - this.disabled = disabled; - } - - void setUsername(String username) { - this.id = username; - } - - void setEncodedPassword(String password) { - this.encodedPassword = password; - } - - void setAdmin(boolean admin) { - this.admin = admin; - } - - public boolean isAdmin() { - return admin; - } - - void setLocalUsername(String localUsername) { - this.localUsername = localUsername; - } - - public String getLocalUsername() { - return localUsername; - } -} - -@SuppressWarnings("serial") -class LiteralGrantedAuthority implements GrantedAuthority { - private String auth; - - LiteralGrantedAuthority(String auth) { - this.auth = auth; - } - - @Override - public String getAuthority() { - return auth; - } - - @Override - public String toString() { - return "AUTHORITY(" + auth + ")"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStore.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStore.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStore.java deleted file mode 100644 index 3177d5c..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStore.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - */ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import static org.apache.commons.logging.LogFactory.getLog; -import static org.taverna.server.master.TavernaServer.JMX_ROOT; -import static org.taverna.server.master.common.Roles.ADMIN; -import static org.taverna.server.master.common.Roles.USER; -import static org.taverna.server.master.defaults.Default.AUTHORITY_PREFIX; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.jdo.annotations.PersistenceAware; - -import org.apache.commons.logging.Log; -import org.springframework.beans.factory.annotation.Required; -import org.springframework.dao.DataAccessException; -import org.springframework.jmx.export.annotation.ManagedAttribute; -import org.springframework.jmx.export.annotation.ManagedOperation; -import org.springframework.jmx.export.annotation.ManagedOperationParameter; -import org.springframework.jmx.export.annotation.ManagedOperationParameters; -import org.springframework.jmx.export.annotation.ManagedResource; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.core.userdetails.memory.UserAttribute; -import org.springframework.security.core.userdetails.memory.UserAttributeEditor; -import org.taverna.server.master.utils.CallTimeLogger.PerfLogged; -import org.taverna.server.master.utils.JDOSupport; - -/** - * The bean class that is responsible for managing the users in the database. - * - * @author Donal Fellows - */ -@PersistenceAware -@ManagedResource(objectName = JMX_ROOT + "Users", description = "The user database.") -public class UserStore extends JDOSupport<User> implements UserDetailsService, - UserStoreAPI { - /** The logger for the user store. */ - private transient Log log = getLog("Taverna.Server.UserDB"); - - public UserStore() { - super(User.class); - } - - @PreDestroy - void closeLog() { - log = null; - } - - private Map<String, BootstrapUserInfo> base = new HashMap<>(); - private String defLocalUser; - private PasswordEncoder encoder; - private volatile int epoch; - - /** - * Install the encoder that will be used to turn a plaintext password into - * something that it is safe to store in the database. - * - * @param encoder - * The password encoder bean to install. - */ - public void setEncoder(PasswordEncoder encoder) { - this.encoder = encoder; - } - - public void setBaselineUserProperties(Properties props) { - UserAttributeEditor parser = new UserAttributeEditor(); - - for (Object name : props.keySet()) { - String username = (String) name; - String value = props.getProperty(username); - - // Convert value to a password, enabled setting, and list of granted - // authorities - parser.setAsText(value); - - UserAttribute attr = (UserAttribute) parser.getValue(); - if (attr != null && attr.isEnabled()) - base.put(username, new BootstrapUserInfo(username, attr)); - } - } - - private void installPassword(User u, String password) { - u.setEncodedPassword(encoder.encode(password)); - } - - public void setDefaultLocalUser(String defLocalUser) { - this.defLocalUser = defLocalUser; - } - - @SuppressWarnings("unchecked") - private List<String> getUsers() { - return (List<String>) namedQuery("users").execute(); - } - - @WithinSingleTransaction - @PostConstruct - void initDB() { - if (base == null || base.isEmpty()) - log.warn("no baseline user collection"); - else if (!getUsers().isEmpty()) - log.info("using existing users from database"); - else - for (String username : base.keySet()) { - BootstrapUserInfo ud = base.get(username); - if (ud == null) - continue; - User u = ud.get(encoder); - if (u == null) - continue; - log.info("bootstrapping user " + username + " in the database"); - persist(u); - } - base = null; - epoch++; - } - - @Override - @PerfLogged - @WithinSingleTransaction - @ManagedAttribute(description = "The list of server accounts known about.", currencyTimeLimit = 30) - public List<String> getUserNames() { - return getUsers(); - } - - @Override - @PerfLogged - @WithinSingleTransaction - public User getUser(String userName) { - return detach(getById(userName)); - } - - /** - * Get information about a server account. - * - * @param userName - * The username to look up. - * @return A description map intended for use by a server admin over JMX. - */ - @PerfLogged - @WithinSingleTransaction - @ManagedOperation(description = "Get information about a server account.") - @ManagedOperationParameters(@ManagedOperationParameter(name = "userName", description = "The username to look up.")) - public Map<String, String> getUserInfo(String userName) { - User u = getById(userName); - Map<String, String> info = new HashMap<>(); - info.put("name", u.getUsername()); - info.put("admin", u.isAdmin() ? "yes" : "no"); - info.put("enabled", u.isEnabled() ? "yes" : "no"); - info.put("localID", u.getLocalUsername()); - return info; - } - - /** - * Get a list of all the users in the database. - * - * @return A list of user details, <i>copied</i> out of the database. - */ - @PerfLogged - @WithinSingleTransaction - public List<UserDetails> listUsers() { - ArrayList<UserDetails> result = new ArrayList<>(); - for (String id : getUsers()) - result.add(detach(getById(id))); - return result; - } - - @Override - @PerfLogged - @WithinSingleTransaction - @ManagedOperation(description = "Create a new user account; the account will be disabled and " - + "non-administrative by default. Does not create any underlying system account.") - @ManagedOperationParameters({ - @ManagedOperationParameter(name = "username", description = "The username to create."), - @ManagedOperationParameter(name = "password", description = "The password to use."), - @ManagedOperationParameter(name = "coupleLocalUsername", description = "Whether to set the local user name to the 'main' one.") }) - public void addUser(String username, String password, - boolean coupleLocalUsername) { - if (username.matches(".*[^a-zA-Z0-9].*")) - throw new IllegalArgumentException( - "bad user name; must be pure alphanumeric"); - if (getById(username) != null) - throw new IllegalArgumentException("user name already exists"); - User u = new User(); - u.setDisabled(true); - u.setAdmin(false); - u.setUsername(username); - installPassword(u, password); - if (coupleLocalUsername) - u.setLocalUsername(username); - else - u.setLocalUsername(defLocalUser); - log.info("creating user for " + username); - persist(u); - epoch++; - } - - @Override - @PerfLogged - @WithinSingleTransaction - @ManagedOperation(description = "Set or clear whether this account is enabled. " - + "Disabled accounts cannot be used to log in.") - @ManagedOperationParameters({ - @ManagedOperationParameter(name = "username", description = "The username to adjust."), - @ManagedOperationParameter(name = "enabled", description = "Whether to enable the account.") }) - public void setUserEnabled(String username, boolean enabled) { - User u = getById(username); - if (u != null) { - u.setDisabled(!enabled); - log.info((enabled ? "enabling" : "disabling") + " user " + username); - epoch++; - } - } - - @Override - @PerfLogged - @WithinSingleTransaction - @ManagedOperation(description = "Set or clear the mark on an account that indicates " - + "that it has administrative privileges.") - @ManagedOperationParameters({ - @ManagedOperationParameter(name = "username", description = "The username to adjust."), - @ManagedOperationParameter(name = "admin", description = "Whether the account has admin privileges.") }) - public void setUserAdmin(String username, boolean admin) { - User u = getById(username); - if (u != null) { - u.setAdmin(admin); - log.info((admin ? "enabling" : "disabling") + " user " + username - + " admin status"); - epoch++; - } - } - - @Override - @PerfLogged - @WithinSingleTransaction - @ManagedOperation(description = "Change the password for an account.") - @ManagedOperationParameters({ - @ManagedOperationParameter(name = "username", description = "The username to adjust."), - @ManagedOperationParameter(name = "password", description = "The new password to use.") }) - public void setUserPassword(String username, String password) { - User u = getById(username); - if (u != null) { - installPassword(u, password); - log.info("changing password for user " + username); - epoch++; - } - } - - @Override - @PerfLogged - @WithinSingleTransaction - @ManagedOperation(description = "Change what local system account to use for a server account.") - @ManagedOperationParameters({ - @ManagedOperationParameter(name = "username", description = "The username to adjust."), - @ManagedOperationParameter(name = "password", description = "The new local user account use.") }) - public void setUserLocalUser(String username, String localUsername) { - User u = getById(username); - if (u != null) { - u.setLocalUsername(localUsername); - log.info("mapping user " + username + " to local account " - + localUsername); - epoch++; - } - } - - @Override - @PerfLogged - @WithinSingleTransaction - @ManagedOperation(description = "Delete a server account. The underlying " - + "system account is not modified.") - @ManagedOperationParameters(@ManagedOperationParameter(name = "username", description = "The username to delete.")) - public void deleteUser(String username) { - delete(getById(username)); - log.info("deleting user " + username); - epoch++; - } - - @Override - @PerfLogged - @WithinSingleTransaction - public UserDetails loadUserByUsername(String username) - throws UsernameNotFoundException, DataAccessException { - User u; - if (base != null) { - log.warn("bootstrap user store still installed!"); - BootstrapUserInfo ud = base.get(username); - if (ud != null) { - log.warn("retrieved production credentials for " + username - + " from bootstrap store"); - u = ud.get(encoder); - if (u != null) - return u; - } - } - try { - u = detach(getById(username)); - } catch (NullPointerException npe) { - throw new UsernameNotFoundException("who are you?"); - } catch (Exception ex) { - throw new UsernameNotFoundException("who are you?", ex); - } - if (u != null) - return u; - throw new UsernameNotFoundException("who are you?"); - } - - int getEpoch() { - return epoch; - } - - public static class CachedUserStore implements UserDetailsService { - private int epoch; - private Map<String, UserDetails> cache = new HashMap<>(); - private UserStore realStore; - - @Required - public void setRealStore(UserStore store) { - this.realStore = store; - } - - @Override - @PerfLogged - public UserDetails loadUserByUsername(String username) { - int epoch = realStore.getEpoch(); - UserDetails details; - synchronized (cache) { - if (epoch != this.epoch) { - cache.clear(); - this.epoch = epoch; - details = null; - } else - details = cache.get(username); - } - if (details == null) { - details = realStore.loadUserByUsername(username); - synchronized (cache) { - cache.put(username, details); - } - } - return details; - } - } - - private static class BootstrapUserInfo { - private String user; - private String pass; - private Collection<GrantedAuthority> auth; - - BootstrapUserInfo(String username, UserAttribute attr) { - user = username; - pass = attr.getPassword(); - auth = attr.getAuthorities(); - } - - User get(PasswordEncoder encoder) { - User u = new User(); - boolean realUser = false; - for (GrantedAuthority ga : auth) { - String a = ga.getAuthority(); - if (a.startsWith(AUTHORITY_PREFIX)) - u.setLocalUsername(a.substring(AUTHORITY_PREFIX.length())); - else if (a.equals(USER)) - realUser = true; - else if (a.equals(ADMIN)) - u.setAdmin(true); - } - if (!realUser) - return null; - u.setUsername(user); - u.setEncodedPassword(encoder.encode(pass)); - u.setDisabled(false); - return u; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-server/blob/00397eff/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStoreAPI.java ---------------------------------------------------------------------- diff --git a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStoreAPI.java b/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStoreAPI.java deleted file mode 100644 index c4caf3c..0000000 --- a/taverna-server-webapp/src/main/java/org/taverna/server/master/identity/UserStoreAPI.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.taverna.server.master.identity; -/* - * 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. - */ - -import java.util.List; - -/** - * The API that is exposed by the DAO that exposes user management. - * - * @author Donal Fellows - * @see User - */ -public interface UserStoreAPI { - /** - * List the currently-known account names. - * - * @return A list of users in the database. Note that this is a snapshot. - */ - List<String> getUserNames(); - - /** - * Get a particular user's description. - * - * @param userName - * The username to look up. - * @return A <i>copy</i> of the user description. - */ - User getUser(String userName); - - /** - * Create a new user account; the account will be disabled and - * non-administrative by default. Does not create any underlying system - * account. - * - * @param username - * The username to create. - * @param password - * The password to use. - * @param coupleLocalUsername - * Whether to set the local user name to the 'main' one. - */ - void addUser(String username, String password, boolean coupleLocalUsername); - - /** - * Set or clear whether this account is enabled. Disabled accounts cannot be - * used to log in. - * - * @param username - * The username to adjust. - * @param enabled - * Whether to enable the account. - */ - void setUserEnabled(String username, boolean enabled); - - /** - * Set or clear the mark on an account that indicates that it has - * administrative privileges. - * - * @param username - * The username to adjust. - * @param admin - * Whether the account has admin privileges. - */ - void setUserAdmin(String username, boolean admin); - - /** - * Change the password for an account. - * - * @param username - * The username to adjust. - * @param password - * The new password to use. - */ - void setUserPassword(String username, String password); - - /** - * Change what local system account to use for a server account. - * - * @param username - * The username to adjust. - * @param localUsername - * The new local user account use. - */ - void setUserLocalUser(String username, String localUsername); - - /** - * Delete a server account. The underlying system account is not modified. - * - * @param username - * The username to delete. - */ - void deleteUser(String username); -}
