当前位置: 首页>>代码示例>>Java>>正文


Java SimpleCredentials.setAttribute方法代码示例

本文整理汇总了Java中javax.jcr.SimpleCredentials.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleCredentials.setAttribute方法的具体用法?Java SimpleCredentials.setAttribute怎么用?Java SimpleCredentials.setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.SimpleCredentials的用法示例。


在下文中一共展示了SimpleCredentials.setAttribute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setApplicationContext

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	try {
		repository = repositoryBuilder.getRepository();
		SimpleCredentials cred = new SimpleCredentials("admin", "admin".toCharArray());
		cred.setAttribute("AutoRefresh", true);
		session = repository.login(cred, null);
		versionManager = session.getWorkspace().getVersionManager();
		lockManager=session.getWorkspace().getLockManager();
		Collection<RepositoryInteceptor> repositoryInteceptors=applicationContext.getBeansOfType(RepositoryInteceptor.class).values();
		if(repositoryInteceptors.size()==0){
			repositoryInteceptor=new DefaultRepositoryInteceptor();
		}else{
			repositoryInteceptor=repositoryInteceptors.iterator().next();
		}
	} catch (Exception ex) {
		throw new RuleException(ex);
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:20,代码来源:BaseRepositoryService.java

示例2: createToken

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
/**
 * Create a separate token node underneath a dedicated token store within
 * the user home node. That token node contains the hashed token, the
 * expiration time and additional mandatory attributes that will be verified
 * during login.
 *
 * @param credentials The current credentials.
 * @return A new {@code TokenInfo} or {@code null} if the token could not
 *         be created.
 */
@Override
public TokenInfo createToken(Credentials credentials) {
    SimpleCredentials sc = extractSimpleCredentials(credentials);
    TokenInfo tokenInfo = null;
    if (sc != null) {
        String[] attrNames = sc.getAttributeNames();
        Map<String, String> attributes = new HashMap<String, String>(attrNames.length);
        for (String attrName : sc.getAttributeNames()) {
            attributes.put(attrName, sc.getAttribute(attrName).toString());
        }
        tokenInfo = createToken(sc.getUserID(), attributes);
        if (tokenInfo != null) {
            // also set the new token to the simple credentials.
            sc.setAttribute(TOKEN_ATTRIBUTE, tokenInfo.getToken());
        }
    }

    return tokenInfo;
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:30,代码来源:TokenProviderImpl.java

示例3: testDoCreateToken

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testDoCreateToken() throws Exception {
    assertFalse(tokenProvider.doCreateToken(new GuestCredentials()));
    assertFalse(tokenProvider.doCreateToken(new TokenCredentials("token")));
    assertFalse(tokenProvider.doCreateToken(getAdminCredentials()));

    SimpleCredentials sc = new SimpleCredentials("uid", "pw".toCharArray());
    assertFalse(tokenProvider.doCreateToken(sc));

    sc.setAttribute("any_attribute", "value");
    assertFalse(tokenProvider.doCreateToken(sc));

    sc.setAttribute("rep:token_key", "value");
    assertFalse(tokenProvider.doCreateToken(sc));

    sc.setAttribute(".token", "existing");
    assertFalse(tokenProvider.doCreateToken(sc));

    sc.setAttribute(".token", "");
    assertTrue(tokenProvider.doCreateToken(sc));
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:22,代码来源:TokenProviderImplTest.java

示例4: testSimpleCredentialsWithAttribute

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testSimpleCredentialsWithAttribute() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = new SimpleCredentials("test", new char[0]);
        sc.setAttribute(".token", "");

        cs = login(sc);
        fail("Unsupported credentials login should fail");
    } catch (LoginException e) {
        // success
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:18,代码来源:TokenLoginModuleTest.java

示例5: testLoginWithAttributes

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testLoginWithAttributes( ) throws Exception {
    ContentSession cs = null;
    try {
        createTestUser();

        SimpleCredentials sc = new SimpleCredentials(USER_ID, USER_PW.toCharArray());
        sc.setAttribute("attr", "value");

        cs = login(sc);

        AuthInfo authInfo = cs.getAuthInfo();
        assertTrue(Arrays.asList(authInfo.getAttributeNames()).contains("attr"));
        assertEquals("value", authInfo.getAttribute("attr"));

        cs.close();
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:23,代码来源:LoginModuleImplTest.java

示例6: testInvalidSimpleCredentialsWithAttribute

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testInvalidSimpleCredentialsWithAttribute() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = new SimpleCredentials("test", new char[0]);
        sc.setAttribute(".token", "");

        cs = login(sc);
        fail("Invalid simple credentials login should fail");
    } catch (LoginException e) {
        // success
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:18,代码来源:TokenDefaultLoginModuleTest.java

示例7: testTokenCreationAndLogin

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testTokenCreationAndLogin() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        sc.setAttribute(".token", "");
        cs = login(sc);

        Object token = sc.getAttribute(".token").toString();
        assertNotNull(token);
        TokenCredentials tc = new TokenCredentials(token.toString());

        cs.close();
        cs = login(tc);
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:21,代码来源:TokenDefaultLoginModuleTest.java

示例8: testTokenCreationAndImpersonation

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testTokenCreationAndImpersonation() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        sc.setAttribute(".token", "");

        ImpersonationCredentials ic = new ImpersonationCredentials(sc, new AuthInfoImpl(((SimpleCredentials) getAdminCredentials()).getUserID(), Collections.<String, Object>emptyMap(), Collections.<Principal>emptySet()));
        cs = login(ic);

        Object token = sc.getAttribute(".token").toString();
        assertNotNull(token);
        TokenCredentials tc = new TokenCredentials(token.toString());

        cs.close();
        cs = login(tc);
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:23,代码来源:TokenDefaultLoginModuleTest.java

示例9: testTokenCreationWithAttributes

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testTokenCreationWithAttributes() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        sc.setAttribute(".token", "");
        sc.setAttribute(".token.mandatory", "something");
        sc.setAttribute("attr", "val");

        cs = login(sc);

        AuthInfo ai = cs.getAuthInfo();
        Set<String> attrNames = ImmutableSet.copyOf(ai.getAttributeNames());
        assertTrue(attrNames.contains("attr"));
        assertFalse(attrNames.contains(".token"));
        assertFalse(attrNames.contains(".token.mandatory"));
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:23,代码来源:TokenDefaultLoginModuleTest.java

示例10: testTokenCreationWithImpersonationAttributes

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testTokenCreationWithImpersonationAttributes() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        sc.setAttribute(".token", "");
        sc.setAttribute(".token.mandatory", "something");
        sc.setAttribute("attr", "val");

        ImpersonationCredentials ic = new ImpersonationCredentials(sc, new AuthInfoImpl(((SimpleCredentials) getAdminCredentials()).getUserID(), Collections.<String, Object>emptyMap(), Collections.<Principal>emptySet()));
        cs = login(ic);

        AuthInfo ai = cs.getAuthInfo();
        Set<String> attrNames = ImmutableSet.copyOf(ai.getAttributeNames());
        assertTrue(attrNames.contains("attr"));
        assertFalse(attrNames.contains(".token"));
        assertFalse(attrNames.contains(".token.mandatory"));
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:24,代码来源:TokenDefaultLoginModuleTest.java

示例11: testCreateTokenWithExpirationParam

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testCreateTokenWithExpirationParam() throws Exception {
    SimpleCredentials sc = new SimpleCredentials(userId, new char[0]);
    sc.setAttribute(TokenProvider.PARAM_TOKEN_EXPIRATION, 100000);

    TokenInfo info = tokenProvider.createToken(sc);
    assertTokenInfo(info, userId);

    Tree tokenTree = getTokenTree(info);
    assertNotNull(tokenTree);
    assertTrue(tokenTree.exists());
    assertTrue(tokenTree.hasProperty(TokenProvider.PARAM_TOKEN_EXPIRATION));
    assertEquals(100000, tokenTree.getProperty(TokenProvider.PARAM_TOKEN_EXPIRATION).getValue(Type.LONG).longValue());
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:15,代码来源:TokenProviderImplTest.java

示例12: testCreateTokenWithInvalidExpirationParam

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testCreateTokenWithInvalidExpirationParam() throws Exception {
    SimpleCredentials sc = new SimpleCredentials(userId, new char[0]);
    sc.setAttribute(TokenProvider.PARAM_TOKEN_EXPIRATION, "invalid");

    try {
        tokenProvider.createToken(sc);
        fail();
    } catch (NumberFormatException e) {
        // success
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:13,代码来源:TokenProviderImplTest.java

示例13: testSimpleCredentialsWithAttribute

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testSimpleCredentialsWithAttribute() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        sc.setAttribute(".token", "");
        cs = login(sc);
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:14,代码来源:TokenDefaultLoginModuleTest.java

示例14: testTokenAuthInfo

import javax.jcr.SimpleCredentials; //导入方法依赖的package包/类
@Test
public void testTokenAuthInfo() throws Exception {
    ContentSession cs = null;
    try {
        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        sc.setAttribute(".token", "");
        cs = login(sc);
        assertEquals("userid must be correct", "admin", cs.getAuthInfo().getUserID());
    } finally {
        if (cs != null) {
            cs.close();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:15,代码来源:TokenDefaultLoginModuleTest.java


注:本文中的javax.jcr.SimpleCredentials.setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。