本文整理了Java中org.springframework.context.support.MessageSourceAccessor.getMessage()
方法的一些代码示例,展示了MessageSourceAccessor.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageSourceAccessor.getMessage()
方法的具体详情如下:
包路径:org.springframework.context.support.MessageSourceAccessor
类名称:MessageSourceAccessor
方法名:getMessage
[英]Retrieve the message for the given code and the default Locale.
[中]检索给定代码和默认语言环境的消息。
代码示例来源:origin: spring-projects/spring-security
private BadCredentialsException badCredentials() {
return new BadCredentialsException(messages.getMessage(
"LdapAuthenticationProvider.badCredentials", "Bad credentials"));
}
代码示例来源:origin: spring-projects/spring-security-oauth
/**
* Logic to be performed on a new timestamp. The default behavior expects that the timestamp should not be new.
*
* @throws org.springframework.security.core.AuthenticationException
* If the timestamp shouldn't be new.
*/
protected void onNewTimestamp() throws AuthenticationException {
throw new InvalidOAuthParametersException(messages.getMessage("OAuthProcessingFilter.timestampNotNew", "A new timestamp should not be used in a request for an access token."));
}
代码示例来源:origin: spring-projects/spring-security
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
RunAsUserToken token = (RunAsUserToken) authentication;
if (token.getKeyHash() == key.hashCode()) {
return authentication;
}
else {
throw new BadCredentialsException(messages.getMessage(
"RunAsImplAuthenticationProvider.incorrectKey",
"The presented RunAsUserToken does not contain the expected key"));
}
}
代码示例来源:origin: spring-projects/spring-security-oauth
@Override
protected void onNewTimestamp() throws AuthenticationException {
throw new InvalidOAuthParametersException(messages.getMessage("AccessTokenProcessingFilter.timestampNotNew", "A new timestamp should not be used in a request for an access token."));
}
代码示例来源:origin: org.springframework.security/spring-security-core
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
RunAsUserToken token = (RunAsUserToken) authentication;
if (token.getKeyHash() == key.hashCode()) {
return authentication;
}
else {
throw new BadCredentialsException(messages.getMessage(
"RunAsImplAuthenticationProvider.incorrectKey",
"The presented RunAsUserToken does not contain the expected key"));
}
}
代码示例来源:origin: spring-projects/spring-security
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
if (!supports(authentication.getClass())) {
return null;
}
if (this.key.hashCode() != ((RememberMeAuthenticationToken) authentication)
.getKeyHash()) {
throw new BadCredentialsException(
messages.getMessage("RememberMeAuthenticationProvider.incorrectKey",
"The presented RememberMeAuthenticationToken does not contain the expected key"));
}
return authentication;
}
代码示例来源:origin: spring-projects/spring-security
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
if (!supports(authentication.getClass())) {
return null;
}
if (this.key.hashCode() != ((AnonymousAuthenticationToken) authentication)
.getKeyHash()) {
throw new BadCredentialsException(
messages.getMessage("AnonymousAuthenticationProvider.incorrectKey",
"The presented AnonymousAuthenticationToken does not contain the expected key"));
}
return authentication;
}
代码示例来源:origin: org.springframework.security/spring-security-core
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
if (!supports(authentication.getClass())) {
return null;
}
if (this.key.hashCode() != ((AnonymousAuthenticationToken) authentication)
.getKeyHash()) {
throw new BadCredentialsException(
messages.getMessage("AnonymousAuthenticationProvider.incorrectKey",
"The presented AnonymousAuthenticationToken does not contain the expected key"));
}
return authentication;
}
代码示例来源:origin: spring-projects/spring-security
public void check(UserDetails user) {
if (!user.isCredentialsNonExpired()) {
logger.debug("User account credentials have expired");
throw new CredentialsExpiredException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.credentialsExpired",
"User credentials have expired"));
}
}
}
代码示例来源:origin: spring-projects/spring-security
@SuppressWarnings("deprecation")
protected void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken authentication)
throws AuthenticationException {
if (authentication.getCredentials() == null) {
logger.debug("Authentication failed: no credentials provided");
throw new BadCredentialsException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.badCredentials",
"Bad credentials"));
}
String presentedPassword = authentication.getCredentials().toString();
if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) {
logger.debug("Authentication failed: password does not match stored value");
throw new BadCredentialsException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.badCredentials",
"Bad credentials"));
}
}
代码示例来源:origin: org.springframework.security/spring-security-core
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
if (!supports(authentication.getClass())) {
return null;
}
if (this.key.hashCode() != ((RememberMeAuthenticationToken) authentication)
.getKeyHash()) {
throw new BadCredentialsException(
messages.getMessage("RememberMeAuthenticationProvider.incorrectKey",
"The presented RememberMeAuthenticationToken does not contain the expected key"));
}
return authentication;
}
代码示例来源:origin: org.springframework.security/spring-security-core
public void check(UserDetails user) {
if (!user.isCredentialsNonExpired()) {
logger.debug("User account credentials have expired");
throw new CredentialsExpiredException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.credentialsExpired",
"User credentials have expired"));
}
}
}
代码示例来源:origin: spring-projects/spring-security
protected final void checkAllowIfAllAbstainDecisions() {
if (!this.isAllowIfAllAbstainDecisions()) {
throw new AccessDeniedException(messages.getMessage(
"AbstractAccessDecisionManager.accessDenied", "Access is denied"));
}
}
代码示例来源:origin: cloudfoundry/uaa
public DirContextOperations searchAuthenticate(DirContextOperations user, byte[] passwordBytes,
SpringSecurityLdapTemplate ldapTemplate) {
if (logger.isDebugEnabled()) {
logger.debug("Performing LDAP compare of password attribute '" + passwordAttributeName + "' for user '" +
user.getDn() + "'");
}
if (!ldapTemplate.compare(user.getDn().toString(), passwordAttributeName, passwordBytes)) {
throw new BadCredentialsException(messages.getMessage("PasswordComparisonAuthenticator.badCredentials",
"Bad credentials"));
}
return user;
}
代码示例来源:origin: org.springframework.security/spring-security-core
protected final void checkAllowIfAllAbstainDecisions() {
if (!this.isAllowIfAllAbstainDecisions()) {
throw new AccessDeniedException(messages.getMessage(
"AbstractAccessDecisionManager.accessDenied", "Access is denied"));
}
}
代码示例来源:origin: spring-projects/spring-security-oauth
@Override
protected void validateAdditionalParameters(ConsumerDetails consumerDetails, Map<String, String> oauthParams) {
super.validateAdditionalParameters(consumerDetails, oauthParams);
if (isRequire10a()) {
String token = oauthParams.get(OAuthConsumerParameter.oauth_callback.toString());
if (token == null) {
throw new InvalidOAuthParametersException(messages.getMessage("AccessTokenProcessingFilter.missingCallback", "Missing callback."));
}
}
}
代码示例来源:origin: spring-projects/spring-security-oauth
@Override
protected void validateAdditionalParameters(ConsumerDetails consumerDetails, Map<String, String> oauthParams) {
super.validateAdditionalParameters(consumerDetails, oauthParams);
String token = oauthParams.get(OAuthConsumerParameter.oauth_token.toString());
if (token == null) {
throw new InvalidOAuthParametersException(messages.getMessage("AccessTokenProcessingFilter.missingToken", "Missing token."));
}
if (isRequire10a()) {
String verifier = oauthParams.get(OAuthConsumerParameter.oauth_verifier.toString());
if (verifier == null) {
throw new InvalidOAuthParametersException(messages.getMessage("AccessTokenProcessingFilter.missingVerifier", "Missing verifier."));
}
OAuthProviderToken requestToken = getTokenServices().getToken(token);
if (!verifier.equals(requestToken.getVerifier())) {
throw new InvalidOAuthParametersException(messages.getMessage("AccessTokenProcessingFilter.missingVerifier", "Invalid verifier."));
}
}
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void setMessageSourceWhenNotNullThenCanGet() throws Exception {
MessageSource source = mock(MessageSource.class);
JdbcDaoImpl dao = new JdbcDaoImpl();
dao.setMessageSource(source);
String code = "code";
dao.getMessages().getMessage(code);
verify(source).getMessage(eq(code), any(), any());
}
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void germanSystemLocaleWithEnglishLocaleContextHolder() {
Locale beforeSystem = Locale.getDefault();
Locale.setDefault(Locale.GERMAN);
Locale beforeHolder = LocaleContextHolder.getLocale();
LocaleContextHolder.setLocale(Locale.US);
MessageSourceAccessor msgs = SpringSecurityMessageSource.getAccessor();
assertThat("Access is denied").isEqualTo(
msgs.getMessage("AbstractAccessDecisionManager.accessDenied", "Ooops"));
// Revert to original Locale
Locale.setDefault(beforeSystem);
LocaleContextHolder.setLocale(beforeHolder);
}
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void testReplacableLookup() {
// Change Locale to English
Locale before = LocaleContextHolder.getLocale();
LocaleContextHolder.setLocale(Locale.FRENCH);
// Cause a message to be generated
MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
assertThat("Le jeton nonce est compromis FOOBAR").isEqualTo(
messages.getMessage("DigestAuthenticationFilter.nonceCompromised",
new Object[] { "FOOBAR" }, "ERROR - FAILED TO LOOKUP"));
// Revert to original Locale
LocaleContextHolder.setLocale(before);
}
内容来源于网络,如有侵权,请联系作者删除!