List of usage examples for javax.xml.bind JAXBElement getValue
public T getValue()
Return the content model and attribute values for this element.
See #isNil() for a description of a property constraint when this value is null
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.SessionWSDaoImpl.java
@Override public BlackboardSessionResponse createSession(ConferenceUser user, SessionForm sessionForm) { final BlackboardSetSession setSession = new BlackboardSetSession(); setSession.setCreatorId(user.getUniqueId()); setSession.setSessionName(sessionForm.getSessionName()); setSession.setStartTime(sessionForm.getStartTime().getMillis()); setSession.setEndTime(sessionForm.getEndTime().getMillis()); setSession.setBoundaryTime(sessionForm.getBoundaryTime()); setSession.setChairList(user.getUniqueId()); if (securityExpressionEvaluator.authorize("hasRole('ROLE_FULL_ACCESS')")) { setSession.setMaxTalkers(sessionForm.getMaxTalkers()); setSession.setMaxCameras(sessionForm.getMaxCameras()); setSession.setMustBeSupervised(sessionForm.isMustBeSupervised()); setSession.setPermissionsOn(sessionForm.isPermissionsOn()); setSession.setRaiseHandOnEnter(sessionForm.isRaiseHandOnEnter()); final RecordingMode recordingMode = sessionForm.getRecordingMode(); if (recordingMode != null) { setSession.setRecordingModeType(recordingMode.getBlackboardRecordingMode()); }/* w w w . j a va 2 s . c om*/ setSession.setHideParticipantNames(sessionForm.isHideParticipantNames()); setSession.setAllowInSessionInvites(sessionForm.isAllowInSessionInvites()); } final Object objSessionResponse = sasWebServiceOperations .marshalSendAndReceiveToSAS("http://sas.elluminate.com/SetSession", setSession); @SuppressWarnings("unchecked") JAXBElement<BlackboardSessionResponseCollection> jaxbSessionResponse = (JAXBElement<BlackboardSessionResponseCollection>) objSessionResponse; final BlackboardSessionResponseCollection sessionResponses = jaxbSessionResponse.getValue(); final BlackboardSessionResponse sessionResponse = DataAccessUtils .singleResult(sessionResponses.getSessionResponses()); return sessionResponse; }
From source file:be.fedict.eid.idp.protocol.ws_federation.sts.SecurityTokenServicePortImpl.java
@Override public RequestSecurityTokenResponseCollectionType requestSecurityToken(RequestSecurityTokenType request) { List<Object> requestContent = request.getAny(); String expectedAudience = null; for (Object requestObject : requestContent) { LOG.debug("request object type: " + requestObject.getClass().getName()); if (requestObject instanceof JAXBElement) { JAXBElement jaxbElement = (JAXBElement) requestObject; QName qname = jaxbElement.getName(); if (WSTrustConstants.TOKEN_TYPE_QNAME.equals(qname)) { String tokenType = (String) jaxbElement.getValue(); if (false == WSTrustConstants.STATUS_TOKEN_TYPE.equals(tokenType)) { throw new SecurityException("invalid response token type: " + tokenType); }//from www . j a va 2 s. com } else if (WSTrustConstants.REQUEST_TYPE_QNAME.equals(qname)) { String requestType = (String) jaxbElement.getValue(); if (false == WSTrustConstants.VALIDATE_REQUEST_TYPE.equals(requestType)) { throw new SecurityException("invalid request type: " + requestType); } } else if (WSTrustConstants.VALIDATE_TARGET_QNAME.equals(qname)) { ValidateTargetType validateTarget = (ValidateTargetType) jaxbElement.getValue(); Object validateTargetObject = validateTarget.getAny(); if (null == validateTargetObject) { throw new SecurityException("missing ValidateTarget content"); } LOG.debug("ValidateTarget content type: " + validateTargetObject.getClass().getName()); // TODO: verify content is indeed SecurityTokenReference } } else if (requestObject instanceof AppliesTo) { AppliesTo appliesTo = (AppliesTo) requestObject; LOG.debug("wsp:AppliesTo present"); List<Object> appliesToContent = appliesTo.getAny(); for (Object appliesToObject : appliesToContent) { LOG.debug("AppliesTo object type: " + appliesToObject.getClass().getName()); if (appliesToObject instanceof JAXBElement) { JAXBElement appliesToElement = (JAXBElement) appliesToObject; QName appliesToQName = appliesToElement.getName(); if (WSTrustConstants.ENDPOINT_REFERENCE_QNAME.equals(appliesToQName)) { EndpointReferenceType endpointReference = (EndpointReferenceType) appliesToElement .getValue(); expectedAudience = endpointReference.getAddress().getValue(); } } } } } Element tokenElement = WSSecuritySoapHandler.getToken(this.context); if (null == tokenElement) { throw new SecurityException("missing Token"); } LOG.debug("token element: " + tokenElement.getLocalName()); LOG.debug("expected audience: " + expectedAudience); ServletContext servletContext = (ServletContext) context.getMessageContext() .get(MessageContext.SERVLET_CONTEXT); IdentityProviderConfiguration identityProviderConfiguration = IdentityProviderConfigurationFactory .getInstance(servletContext); boolean valid; String reason = null; try { validateToken(tokenElement, expectedAudience, identityProviderConfiguration); valid = true; } catch (Exception e) { LOG.error("error validating SAML token: " + e.getMessage(), e); valid = false; reason = e.getMessage(); } RequestSecurityTokenResponseCollectionType responseCollection = this.objectFactory .createRequestSecurityTokenResponseCollectionType(); List<RequestSecurityTokenResponseType> requestSecurityTokenResponses = responseCollection .getRequestSecurityTokenResponse(); RequestSecurityTokenResponseType requestSecurityTokenResponse = this.objectFactory .createRequestSecurityTokenResponseType(); requestSecurityTokenResponses.add(requestSecurityTokenResponse); List<Object> rstsContent = requestSecurityTokenResponse.getAny(); rstsContent.add(this.objectFactory.createTokenType(WSTrustConstants.STATUS_TOKEN_TYPE)); StatusType status = this.objectFactory.createStatusType(); rstsContent.add(this.objectFactory.createStatus(status)); if (valid) { status.setCode(WSTrustConstants.VALID_STATUS_CODE); } else { status.setCode(WSTrustConstants.INVALID_STATUS_CODE); status.setReason(reason); } return responseCollection; }
From source file:com.formkiq.core.service.generator.docx4j.WorkflowOutputWordDocxTest.java
/** * Find Text {@link String} in {@link Object}. * @param obj {@link Object}//from w w w.java 2 s.c o m * @return {@link String} */ @SuppressWarnings("unused") private String getText(final Object obj) { JAXBElement<?> o = (JAXBElement<?>) obj; ClassFinder traverser = new ClassFinder(Text.class); new TraversalUtil(o.getValue(), traverser); Text object = (Text) traverser.results.get(0); return object.getValue(); }
From source file:be.fedict.eid.dss.model.bean.ServicesManagerSingletonBean.java
@SuppressWarnings("unchecked") public List<DigitalSignatureServiceProtocolType> getProtocolServices() { LOG.debug("getProtocolServices"); List<DigitalSignatureServiceProtocolType> protocolServices = new LinkedList<DigitalSignatureServiceProtocolType>(); Enumeration<URL> resources; try {// ww w.jav a2s .co m resources = getResources("META-INF/eid-dss-protocol.xml"); } catch (IOException e) { LOG.error("I/O error: " + e.getMessage(), e); return protocolServices; } Unmarshaller unmarshaller; try { JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); unmarshaller = jaxbContext.createUnmarshaller(); } catch (JAXBException e) { LOG.error("JAXB error: " + e.getMessage(), e); return protocolServices; } while (resources.hasMoreElements()) { URL resource = resources.nextElement(); LOG.debug("resource URL: " + resource.toString()); JAXBElement<DigitalSignatureServiceProtocolType> jaxbElement; try { jaxbElement = (JAXBElement<DigitalSignatureServiceProtocolType>) unmarshaller.unmarshal(resource); } catch (JAXBException e) { LOG.error("JAXB error: " + e.getMessage(), e); continue; } protocolServices.add(jaxbElement.getValue()); } return protocolServices; }
From source file:eu.dasish.annotation.backend.rest.AnnotationResourceTest.java
@Test public void testUpdateAnnotationBody() throws NotInDataBaseException, IOException { System.out.println("test updateAnnotationBody"); Annotation annotation = (new TestInstances("/backend/api")).getAnnotationOne(); final AnnotationBody ab = new AnnotationBody(); TextBody tb = new TextBody(); ab.setTextBody(tb);/*from w w w . j av a 2s . c o m*/ tb.setMimeType("text/plain"); tb.setBody("some text body l"); annotation.setBody(ab); final ResponseBody mockEnvelope = new ResponseBody(); final ActionList actionList = new ActionList(); mockEnvelope.setAnnotation(annotation); mockEnvelope.setActionList(actionList); annotationResource.setHttpServletRequest(mockRequest); mockRequest.setRemoteUser("twagoo@mpi.nl"); mockRequest.setContextPath("/backend"); mockRequest.setServletPath("/api"); final UUID externalId = UUID.fromString("00000000-0000-0000-0000-000000000021"); //final Number annotationID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.ANNOTATION); // (dbIntegrityService.canDo(Access.WRITE, principalID, annotationID)) { // int updatedRows = dbIntegrityService.updateAnnotationBody(annotationID, annotationBody); // return new ObjectFactory().createResponseBody(dbIntegrityService.makeAnnotationResponseEnvelope(annotationID)); mockeryRest.checking(new Expectations() { { oneOf(mockDbDispatcher).setResourcesPaths("/backend/api"); oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl"); will(returnValue(1)); oneOf(mockDbDispatcher).getResourceInternalIdentifier(externalId, Resource.ANNOTATION); will(returnValue(1)); oneOf(mockDbDispatcher).canDo(Access.WRITE, 1, 1, Resource.ANNOTATION); will(returnValue(true)); oneOf(mockDbDispatcher).updateAnnotationBody(1, ab); will(returnValue(1)); oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1); will(returnValue(mockEnvelope)); } }); JAXBElement<ResponseBody> result = annotationResource .updateAnnotationBody("00000000-0000-0000-0000-000000000021", ab); Annotation newAnnotation = result.getValue().getAnnotation(); assertEquals("text/plain", newAnnotation.getBody().getTextBody().getMimeType()); assertEquals("some text body l", newAnnotation.getBody().getTextBody().getBody()); }
From source file:eu.dasish.annotation.backend.rest.AnnotationResourceTest.java
@Test public void testUpdateAnnotationHeadline() throws NotInDataBaseException, IOException { System.out.println("test updateAnnotationHeadline"); Annotation annotation = (new TestInstances("/api")).getAnnotationOne(); final String newHeadline = "new Headline"; annotation.setHeadline(newHeadline); final ResponseBody mockEnvelope = new ResponseBody(); final ActionList actionList = new ActionList(); mockEnvelope.setAnnotation(annotation); mockEnvelope.setActionList(actionList); annotationResource.setHttpServletRequest(mockRequest); mockRequest.setRemoteUser("twagoo@mpi.nl"); mockRequest.setContextPath("/backend"); mockRequest.setServletPath("/api"); final UUID externalId = UUID.fromString("00000000-0000-0000-0000-000000000021"); mockeryRest.checking(new Expectations() { {//from ww w . ja v a 2 s . c om oneOf(mockDbDispatcher).setResourcesPaths("/backend/api"); oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl"); will(returnValue(1)); oneOf(mockDbDispatcher).getResourceInternalIdentifier(externalId, Resource.ANNOTATION); will(returnValue(1)); oneOf(mockDbDispatcher).canDo(Access.WRITE, 1, 1, Resource.ANNOTATION); will(returnValue(true)); oneOf(mockDbDispatcher).updateAnnotationHeadline(1, newHeadline); will(returnValue(1)); oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1); will(returnValue(mockEnvelope)); } }); JAXBElement<ResponseBody> result = annotationResource .updateAnnotationHeadline("00000000-0000-0000-0000-000000000021", newHeadline); Annotation newAnnotation = result.getValue().getAnnotation(); assertEquals("new Headline", newAnnotation.getHeadline()); }
From source file:org.pepstock.jem.rest.services.GfsManager.java
/** * Returns the list of file from a specific folder * @param type type of files//from www . j a va2 s .co m * @param request specific folder * @return list of files * @throws JemException if any exception occurs */ public GfsFileList getFilesList(GfsRequest request) throws JemException { // gets the web resource WebResource resource = getClient().getBaseWebResource(); // creates the returned object GenericType<JAXBElement<GfsFileList>> generic = new GenericType<JAXBElement<GfsFileList>>() { }; try { // creates the complete path of REST service, setting also the output format (XML) JAXBElement<GfsFileList> jaxbContact = resource.path(GfsManagerPaths.MAIN) .path(GfsManagerPaths.FILE_LIST).accept(MediaType.APPLICATION_XML).post(generic, request); // gets the returned object GfsFileList object = jaxbContact.getValue(); // checks if has got any exception // Exception must be saved as attribute of returned object if (object.hasException()) { throw new JemException(object.getExceptionMessage()); } return object; } catch (UniformInterfaceException e) { LogAppl.getInstance().debug(e.getMessage(), e); // checks http status if (e.getResponse().getStatus() != 204) { throw new JemException(e.getMessage(), e); } return null; } }
From source file:it.cnr.icar.eric.server.cms.CanonicalXMLFilteringService.java
@SuppressWarnings("unchecked") public ServiceOutput invoke(ServerRequestContext context, ServiceInput si, ServiceType service, InvocationController invocationController, UserType user) throws RegistryException { if (log.isTraceEnabled()) { log.trace("CanonicalXMLFilteringService.invoke()"); }//from w ww . j a va 2 s . c om ServiceOutput so = new ServiceOutput(); so.setOutput(context); RepositoryItem repositoryItem = si.getRepositoryItem(); String roId = si.getRegistryObject().getId(); ServerRequestContext outputContext = context; //new RequestContext(null); try { HashMap<String, String> params = new HashMap<String, String>(); params.put("subjectId", context.getUser().getId()); //First filter the RegistryObject metadata StreamSource input = getAsStreamSource(si.getRegistryObject()); StreamSource xslt = rm.getAsStreamSource(invocationController.getEoId()); //Specify empty value to indicate that only metadata should be transformed //in this first XSLT invocation. params.put("repositoryItem", ""); File output = runXSLT(input, xslt, getURIResolver(context), params); JAXBElement<RegistryObjectType> ebRegistryObject = (JAXBElement<RegistryObjectType>) bu.getJAXBContext() .createUnmarshaller().unmarshal(output); // take ComplexType from Element RegistryObjectType ebRegistryObjectType = ebRegistryObject.getValue(); //Replace input RegistryObject with output RegistryObject. outputContext.getQueryResults().remove(si.getRegistryObject()); outputContext.getQueryResults().add(ebRegistryObjectType); //Now filter the RepositoryItem content if any if (repositoryItem != null) { input = new StreamSource(repositoryItem.getDataHandler().getInputStream()); xslt = rm.getAsStreamSource(invocationController.getEoId()); params.put("repositoryItem", roId); output = runXSLT(input, xslt, getURIResolver(context), params); RepositoryItem outputRI = new RepositoryItemImpl(roId, new DataHandler(new FileDataSource(output))); //Replace input RepositoryItem with output RepositoryItem. outputContext.getRepositoryItemsMap().put(roId, outputRI); } // TODO: User should refer to "Service object for the // Content Management Service that generated the // Cataloged Content." outputContext.setUser(user); } catch (Exception e) { if (outputContext != context) { outputContext.rollback(); } throw new RegistryException(e); } so.setOutput(outputContext); // Setting this error list is redundant, but Content Validation Services // currently output a Boolean and a RegistryErrorList, so using // same mechanism to report errors from Content Filtering Services. so.setErrorList(outputContext.getErrorList()); if (outputContext != context) { outputContext.commit(); } return so; }
From source file:de.extra.client.plugins.responseprocessplugin.filesystem.FileSystemResultPackageDataResponseProcessPlugin.java
/** * /*from w ww. j ava 2s.c o m*/ * @param packagePlugIns * @return element Name aus der PackagePlugIns.DataSource mit dem Type File, * wenn Element nicht vorhanden ist, wird null zurckgeliefert */ private String extractIncomingFileNameFromDataSource(final AnyPlugInContainerType packagePlugIns) { String fileName = null; if (packagePlugIns != null) { final List<Object> plugins = packagePlugIns.getAny(); for (final Object plugin : plugins) { final JAXBElement<?> jaxbElement = (JAXBElement<?>) plugin; if (DataSource.class.isAssignableFrom(jaxbElement.getDeclaredType())) { final DataSource dataSource = DataSource.class.cast(jaxbElement.getValue()); final DataContainerType dataContainer = dataSource.getDataContainer(); // Strikte Validierung. Element DataSource ohne // DataContainer // ist in diesem Scenario nicht vereinbart Assert.notNull(dataContainer, "DataContainer from ElementDataSource is null"); if (DataContainerCode.FILE.equals(dataContainer.getType())) { if (fileName == null) { fileName = dataContainer.getName(); } else { throw new ExtraResponseProcessPluginRuntimeException( ExceptionCode.EXTRA_ILLEGAL_ACCESS_EXCEPTION, "Multiple DataContainer for DataSource found"); } } } } } return fileName; }
From source file:org.pepstock.jem.rest.services.GfsManager.java
/** * delete a file of a specific type/*from ww w . j a v a2 s . c o m*/ * @param type type of file * @param request file name * @throws JemException if any exception occurs */ public void delete(GfsRequest request) throws JemException { // gets the web resource WebResource resource = getClient().getBaseWebResource(); // creates the returned object GenericType<JAXBElement<ReturnedObject>> generic = new GenericType<JAXBElement<ReturnedObject>>() { }; try { // creates the complete path of REST service, setting also the output format (XML) JAXBElement<ReturnedObject> jaxbContact = resource.path(GfsManagerPaths.MAIN) .path(GfsManagerPaths.FILE_DELETE).accept(MediaType.APPLICATION_XML).post(generic, request); // gets the returned object ReturnedObject object = jaxbContact.getValue(); // checks if has got any exception // Exception must be saved as attribute of returned object if (object.hasException()) { throw new JemException(object.getExceptionMessage()); } } catch (UniformInterfaceException e) { LogAppl.getInstance().debug(e.getMessage(), e); // checks http status if (e.getResponse().getStatus() != 204) { throw new JemException(e.getMessage(), e); } } }