本文整理汇总了Java中org.jasig.cas.authentication.principal.UsernamePasswordCredentials类的典型用法代码示例。如果您正苦于以下问题:Java UsernamePasswordCredentials类的具体用法?Java UsernamePasswordCredentials怎么用?Java UsernamePasswordCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsernamePasswordCredentials类属于org.jasig.cas.authentication.principal包,在下文中一共展示了UsernamePasswordCredentials类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testValidMd5Password
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Test
public void testValidMd5Password() throws Exception {
final UserPasswordDao userPasswordDao = EasyMock.createMock(UserPasswordDao.class);
EasyMock.expect(userPasswordDao.getPasswordHash("admin"))
.andReturn("(MD5)OP2Z89LDMIY6gHAwfoFPRSQWDl5Z16Vt");
final PersonDirAuthenticationHandler authenticationHandler =
new PersonDirAuthenticationHandler();
authenticationHandler.setUserPasswordDao(userPasswordDao);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername("admin");
credentials.setPassword("admin");
EasyMock.replay(userPasswordDao);
final boolean auth =
authenticationHandler.authenticateUsernamePasswordInternal(credentials);
EasyMock.verify(userPasswordDao);
assertTrue(auth);
}
开发者ID:Jasig,项目名称:uPortal-start,代码行数:24,代码来源:PersonDirAuthenticationHandlerTest.java
示例2: testInvalidMd5Password
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Test
public void testInvalidMd5Password() throws Exception {
final UserPasswordDao userPasswordDao = EasyMock.createMock(UserPasswordDao.class);
EasyMock.expect(userPasswordDao.getPasswordHash("admin"))
.andReturn("(MD5)OP2Z89LDMIY5gHAwfoFPRSQWDl5Z16Vt");
final PersonDirAuthenticationHandler authenticationHandler =
new PersonDirAuthenticationHandler();
authenticationHandler.setUserPasswordDao(userPasswordDao);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername("admin");
credentials.setPassword("admin");
EasyMock.replay(userPasswordDao);
final boolean auth =
authenticationHandler.authenticateUsernamePasswordInternal(credentials);
EasyMock.verify(userPasswordDao);
assertFalse(auth);
}
开发者ID:Jasig,项目名称:uPortal-start,代码行数:24,代码来源:PersonDirAuthenticationHandlerTest.java
示例3: testNullPassword
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Test
public void testNullPassword() throws Exception {
final UserPasswordDao userPasswordDao = EasyMock.createMock(UserPasswordDao.class);
EasyMock.expect(userPasswordDao.getPasswordHash("admin")).andReturn(null);
final PersonDirAuthenticationHandler authenticationHandler =
new PersonDirAuthenticationHandler();
authenticationHandler.setUserPasswordDao(userPasswordDao);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername("admin");
credentials.setPassword("admin");
EasyMock.replay(userPasswordDao);
final boolean auth =
authenticationHandler.authenticateUsernamePasswordInternal(credentials);
EasyMock.verify(userPasswordDao);
assertFalse(auth);
}
开发者ID:Jasig,项目名称:uPortal-start,代码行数:23,代码来源:PersonDirAuthenticationHandlerTest.java
示例4: testValidSHA256Password
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Test
public void testValidSHA256Password() throws Exception {
final UserPasswordDao userPasswordDao = EasyMock.createMock(UserPasswordDao.class);
EasyMock.expect(userPasswordDao.getPasswordHash("student"))
.andReturn("(SHA256)KwAQC001SoQq/CjHMLSz2o0aAqx7WrKeRFgWOeM2GEyLXGZd+1/XkA==");
final PersonDirAuthenticationHandler authenticationHandler =
new PersonDirAuthenticationHandler();
authenticationHandler.setUserPasswordDao(userPasswordDao);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername("student");
credentials.setPassword("wombat");
EasyMock.replay(userPasswordDao);
final boolean auth =
authenticationHandler.authenticateUsernamePasswordInternal(credentials);
EasyMock.verify(userPasswordDao);
assertTrue(auth);
}
开发者ID:Jasig,项目名称:uPortal-start,代码行数:24,代码来源:PersonDirAuthenticationHandlerTest.java
示例5: testInvalidSHA256Password
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Test
public void testInvalidSHA256Password() throws Exception {
final UserPasswordDao userPasswordDao = EasyMock.createMock(UserPasswordDao.class);
EasyMock.expect(userPasswordDao.getPasswordHash("student"))
.andReturn("(SHA256)KwAQC001SoPq/CjHMLSz2o0aAqx7WrKeRFgWOeM2GEyLXGZd+1/XkA==");
final PersonDirAuthenticationHandler authenticationHandler =
new PersonDirAuthenticationHandler();
authenticationHandler.setUserPasswordDao(userPasswordDao);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername("student");
credentials.setPassword("student");
EasyMock.replay(userPasswordDao);
final boolean auth =
authenticationHandler.authenticateUsernamePasswordInternal(credentials);
EasyMock.verify(userPasswordDao);
assertFalse(auth);
}
开发者ID:Jasig,项目名称:uPortal-start,代码行数:24,代码来源:PersonDirAuthenticationHandlerTest.java
示例6: LegacyAuthenticationHandlerAdapter
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
/**
* Creates a new instance that adapts the given legacy authentication handler.
*
* @param legacy CAS 3.0 authentication handler.
*/
public LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy) {
if (!legacy.supports(new UsernamePasswordCredentials())) {
throw new IllegalArgumentException(
"Cannot infer credential conversion strategy - specify CredentialsAdapter explicitly.");
}
this.legacyHandler = legacy;
this.credentialsAdapter = new UsernamePasswordCredentialsAdapter();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:LegacyAuthenticationHandlerAdapter.java
示例7: convert
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Override
public Credentials convert(final Credential credential) {
if (!(credential instanceof UsernamePasswordCredential)) {
throw new IllegalArgumentException(credential + " not supported.");
}
final UsernamePasswordCredential original = (UsernamePasswordCredential) credential;
final UsernamePasswordCredentials old = new UsernamePasswordCredentials();
old.setUsername(original.getUsername());
old.setPassword(original.getPassword());
return old;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:UsernamePasswordCredentialsAdapter.java
示例8: supports
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
/**
* Return true if Credentials are UsernamePasswordCredentials, false
* otherwise.
*/
@Override
public boolean supports(final Credentials credentials) {
return credentials != null
&& UsernamePasswordCredentials.class.isAssignableFrom(credentials
.getClass());
}
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:11,代码来源:TransformedUsernamePasswordCredentialToPrincipalResolver.java
示例9: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
protected final boolean authenticateUsernamePasswordInternal(final UsernamePasswordCredentials credentials) throws AuthenticationException {
final String transformedUsername = getPrincipalNameTransformer().transform(credentials.getUsername());
final String encryptedPassword = getPasswordEncoder().encode(
credentials.getPassword() + (isWithSalt()?"{" + transformedUsername + "}":""));
ApiResponse response;
JsonNode userTree;
try {
response = caratarseAuthClient.getUserByUsername(transformedUsername);
if ("404".equals(response.getCode())) {
throw new UnknownUsernameAuthenticationException();
}
ObjectMapper m = new ObjectMapper();
JsonNode rootTree = m.readTree(response.getContent());
userTree = rootTree.get("_embedded").get("users").get(0);
if (userTree == null) {
throw new UnknownUsernameAuthenticationException();
}
} catch (Exception ex) {
throw new AuthenticationException("Authentication failed for user "+transformedUsername, ex) {};
}
if (!userIsEnabled(userTree)) {
throw new BlockedCredentialsAuthenticationException();
}
if (!passwordMatches(userTree, encryptedPassword)) {
throw new BadPasswordAuthenticationException();
}
// update last login
return true;
}
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:37,代码来源:CaratarseAuthClientAuthenticationHandler.java
示例10: authenticateUsernamePasswordInternal
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Override
protected boolean authenticateUsernamePasswordInternal(
UsernamePasswordCredentials credentials)
throws AuthenticationException {
String username = credentials.getUsername();
String password = credentials.getPassword();
String encryptedPassword = this.getPasswordEncoder().encode(
password);
if("admin1".equals(username)){
System.out
.println("JpaUsernamePasswordAuthenticationHandler.authenticateUsernamePasswordInternal()");
System.err.println("让测试账号admin1 通过验证");
return true;
}
//来自账号服务器的验证
CasLoginAccount casLoginAccount = new CasLoginAccount(username);
RegisteredAccount findAccountBy = accountManager.findAccountBy(casLoginAccount);
if(null != findAccountBy){
return encryptedPassword.equals(findAccountBy.getPasswd());
}
//Server Manager 账号验证
try{
UserDetails loadUserByUsername = userDetailsService.loadUserByUsername(username);
if(null != loadUserByUsername){
return password.equals(loadUserByUsername.getPassword());
}
}catch(UsernameNotFoundException e){
}
return false;
}
开发者ID:lanen,项目名称:mint4j,代码行数:36,代码来源:JpaUsernamePasswordAuthenticationHandler.java
示例11: getGlobusCredential
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
public GlobusCredential getGlobusCredential() throws Exception {
CaGridAuthenticationManager authManager = new CaGridAuthenticationManager();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername(userName);
credentials.setPassword(userPasswd);
authManager.authenticate(credentials);
return authManager.getCredentials();
}
开发者ID:NCIP,项目名称:labviewer,代码行数:9,代码来源:CancerCenterClient.java
示例12: main
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
public static void main(String[] args) {
CaGridAuthenticationManager authManager = new CaGridAuthenticationManager();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername("[email protected]");
credentials.setPassword("!Ccts1");
try {
authManager.authenticate(credentials);
}catch (Exception e){
e.printStackTrace();
}
}
开发者ID:NCIP,项目名称:labviewer,代码行数:12,代码来源:CaGridAuthenticationManager.java
示例13: extractPrincipalId
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
@Override
protected String extractPrincipalId(final Credentials credentials) {
final UsernamePasswordCredentials usernamePasswordCredentials = (UsernamePasswordCredentials) credentials;
return principalNameTransformer.transform(usernamePasswordCredentials.getUsername());
}
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:6,代码来源:TransformedUsernamePasswordCredentialToPrincipalResolver.java
示例14: authenticate
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; //导入依赖的package包/类
public Authentication authenticate(Credentials credentials) throws AuthenticationException
{
if (null == webSSOProperties)
{
throw new AuthenticationConfigurationException ("Error Initializing Authentication Manager properties");
}
// Obtain the implementation for the AuthenticationServiceHelper Interface
AuthenticationServiceHelper authenticationServiceHelper = (AuthenticationServiceHelper)ObjectFactory.getObject(WebSSOConstants.AUTHENTICATION_SERVICE_HELPER);
// Authenticate the user credentials and retrieve
SAMLAssertion samlAssertion = authenticationServiceHelper.authenticate(getAuthenticationServiceURL(), ((UsernamePasswordCredentials) credentials).getUsername(), ((UsernamePasswordCredentials) credentials).getPassword());
// Obtain the implementation for the DorianHelper Interface
DorianHelper dorianHelper = (DorianHelper) ObjectFactory.getObject(WebSSOConstants.DORIAN_HELPER);
// Obtained the GlobusCredential for the Authenticated User
GlobusCredential globusCredential = dorianHelper.obtainProxy(samlAssertion);
this.credentials = globusCredential;
// Obtain the implementation for the GridCredentialsDelegator Interface
GridCredentialDelegator gridCredentialDelegator = (GridCredentialDelegator)ObjectFactory.getObject(WebSSOConstants.GRID_CREDENTIAL_DELEGATOR);
// Delegate the Globus Credentials
String serializedDelegatedCredentialReference = gridCredentialDelegator.delegateGridCredential(globusCredential, dorianHelper.getProxyLifetime(), this.getHostIdentities());
this.serializedDelegationEpr = serializedDelegatedCredentialReference;
// Obtain the implementation for the SAMLToAttributeMapper Interface
SAMLToAttributeMapper samlToAttributeMapper = (SAMLToAttributeMapper)ObjectFactory.getObject(WebSSOConstants.SAML_TO_ATTRIBUTE_MAPPER);
HashMap<String, String> attributesMap = samlToAttributeMapper.convertSAMLtoHashMap(samlAssertion);
// Adding the serialed Delegated Credentails Reference and Grid Identity to the
attributesMap.put(WebSSOConstants.CAGRID_SSO_DELEGATION_SERVICE_EPR, serializedDelegatedCredentialReference);
attributesMap.put(WebSSOConstants.CAGRID_SSO_GRID_IDENTITY, globusCredential.getIdentity());
// Creating the Principal from the grid identity
Principal p = new SimplePrincipal(this.constructPrincipal(attributesMap));
// Create a new Authentication Object using the Principal
MutableAuthentication mutableAuthentication = new MutableAuthentication(p);
return mutableAuthentication;
}
开发者ID:NCIP,项目名称:labviewer,代码行数:45,代码来源:CaGridAuthenticationManager.java
注:本文中的org.jasig.cas.authentication.principal.UsernamePasswordCredentials类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论