List of usage examples for javax.xml.bind JAXBElement getName
public QName getName()
From source file:com.evolveum.midpoint.prism.marshaller.BeanMarshaller.java
private XNode marshalHeterogeneousList(Object bean, SerializationContext ctx) throws SchemaException { // structurally similar to a specific path through marshalXmlTypeToMap Class<?> beanClass = bean.getClass(); QName propertyName = getHeterogeneousListPropertyName(beanClass); Method getter = inspector.findPropertyGetter(beanClass, propertyName.getLocalPart()); Object getterResult = getValue(bean, getter, propertyName.getLocalPart()); if (!(getterResult instanceof Collection)) { throw new IllegalStateException("Heterogeneous list property " + propertyName + " does not contain a collection but " + MiscUtil.getObjectName(getterResult)); }/* w w w . j av a 2 s .c o m*/ ListXNode xlist = new ListXNode(); for (Object value : (Collection) getterResult) { if (!(value instanceof JAXBElement)) { throw new IllegalStateException( "Heterogeneous list contains a value that is not a JAXBElement: " + value); } JAXBElement jaxbElement = (JAXBElement) value; Object realValue = jaxbElement.getValue(); if (realValue == null) { throw new IllegalStateException("Heterogeneous list contains a null value"); // TODO } QName typeName = inspector.determineTypeForClass(realValue.getClass()); XNode marshaled = marshallValue(realValue, typeName, false, ctx); marshaled.setElementName(jaxbElement.getName()); setExplicitTypeDeclarationIfNeededForHeteroList(marshaled, realValue); xlist.add(marshaled); } return xlist; }
From source file:de.ingrid.interfaces.csw.domain.filter.impl.LuceneFilterParser.java
/** * Build a piece of Lucene query with the specified Logical filter. * * @param logicOpsEl//from ww w . ja v a 2s . c o m * @return SpatialQuery * @throws CSWFilterException */ private SpatialQuery processLogicalOperator(JAXBElement<? extends LogicOpsType> logicOpsEl) throws CSWFilterException { List<SpatialQuery> subQueries = new ArrayList<SpatialQuery>(); StringBuilder queryBuilder = new StringBuilder(); List<Filter> filters = new ArrayList<Filter>(); String operator = logicOpsEl.getName().getLocalPart(); LogicOpsType logicOps = logicOpsEl.getValue(); if (logicOps instanceof BinaryLogicOpType) { BinaryLogicOpType binary = (BinaryLogicOpType) logicOps; queryBuilder.append('('); // process comparison operators: PropertyIsLike, IsNull, IsBetween, // ... for (JAXBElement<? extends ComparisonOpsType> el : binary.getComparisonOps()) { queryBuilder.append(this.processComparisonOperator(el)); queryBuilder.append(" ").append(operator.toUpperCase()).append(" "); } // process logical operators like AND, OR, ... for (JAXBElement<? extends LogicOpsType> el : binary.getLogicOps()) { boolean writeOperator = true; SpatialQuery sq = this.processLogicalOperator(el); String subQuery = sq.getQuery(); Filter subFilter = sq.getSpatialFilter(); // if the sub spatial query contains both term search and // spatial search we create a subQuery if ((subFilter != null && !subQuery.equals(defaultField)) || sq.getSubQueries().size() != 0 || (sq.getLogicalOperator() == SerialChainFilter.NOT && sq.getSpatialFilter() == null)) { subQueries.add(sq); writeOperator = false; } else { if (subQuery.equals("")) { writeOperator = false; } else { queryBuilder.append(subQuery); } if (subFilter != null) { filters.add(subFilter); } } if (writeOperator) { queryBuilder.append(" ").append(operator.toUpperCase()).append(" "); } else { writeOperator = true; } } // process spatial constraint : BBOX, Beyond, Overlaps, ... for (JAXBElement<? extends SpatialOpsType> el : binary.getSpatialOps()) { // for the spatial filter we don't need to write into the Lucene // query filters.add(this.processSpatialOperator(el)); } // remove the last Operator and add a ') ' int pos = queryBuilder.length() - (operator.length() + 2); if (pos > 0) { queryBuilder.delete(queryBuilder.length() - (operator.length() + 2), queryBuilder.length()); } queryBuilder.append(')'); } else if (logicOps instanceof UnaryLogicOpType) { UnaryLogicOpType unary = (UnaryLogicOpType) logicOps; // process comparison operator: PropertyIsLike, IsNull, IsBetween, // ... if (unary.getComparisonOps() != null) { queryBuilder.append(this.processComparisonOperator(unary.getComparisonOps())); } // process spatial constraint : BBOX, Beyond, Overlaps, ... else if (unary.getSpatialOps() != null) { filters.add(this.processSpatialOperator(unary.getSpatialOps())); } // process logical Operators like AND, OR, ... else if (unary.getLogicOps() != null) { SpatialQuery sq = this.processLogicalOperator(unary.getLogicOps()); String subQuery = sq.getQuery(); Filter subFilter = sq.getSpatialFilter(); if ((sq.getLogicalOperator() == SerialChainFilter.OR && subFilter != null && !subQuery.equals(defaultField)) || (sq.getLogicalOperator() == SerialChainFilter.NOT)) { subQueries.add(sq); } else { if (!subQuery.equals("")) { queryBuilder.append(subQuery); } if (subFilter != null) { filters.add(sq.getSpatialFilter()); } } } } String query = queryBuilder.toString(); if (query.equals("()")) { query = ""; } int logicalOperand = SerialChainFilter.valueOf(operator); Filter spatialFilter = this.getSpatialFilterFromList(logicalOperand, filters, query); SpatialQuery response = new SpatialQuery(query, spatialFilter, logicalOperand); response.setSubQueries(subQueries); return response; }
From source file:it.govpay.core.business.Pagamento.java
public AvviaTransazioneDTOResponse avviaTransazione(AvviaTransazioneDTO dto) throws GovPayException, ServiceException { GpContext ctx = GpThreadLocal.get(); List<Versamento> versamenti = new ArrayList<Versamento>(); for (Object v : dto.getVersamentoOrVersamentoRef()) { Versamento versamentoModel = null; if (v instanceof it.govpay.servizi.commons.Versamento) { it.govpay.servizi.commons.Versamento versamento = (it.govpay.servizi.commons.Versamento) v; ctx.log("rpt.acquisizioneVersamento", versamento.getCodApplicazione(), versamento.getCodVersamentoEnte()); versamentoModel = VersamentoUtils .toVersamentoModel((it.govpay.servizi.commons.Versamento) versamento, this); versamentoModel.setIuvProposto(versamento.getIuv()); } else {// w w w . j a v a 2 s. c o m it.govpay.servizi.commons.VersamentoKey versamento = (it.govpay.servizi.commons.VersamentoKey) v; String codDominio = null, codApplicazione = null, codVersamentoEnte = null, iuv = null, bundlekey = null, codUnivocoDebitore = null; Iterator<JAXBElement<String>> iterator = versamento.getContent().iterator(); while (iterator.hasNext()) { JAXBElement<String> element = iterator.next(); if (element.getName().equals(VersamentoUtils._VersamentoKeyBundlekey_QNAME)) { bundlekey = element.getValue(); } if (element.getName().equals(VersamentoUtils._VersamentoKeyCodUnivocoDebitore_QNAME)) { codUnivocoDebitore = element.getValue(); } if (element.getName().equals(VersamentoUtils._VersamentoKeyCodApplicazione_QNAME)) { codApplicazione = element.getValue(); } if (element.getName().equals(VersamentoUtils._VersamentoKeyCodDominio_QNAME)) { codDominio = element.getValue(); } if (element.getName().equals(VersamentoUtils._VersamentoKeyCodVersamentoEnte_QNAME)) { codVersamentoEnte = element.getValue(); } if (element.getName().equals(VersamentoUtils._VersamentoKeyIuv_QNAME)) { iuv = element.getValue(); } } it.govpay.core.business.Versamento versamentoBusiness = new it.govpay.core.business.Versamento( this); versamentoModel = versamentoBusiness.chiediVersamento(codApplicazione, codVersamentoEnte, bundlekey, codUnivocoDebitore, codDominio, iuv); } if (!versamentoModel.getUo(this).isAbilitato()) { throw new GovPayException( "Il pagamento non puo' essere avviato poiche' uno dei versamenti risulta associato ad una unita' operativa disabilitata [Uo:" + versamentoModel.getUo(this).getCodUo() + "].", EsitoOperazione.UOP_001, versamentoModel.getUo(this).getCodUo()); } if (!versamentoModel.getUo(this).getDominio(this).isAbilitato()) { throw new GovPayException( "Il pagamento non puo' essere avviato poiche' uno dei versamenti risulta associato ad un dominio disabilitato [Dominio:" + versamentoModel.getUo(this).getDominio(this).getCodDominio() + "].", EsitoOperazione.DOM_001, versamentoModel.getUo(this).getDominio(this).getCodDominio()); } versamenti.add(versamentoModel); } Anagrafica versanteModel = VersamentoUtils.toAnagraficaModel(dto.getVersante()); boolean aggiornaSeEsiste = dto.getAggiornaSeEsisteB() != null ? dto.getAggiornaSeEsisteB() : true; List<Rpt> rpts = avviaTransazione(versamenti, dto.getPortale(), dto.getCanale(), dto.getIbanAddebito(), versanteModel, dto.getAutenticazione(), dto.getUrlRitorno(), aggiornaSeEsiste); AvviaTransazioneDTOResponse response = new AvviaTransazioneDTOResponse(); response.setCodSessione(rpts.get(0).getCodSessione()); response.setPspRedirectURL(rpts.get(0).getPspRedirectURL()); for (Rpt rpt : rpts) { RifTransazione rifTransazione = response.new RifTransazione(); rifTransazione.setCcp(rpt.getCcp()); rifTransazione.setCodApplicazione(rpt.getVersamento(this).getApplicazione(this).getCodApplicazione()); rifTransazione.setCodDominio(rpt.getCodDominio()); rifTransazione.setCodVersamentoEnte(rpt.getVersamento(this).getCodVersamentoEnte()); rifTransazione.setIuv(rpt.getIuv()); response.getRifTransazioni().add(rifTransazione); } return response; }
From source file:at.gv.egovernment.moa.id.auth.servlet.PEPSConnectorServlet.java
/** * Handles the reception of a STORK response message * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) *//* w ww . j av a 2s.c o m*/ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String pendingRequestID = null; try { Logger.warn(getClass().getName() + " is deprecated and should not be used any more."); Logger.info("PEPSConnector Servlet invoked, expecting C-PEPS message."); Logger.debug("This ACS endpoint is: " + HTTPUtils.getBaseURL(request)); super.setNoCachingHeadersInHttpRespone(request, response); Logger.trace("No Caching headers set for HTTP response"); //check if https or only http super.checkIfHTTPisAllowed(request.getRequestURL().toString()); Logger.debug("Beginning to extract SAMLResponse out of HTTP Request"); //extract STORK Response from HTTP Request //Decodes SAML Response byte[] decSamlToken; try { decSamlToken = PEPSUtil.decodeSAMLToken(request.getParameter("SAMLResponse")); Logger.debug("SAMLResponse: " + new String(decSamlToken)); } catch (NullPointerException e) { Logger.error("Unable to retrieve STORK Response", e); throw new MOAIDException("stork.04", null); } //Get SAMLEngine instance STORKSAMLEngine engine = STORKSAMLEngine.getInstance("outgoing"); STORKAuthnResponse authnResponse = null; try { //validate SAML Token Logger.debug("Starting validation of SAML response"); authnResponse = engine.validateSTORKAuthnResponse(decSamlToken, (String) request.getRemoteHost()); Logger.info("SAML response succesfully verified!"); } catch (STORKSAMLEngineException e) { Logger.error("Failed to verify STORK SAML Response", e); throw new MOAIDException("stork.05", null); } Logger.info("STORK SAML Response message succesfully extracted"); Logger.debug("STORK response: "); Logger.debug(authnResponse.toString()); Logger.debug("Trying to find MOA Session-ID ..."); //String moaSessionID = request.getParameter(PARAM_SESSIONID); //first use SAML2 relayState String moaSessionID = request.getParameter("RelayState"); // escape parameter strings moaSessionID = StringEscapeUtils.escapeHtml(moaSessionID); //check if SAML2 relaystate includes a MOA sessionID if (StringUtils.isEmpty(moaSessionID)) { //if relaystate is emtpty, use SAML response -> inResponseTo element as session identifier moaSessionID = authnResponse.getInResponseTo(); moaSessionID = StringEscapeUtils.escapeHtml(moaSessionID); if (StringUtils.isEmpty(moaSessionID)) { //No authentication session has been started before Logger.error("MOA-SessionID was not found, no previous AuthnRequest had been started"); Logger.debug("PEPSConnectorURL was: " + request.getRequestURL()); throw new AuthenticationException("auth.02", new Object[] { moaSessionID }); } else Logger.trace( "Use MOA SessionID " + moaSessionID + " from AuthnResponse->inResponseTo attribute."); } else //Logger.trace("MOA SessionID " + moaSessionID + " is found in http GET parameter."); Logger.trace("MOA SessionID " + moaSessionID + " is found in SAML2 relayState."); /*INFO!!!! * SAML message IDs has an different format then MOASessionIDs * This is only a workaround because many PEPS does not support SAML2 relayState or * MOASessionID as AttributConsumerServiceURL GET parameter */ // if (!ParamValidatorUtils.isValidSessionID(moaSessionID)) // throw new WrongParametersException("VerifyAuthenticationBlock", PARAM_SESSIONID, "auth.12"); pendingRequestID = AuthenticationSessionStoreage.getPendingRequestID(moaSessionID); //load MOASession from database AuthenticationSession moaSession = AuthenticationServer.getSession(moaSessionID); //change MOASessionID moaSessionID = AuthenticationSessionStoreage.changeSessionID(moaSession); Logger.info("Found MOA sessionID: " + moaSessionID); String statusCodeValue = authnResponse.getStatusCode(); if (!statusCodeValue.equals(StatusCode.SUCCESS_URI)) { Logger.error("Received ErrorResponse from PEPS: " + statusCodeValue); throw new MOAIDException("stork.06", new Object[] { statusCodeValue }); } Logger.info("Got SAML response with authentication success message."); Logger.debug("MOA session is still valid"); STORKAuthnRequest storkAuthnRequest = moaSession.getStorkAuthnRequest(); if (storkAuthnRequest == null) { Logger.error( "Could not find any preceeding STORK AuthnRequest to this MOA session: " + moaSessionID); throw new MOAIDException("stork.07", null); } OAAuthParameter oaParam = AuthConfigurationProvider.getInstance() .getOnlineApplicationParameter(moaSession.getPublicOAURLPrefix()); if (oaParam == null) throw new AuthenticationException("auth.00", new Object[] { moaSession.getPublicOAURLPrefix() }); //================== Check QAA level start ==================== int reqQaa = -1; int authQaa = -1; String authQaaStr = null; try { reqQaa = storkAuthnRequest.getQaa(); //TODO: found better solution, but QAA Level in response could be not supported yet try { authQaaStr = authnResponse.getAssertions().get(0).getAuthnStatements().get(0).getAuthnContext() .getAuthnContextClassRef().getAuthnContextClassRef(); moaSession.setQAALevel(authQaaStr); } catch (Throwable e) { Logger.warn("STORK QAA-Level is not found in AuthnResponse. Set QAA Level to requested level"); moaSession.setQAALevel(PVPConstants.STORK_QAA_PREFIX + oaParam.getQaaLevel()); authQaaStr = PVPConstants.STORK_QAA_PREFIX + oaParam.getQaaLevel(); } if (authQaaStr != null)//Check value only if set { authQaa = Integer.valueOf(authQaaStr.substring(PVPConstants.STORK_QAA_PREFIX.length())); // authQaa = Integer.valueOf(authQaaStr); if (reqQaa > authQaa) { Logger.warn("Requested QAA level does not match to authenticated QAA level"); throw new MOAIDException("stork.21", new Object[] { reqQaa, authQaa }); } } } catch (MOAIDException e) { throw e; } catch (Exception e) { if (Logger.isDebugEnabled()) Logger.warn("STORK QAA Level evaluation error", e); else Logger.warn("STORK QAA Level evaluation error (ErrorMessage=" + e.getMessage() + ")"); throw new MOAIDException("stork.21", new Object[] { reqQaa, authQaa }); } //================== Check QAA level end ==================== Logger.debug("Found a preceeding STORK AuthnRequest to this MOA session: " + moaSessionID); ////////////// incorporate gender from parameters if not in stork response IPersonalAttributeList attributeList = authnResponse.getPersonalAttributeList(); // but first, check if we have a representation case if (STORKResponseProcessor.hasAttribute("mandateContent", attributeList) || STORKResponseProcessor.hasAttribute("representative", attributeList) || STORKResponseProcessor.hasAttribute("represented", attributeList)) { // in a representation case... moaSession.setUseMandate("true"); // and check if we have the gender value PersonalAttribute gender = attributeList.get("gender"); // TODO Do we need to check gender value if there is no representation case? if (null == gender) { String gendervalue = (String) request.getParameter("gender"); if (null != gendervalue) { gender = new PersonalAttribute(); gender.setName("gender"); ArrayList<String> tmp = new ArrayList<String>(); tmp.add(gendervalue); gender.setValue(tmp); authnResponse.getPersonalAttributeList().add(gender); } } } ////////////////////////////////////////////////////////////////////////// Logger.debug("Starting extraction of signedDoc attribute"); //extract signed doc element and citizen signature String citizenSignature = null; try { String signatureInfo = authnResponse.getPersonalAttributeList().get("signedDoc").getValue().get(0); // TODO ERROR HANDLING Logger.debug("signatureInfo:" + signatureInfo); SignResponse dssSignResponse = (SignResponse) ApiUtils .unmarshal(new StreamSource(new java.io.StringReader(signatureInfo))); // fetch signed doc DataSource ds = null; try { ds = LightweightSourceResolver.getDataSource(dssSignResponse); } catch (Exception e) { e.printStackTrace(); } if (ds == null) { //Normal DocumentServices return a http-page, but the SI DocumentService returns HTTP error 500 //which results in an exception and ds==null //try to load document from documentservice citizenSignature = loadDocumentFromDocumentService(dssSignResponse); //throw new ApiUtilsException("No datasource found in response"); } else { InputStream incoming = ds.getInputStream(); citizenSignature = IOUtils.toString(incoming); incoming.close(); Logger.debug("citizenSignature:" + citizenSignature); if (isDocumentServiceUsed(citizenSignature) == true) { citizenSignature = loadDocumentFromDocumentService(dssSignResponse); // Logger.debug("Loading document from DocumentService."); // String url = getDtlUrlFromResponse(dssSignResponse); // //get Transferrequest // String transferRequest = getDocTransferRequest(dssSignResponse.getDocUI(), url); // //Load document from DocumentService // byte[] data = getDocumentFromDtl(transferRequest, url); // citizenSignature = new String(data, "UTF-8"); // Logger.debug("Overridung citizenSignature with:"+citizenSignature); } } JAXBContext ctx = JAXBContext.newInstance(SignatureType.class.getPackage().getName()); SignatureType root = ((JAXBElement<SignatureType>) ctx.createUnmarshaller() .unmarshal(IOUtils.toInputStream(citizenSignature))).getValue(); // memorize signature into authblock moaSession.setAuthBlock(citizenSignature); // extract certificate for (Object current : root.getKeyInfo().getContent()) if (((JAXBElement<?>) current).getValue() instanceof X509DataType) { for (Object currentX509Data : ((JAXBElement<X509DataType>) current).getValue() .getX509IssuerSerialOrX509SKIOrX509SubjectName()) { JAXBElement<?> casted = ((JAXBElement<?>) currentX509Data); if (casted.getName().getLocalPart().equals("X509Certificate")) { moaSession.setSignerCertificate( new X509Certificate(((String) casted.getValue()).getBytes("UTF-8"))); break; } } } } catch (Throwable e) { Logger.error("Could not extract citizen signature from C-PEPS", e); throw new MOAIDException("stork.09", null); } Logger.debug("Foregin Citizen signature successfully extracted from STORK Assertion (signedDoc)"); Logger.debug("Citizen signature will be verified by SZR Gateway!"); Logger.debug("fetching OAParameters from database"); // //read configuration paramters of OA // AuthenticationSession moasession; // try { // moasession = AuthenticationSessionStoreage.getSession(moaSessionID); // } catch (MOADatabaseException e2) { // Logger.error("could not retrieve moa session"); // throw new AuthenticationException("auth.01", null); // } // OAAuthParameter oaParam = AuthConfigurationProvider.getInstance().getOnlineApplicationParameter(moaSession.getPublicOAURLPrefix()); // if (oaParam == null) // throw new AuthenticationException("auth.00", new Object[] { moaSession.getPublicOAURLPrefix() }); // retrieve target //TODO: check in case of SSO!!! String targetType = null; if (oaParam.getBusinessService()) { String id = oaParam.getIdentityLinkDomainIdentifier(); if (id.startsWith(AuthenticationSession.REGISTERANDORDNR_PREFIX_)) targetType = id; else targetType = AuthenticationSession.REGISTERANDORDNR_PREFIX_ + moaSession.getDomainIdentifier(); } else { targetType = AuthenticationSession.TARGET_PREFIX_ + oaParam.getTarget(); } IdentityLink identityLink = null; try { AuthConfigurationProvider config = AuthConfigurationProvider.getInstance(); if (config.isStorkFakeIdLActive() && config.getStorkFakeIdLCountries().contains(storkAuthnRequest.getCitizenCountryCode())) { // create fake IdL // - fetch IdL template from resources InputStream s = PEPSConnectorServlet.class .getResourceAsStream("/resources/xmldata/fakeIdL_IdL_template.xml"); Element idlTemplate = DOMUtils.parseXmlValidating(s); identityLink = new IdentityLinkAssertionParser(idlTemplate).parseIdentityLink(); // replace data Element idlassertion = identityLink.getSamlAssertion(); // - set bpk/wpbk; Node prIdentification = XPathUtils.selectSingleNode(idlassertion, IdentityLinkAssertionParser.PERSON_IDENT_VALUE_XPATH); if (!STORKResponseProcessor.hasAttribute("eIdentifier", attributeList)) throw new STORKException("eIdentifier is missing"); String eIdentifier = STORKResponseProcessor.getAttributeValue("eIdentifier", attributeList, false); prIdentification.getFirstChild().setNodeValue(eIdentifier); // - set last name Node prFamilyName = XPathUtils.selectSingleNode(idlassertion, IdentityLinkAssertionParser.PERSON_FAMILY_NAME_XPATH); if (!STORKResponseProcessor.hasAttribute("surname", attributeList)) throw new STORKException("surname is missing"); String familyName = STORKResponseProcessor.getAttributeValue("surname", attributeList, false); prFamilyName.getFirstChild().setNodeValue(familyName); // - set first name Node prGivenName = XPathUtils.selectSingleNode(idlassertion, IdentityLinkAssertionParser.PERSON_GIVEN_NAME_XPATH); if (!STORKResponseProcessor.hasAttribute("givenName", attributeList)) throw new STORKException("givenName is missing"); String givenName = STORKResponseProcessor.getAttributeValue("givenName", attributeList, false); prGivenName.getFirstChild().setNodeValue(givenName); // - set date of birth Node prDateOfBirth = XPathUtils.selectSingleNode(idlassertion, IdentityLinkAssertionParser.PERSON_DATE_OF_BIRTH_XPATH); if (!STORKResponseProcessor.hasAttribute("dateOfBirth", attributeList)) throw new STORKException("dateOfBirth is missing"); String dateOfBirth = STORKResponseProcessor.getAttributeValue("dateOfBirth", attributeList, false); prDateOfBirth.getFirstChild().setNodeValue(dateOfBirth); identityLink = new IdentityLinkAssertionParser(idlassertion).parseIdentityLink(); //resign IDL IdentityLinkReSigner identitylinkresigner = IdentityLinkReSigner.getInstance(); Element resignedilAssertion = identitylinkresigner.resignIdentityLink( identityLink.getSamlAssertion(), config.getStorkFakeIdLResigningKey()); identityLink = new IdentityLinkAssertionParser(resignedilAssertion).parseIdentityLink(); } else { //contact SZR Gateway Logger.debug("Starting connecting SZR Gateway"); identityLink = STORKResponseProcessor.connectToSZRGateway( authnResponse.getPersonalAttributeList(), oaParam.getFriendlyName(), targetType, null, oaParam.getMandateProfiles(), citizenSignature); } } catch (STORKException e) { // this is really nasty but we work against the system here. We are supposed to get the gender attribute from // stork. If we do not, we cannot register the person in the ERnP - we have to have the // gender for the represented person. So here comes the dirty hack. if (e.getCause() instanceof STORKException && e.getCause().getMessage().equals("gender not found in response")) { try { Logger.trace("Initialize VelocityEngine..."); VelocityEngine velocityEngine = VelocityProvider.getClassPathVelocityEngine(); Template template = velocityEngine.getTemplate("/resources/templates/fetchGender.html"); VelocityContext context = new VelocityContext(); context.put("SAMLResponse", request.getParameter("SAMLResponse")); context.put("action", request.getRequestURL()); StringWriter writer = new StringWriter(); template.merge(context, writer); response.getOutputStream().write(writer.toString().getBytes("UTF-8")); } catch (Exception e1) { Logger.error("Error sending gender retrival form.", e1); // httpSession.invalidate(); throw new MOAIDException("stork.10", null); } return; } Logger.error("Error connecting SZR Gateway", e); throw new MOAIDException("stork.10", null); } Logger.debug("SZR communication was successfull"); if (identityLink == null) { Logger.error("SZR Gateway did not return an identity link."); throw new MOAIDException("stork.10", null); } moaSession.setForeigner(true); Logger.info("Received Identity Link from SZR Gateway"); moaSession.setIdentityLink(identityLink); Logger.debug("Adding addtional STORK attributes to MOA session"); moaSession.setStorkAttributes(authnResponse.getPersonalAttributeList()); Logger.debug("Add full STORK AuthnResponse to MOA session"); moaSession.setStorkAuthnResponse(request.getParameter("SAMLResponse")); //We don't have BKUURL, setting from null to "Not applicable" moaSession.setBkuURL("Not applicable (STORK Authentication)"); // free for single use moaSession.setAuthenticatedUsed(false); // stork did the authentication step moaSession.setAuthenticated(true); // //TODO: found better solution, but QAA Level in response could be not supported yet // try { // // moaSession.setQAALevel(authnResponse.getAssertions().get(0). // getAuthnStatements().get(0).getAuthnContext(). // getAuthnContextClassRef().getAuthnContextClassRef()); // // } catch (Throwable e) { // Logger.warn("STORK QAA-Level is not found in AuthnResponse. Set QAA Level to requested level"); // moaSession.setQAALevel(PVPConstants.STORK_QAA_PREFIX + oaParam.getQaaLevel()); // // } //session is implicit stored in changeSessionID!!!! String newMOASessionID = AuthenticationSessionStoreage.changeSessionID(moaSession); Logger.info("Changed MOASession " + moaSessionID + " to Session " + newMOASessionID); //redirect String redirectURL = null; redirectURL = new DataURLBuilder().buildDataURL(moaSession.getAuthURL(), ModulUtils.buildAuthURL(moaSession.getModul(), moaSession.getAction(), pendingRequestID), newMOASessionID); redirectURL = response.encodeRedirectURL(redirectURL); // response.setContentType("text/html"); // response.setStatus(302); // response.addHeader("Location", redirectURL); response.sendRedirect(redirectURL); Logger.info("REDIRECT TO: " + redirectURL); } catch (AuthenticationException e) { handleError(null, e, request, response, pendingRequestID); } catch (MOAIDException e) { handleError(null, e, request, response, pendingRequestID); } catch (Exception e) { Logger.error("PEPSConnector has an interal Error.", e); } finally { ConfigurationDBUtils.closeSession(); } }
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
private <T extends Containerable> PrismContainer<T> unmarshalSingleValueContainer(JAXBElement<T> element) throws JAXBException, SchemaException { if (element == null) { return null; }/* w w w . java 2s. com*/ T value = element.getValue(); // this is a bit tricky - we have to create a container and put the newly obtained value into it PrismContainerValue<T> containerValue = value.asPrismContainerValue(); containerValue.revive(prismContext); PrismContainerDefinition definition = prismContext.getSchemaRegistry() .findContainerDefinitionByElementName(element.getName()); if (definition == null) { throw new IllegalStateException( "There's no container definition for element name " + element.getName()); } containerValue.applyDefinition(definition, false); PrismContainer container = definition.instantiate(); container.add(containerValue); return container; }
From source file:com.evolveum.midpoint.prism.parser.PrismBeanConverter.java
private void checkJaxbElementConsistence(Collection<Object> collection) throws SchemaException { QName elementName = null;//from w w w . j a v a 2 s . c o m for (Object object : collection) { if (!(object instanceof JAXBElement)) { continue; } JAXBElement element = (JAXBElement) object; if (elementName == null) { elementName = element.getName(); } else { if (!QNameUtil.match(elementName, element.getName())) { String m = "Mixing incompatible element names in one property: " + elementName + " and " + element.getName(); if (mode != XNodeProcessorEvaluationMode.COMPAT) { throw new SchemaException(m); } else { LOGGER.warn("{}", m); } } } } }
From source file:com.evolveum.midpoint.prism.marshaller.BeanUnmarshaller.java
private void checkJaxbElementConsistence(Collection<Object> collection, ParsingContext pc) throws SchemaException { QName elementName = null;/* ww w. ja v a 2 s. c o m*/ for (Object object : collection) { if (!(object instanceof JAXBElement)) { continue; } JAXBElement element = (JAXBElement) object; if (elementName == null) { elementName = element.getName(); } else { if (!QNameUtil.match(elementName, element.getName())) { String m = "Mixing incompatible element names in one property: " + elementName + " and " + element.getName(); if (pc.isStrict()) { throw new SchemaException(m); } else { pc.warn(LOGGER, m); } } } } }
From source file:com.evolveum.midpoint.prism.parser.XNodeProcessor.java
public RootXNode serializeAtomicValue(JAXBElement<?> element) throws SchemaException { Validate.notNull(element);//w w w . j a v a 2 s .c om return serializeAtomicValue(element.getValue(), element.getName(), null); }
From source file:com.evolveum.midpoint.testing.model.client.sample.AbstractTestForExchangeConnector.java
protected Map<String, Object> getAttributesAsMap(ShadowType shadowType) { Map<String, Object> rv = new HashMap<>(); ShadowAttributesType attributes = shadowType.getAttributes(); for (Object item : attributes.getAny()) { if (item instanceof Element) { Element e = (Element) item; put(rv, e.getLocalName(), e.getTextContent()); } else if (item instanceof JAXBElement) { JAXBElement je = (JAXBElement) item; put(rv, je.getName().getLocalPart(), je.getValue()); } else {//from w w w.ja v a 2 s . c o m // nothing to do here } } return rv; }
From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.ApplicationManagement.java
private List<Adapter> getAdapterServices() { List<Adapter> result = new ArrayList<Adapter>(); for (JAXBElement<? extends ServiceType> jaxbElement : application.getServices().getBaseService()) { if (jaxbElement.getName().getLocalPart().equals("adapter")) { result.add((Adapter) jaxbElement.getValue()); }/*from w w w . j a va 2s .com*/ } return result; }