List of usage examples for org.springframework.context MessageSource getMessage
String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException;
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for//from w ww .j av a 2 s . c om * {@link AUSERVICESAML#checkAttributeValues(EIDASAuthnRequest, String)}. * Testing attribute list without all the mandatory attributes. Must throws a * {@link EIDASServiceException}. */ @Test(expected = EIDASServiceException.class) public void testCheckMandatoryAttributesMissingMand() { final AUSERVICESAML auconnectorsaml = provideauservicesaml(); AUTH_DATA.setPersonalAttributeList(ATTR_LIST_VALUES_MISSING); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auconnectorsaml.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auconnectorsaml.setLoggerBean(mockLoggerBean); auconnectorsaml.setSamlEngineFactory(new EidasSamlEngineFactory()); auconnectorsaml.checkMandatoryAttributes(AUTH_DATA, TestingConstants.USER_IP_CONS.toString()); }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for//from ww w .j a v a 2s.c om * {@link AUSERVICESAML#generateErrorAuthenticationResponse(EIDASAuthnRequest, String, String, String, String, boolean)} * . Testing an empty {@link EIDASAuthnRequest} with audit on. Must throws a * {@link InternalErrorEIDASException}. */ @Test(expected = InternalErrorEIDASException.class) public void testGenerateErrorAuthenticationResponseEmptyAuthDataAuditable() { final AUSERVICESAML auservice = provideauservicesaml(); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auservice.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auservice.setLoggerBean(mockLoggerBean); auservice.setSamlEngineFactory(new EidasSamlEngineFactory()); auservice.generateErrorAuthenticationResponse(EMPTY_AUTH_DATA, TestingConstants.ERROR_CODE_CONS.toString(), TestingConstants.SUB_ERROR_CODE_CONS.toString(), TestingConstants.ERROR_MESSAGE_CONS.toString(), TestingConstants.USER_IP_CONS.toString(), true); }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for//w w w . java 2s . c o m * {@link AUSERVICESAML#generateErrorAuthenticationResponse(EIDASAuthnRequest, String, String, String, String, boolean)} * . Testing an empty {@link EIDASAuthnRequest} with audit off. Must throws a * {@link InternalErrorEIDASException}. */ @Test(expected = InternalErrorEIDASException.class) public void testGenerateErrorAuthenticationResponseEmptyAuthData() { final AUSERVICESAML auconnectorsaml = provideauservicesaml(); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auconnectorsaml.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auconnectorsaml.setLoggerBean(mockLoggerBean); auconnectorsaml.setSamlEngineFactory(new EidasSamlEngineFactory()); auconnectorsaml.generateErrorAuthenticationResponse(EMPTY_AUTH_DATA, TestingConstants.ERROR_CODE_CONS.toString(), TestingConstants.SUB_ERROR_CODE_CONS.toString(), TestingConstants.ERROR_MESSAGE_CONS.toString(), TestingConstants.USER_IP_CONS.toString(), false); }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for//from www .j a v a 2 s .c o m * {@link AUSERVICESAML#generateErrorAuthenticationResponse(EIDASAuthnRequest, String, String, String, String, boolean)} * . Testing with audit on. Must return a byte[]. */ @Test() public void testGenerateErrorAuthenticationResponseAuditable() { final AUSERVICESAML auconnectorsaml = provideauservicesaml(); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auconnectorsaml.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auconnectorsaml.setLoggerBean(mockLoggerBean); auconnectorsaml.setSamlEngineFactory(new EidasSamlEngineFactory()); assertTrue(auconnectorsaml.generateErrorAuthenticationResponse(AUTH_DATA, TestingConstants.ERROR_CODE_CONS.toString(), TestingConstants.SUB_ERROR_CODE_CONS.toString(), TestingConstants.ERROR_MESSAGE_CONS.toString(), TestingConstants.USER_IP_CONS.toString(), true).length > 0); }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for/*from w w w.ja v a2 s . com*/ * {@link AUSERVICESAML#generateErrorAuthenticationResponse(EIDASAuthnRequest, String, String, String, String, boolean)} * . Must return a byte[]. */ @Test() public void testGenerateErrorAuthenticationResponse() { final AUSERVICESAML auconnectorsaml = provideauservicesaml(); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auconnectorsaml.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auconnectorsaml.setLoggerBean(mockLoggerBean); auconnectorsaml.setSamlEngineFactory(new EidasSamlEngineFactory()); assertTrue(auconnectorsaml.generateErrorAuthenticationResponse(AUTH_DATA, TestingConstants.ERROR_CODE_CONS.toString(), TestingConstants.SUB_ERROR_CODE_CONS.toString(), TestingConstants.ERROR_MESSAGE_CONS.toString(), TestingConstants.USER_IP_CONS.toString(), false).length > 0); }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for//ww w. j a va2s . co m * {@link AUSERVICESAML#checkAttributeValues(EIDASAuthnRequest, String)}. * Testing {@link EIDASAuthnRequest} value must return {@link EIDASServiceException}. */ @Test(expected = EIDASServiceException.class) public void testCheckAttributeValuesFalseValue() { final AUSERVICESAML auservice = provideauservicesaml(); final ITranslatorService mockSpecific = mock(ITranslatorService.class); when(mockSpecific.checkAttributeValues(AUTH_DATA)).thenReturn(false); auservice.setSpecificNode(mockSpecific); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auservice.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auservice.setLoggerBean(mockLoggerBean); auservice.setSamlEngineFactory(new EidasSamlEngineFactory()); auservice.checkAttributeValues(AUTH_DATA, TestingConstants.USER_IP_CONS.toString()); }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for/*from w w w . ja v a 2 s. com*/ * {@link AUSERVICESAML#processAuthenticationRequest(byte[], IEIDASSession, String) * )}. Testing invalid max qaalevel in class. Must return and * {@link EIDASServiceException}. */ @Test public void testProcessAuthenticationRequestFailMaxQAALevel() { final AUSERVICESAML auconnectorsaml = provideauservicesaml(); final byte[] saml = auconnectorsaml.getSAMLToken(SAML_TOKEN); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auconnectorsaml.setMessageSource(mockMessages); final AUSERVICEUtil auserviceutil = new AUSERVICEUtil(); auserviceutil.setConcurrentMapService(new ConcurrentMapServiceDefaultImpl()); auserviceutil.setAntiReplayCache(auserviceutil.getConcurrentMapService().getNewAntiReplayCache()); auserviceutil.setConfigs(CONFIGS); auserviceutil.flushReplayCache(); auconnectorsaml.setServiceUtil(auserviceutil); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auconnectorsaml.setLoggerBean(mockLoggerBean); auconnectorsaml.setSamlEngineFactory(new EidasSamlEngineFactory()); final IEIDASSession session = mock(IEIDASSession.class); auconnectorsaml.setCountryCode(TestingConstants.LOCAL_CONS.toString()); try { EIDASAuthnRequest req = auconnectorsaml.processAuthenticationRequest(saml, session, TestingConstants.USER_IP_CONS.toString()); assertNotNull(req.getEidasLoA()); } catch (EIDASServiceException exc) { } }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * Test method for//w ww . j a v a 2s . com * {@link AUSERVICESAML#processAuthenticationRequest(byte[], IEIDASSession, String) * )}. Must succeed. */ @Test public void testProcessAuthenticationRequest() { // Instantiate the util service for anti replay check final AUSERVICEUtil auserviceutil = new AUSERVICEUtil(); auserviceutil.setConcurrentMapService(new ConcurrentMapServiceDefaultImpl()); auserviceutil.setAntiReplayCache(auserviceutil.getConcurrentMapService().getNewAntiReplayCache()); auserviceutil.flushReplayCache(); CONFIGS.setProperty(EIDASValues.NODE_SUPPORT_EIDAS_MESSAGE_FORMAT_ONLY.toString(), "false"); auserviceutil.setConfigs(CONFIGS); final AUSERVICESAML auconnectorsaml = provideauservicesaml(); auconnectorsaml.setServiceUtil(auserviceutil); final byte[] saml = auconnectorsaml.getSAMLToken(SAML_TOKEN); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auconnectorsaml.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auconnectorsaml.setLoggerBean(mockLoggerBean); auconnectorsaml.setSamlEngineFactory(new EidasSamlEngineFactory()); final IEIDASSession session = mock(IEIDASSession.class); auconnectorsaml.setCountryCode(TestingConstants.LOCAL_CONS.toString()); auconnectorsaml.setMaxQAA(TestingConstants.MAX_QAA_CONS.intValue()); auconnectorsaml.setMaxQAAlevel(TestingConstants.MAX_QAA_CONS.intValue()); auconnectorsaml.setMinQAA(TestingConstants.MIN_QAA_CONS.intValue()); auconnectorsaml.processAuthenticationRequest(saml, session, TestingConstants.USER_IP_CONS.toString()); }
From source file:eu.eidas.node.auth.service.tests.AUSERVICESAMLTestCase.java
/** * test the EIDAS only mode cause an error when trying to generate Service authn request *///from www .j av a 2 s . c o m @Test(expected = InternalErrorEIDASException.class) public void testGenerateStorkSAMLRequestInEidasOnlyMode() { // Instantiate the util service for anti replay check final AUSERVICEUtil auserviceutil = new AUSERVICEUtil(); // Support to eIDAS message format only auserviceutil.setConcurrentMapService(new ConcurrentMapServiceDefaultImpl()); auserviceutil.setAntiReplayCache(auserviceutil.getConcurrentMapService().getNewAntiReplayCache()); auserviceutil.flushReplayCache(); CONFIGS.setProperty(EIDASValues.NODE_SUPPORT_EIDAS_MESSAGE_FORMAT_ONLY.toString(), "true"); auserviceutil.setConfigs(CONFIGS); final AUSERVICESAML auservicesaml = provideauservicesaml(); auservicesaml.setServiceUtil(auserviceutil); final byte[] saml = auservicesaml.getSAMLToken(SAML_TOKEN); final MessageSource mockMessages = mock(MessageSource.class); when(mockMessages.getMessage(anyString(), (Object[]) any(), (Locale) any())) .thenReturn(TestingConstants.ERROR_MESSAGE_CONS.toString()); auservicesaml.setMessageSource(mockMessages); final IEIDASLogger mockLoggerBean = mock(IEIDASLogger.class); auservicesaml.setLoggerBean(mockLoggerBean); auservicesaml.setSamlEngineFactory(new EidasSamlEngineFactory()); final IEIDASSession session = mock(IEIDASSession.class); auservicesaml.setCountryCode(TestingConstants.LOCAL_CONS.toString()); auservicesaml.setMaxQAA(TestingConstants.MAX_QAA_CONS.intValue()); auservicesaml.setMaxQAAlevel(TestingConstants.MAX_QAA_CONS.intValue()); auservicesaml.setMinQAA(TestingConstants.MIN_QAA_CONS.intValue()); auservicesaml.processAuthenticationRequest(saml, session, TestingConstants.USER_IP_CONS.toString()); }
From source file:net.mlw.vlh.web.tag.FocusStatusTag.java
/** * * @param info//from w ww . ja va2 s. c o m * @param message * @param local * @param rootTag * @return * @throws NoSuchMessageException * @throws JspException */ private StringBuffer generateFocusStatus(ValueListInfo info, MessageSource message, Locale local, ValueListSpaceTag rootTag) throws NoSuchMessageException, JspException { StringBuffer sb = new StringBuffer(""); if ((!info.isDoFocus()) || (info.getFocusStatus() == ValueListInfo.FOCUS_FOUND)) { return sb; } DisplayHelper displayHelper = rootTag.getConfig().getDisplayHelper(); sb.append("\n <td>"); if (info.getFocusStatus() == ValueListInfo.FOCUS_NOT_FOUND) { sb.append(displayHelper.help(pageContext, message.getMessage("focusStatus.notFound", new String[] { info.getFocusValue() }, local))); } else { if (info.getFocusStatus() == ValueListInfo.FOCUS_TOO_MANY_ITEMS) { sb.append(displayHelper.help(pageContext, message.getMessage("focusStatus.tooManyItems", null, local))); } } sb.append("</td>"); String delim = displayHelper.help(pageContext, message.getMessage("paging.delim", null, "", local)); if (delim.length() > 0) { sb.append(delim); } return sb; }