Response makePermission()

in taverna-server-webapp/src/main/java/org/apache/taverna/server/master/rest/TavernaServerSecurityREST.java [480:595]


	Response makePermission(@Nonnull PermissionDescription desc,
			@Nonnull @Context UriInfo ui);

	/**
	 * A description of the security resources associated with a workflow run.
	 * 
	 * @author Donal Fellows
	 */
	@XmlRootElement(name = "securityDescriptor")
	@XmlType(name = "SecurityDescriptor")
	public static final class Descriptor extends VersionedElement {
		/** The identity of the owner of the enclosing workflow run. */
		@XmlElement
		public String owner;
		/** Where to get the permissions on the run. */
		@XmlElement
		public Uri permissions;

		/** Characterisation of the credentials attached to the run. */
		@XmlElement
		public Credentials credentials;
		/** Characterisation of the trusted certificates attached to the run. */
		@XmlElement
		public Trusts trusts;

		public Descriptor() {
		}

		/**
		 * Initialise a description of the security context.
		 * 
		 * @param ub
		 *            How to build URIs.
		 * @param owner
		 *            Who owns the context.
		 * @param credential
		 *            The credentials associated with the context.
		 * @param trust
		 *            The trusted certificates associated with the context.
		 */
		public Descriptor(@Nonnull UriBuilder ub, @Nonnull String owner,
				@Nonnull Credential[] credential, @Nonnull Trust[] trust) {
			super(true);
			this.owner = owner;
			this.permissions = new Uri(ub, PERMS);
			this.credentials = new Credentials(new Uri(ub, CREDS).ref,
					credential);
			this.trusts = new Trusts(new Uri(ub, TRUSTS).ref, trust);
		}

		/**
		 * A description of credentials associated with a workflow run.
		 * 
		 * @author Donal Fellows
		 */
		@XmlType(name = "CredentialCollection")
		public static final class Credentials {
			/** Reference to the collection of credentials */
			@XmlAttribute(name = "href", namespace = XLINK)
			@XmlSchemaType(name = "anyURI")
			public URI href;
			/** Descriptions of the credentials themselves. */
			@XmlElement
			public List<CredentialHolder> credential = new ArrayList<>();

			public Credentials() {
			}

			/**
			 * Initialise a description of the credentials.
			 * 
			 * @param uri
			 *            the URI of the collection.
			 * @param credential
			 *            The credentials in the collection.
			 */
			public Credentials(@Nonnull URI uri,
					@Nonnull Credential[] credential) {
				this.href = uri;
				for (Credential c : credential)
					this.credential.add(new CredentialHolder(c));
			}
		}

		/**
		 * A description of trusted certificates associated with a workflow run.
		 * 
		 * @author Donal Fellows
		 */
		@XmlType(name = "TrustCollection")
		public static final class Trusts {
			/** Reference to the collection of trusted certs */
			@XmlAttribute(name = "href", namespace = XLINK)
			@XmlSchemaType(name = "anyURI")
			public URI href;
			/** Descriptions of the trusted certs themselves. */
			@XmlElement
			public Trust[] trust;

			public Trusts() {
			}

			/**
			 * Initialise a description of the trusted certificates.
			 * 
			 * @param uri
			 *            the URI of the collection.
			 * @param trust
			 *            The trusted certificates in the collection.
			 */
			public Trusts(@Nonnull URI uri, @Nonnull Trust[] trust) {
				this.href = uri;
				this.trust = trust.clone();
			}
		}
	}