• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TkAuth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.takes.facets.auth.TkAuth的典型用法代码示例。如果您正苦于以下问题:Java TkAuth类的具体用法?Java TkAuth怎么用?Java TkAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TkAuth类属于org.takes.facets.auth包,在下文中一共展示了TkAuth类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: matchesIfAuthenticatedUser

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * FkAuthenticated can match by user status.
 * @throws IOException If some problem inside
 */
@Test
public void matchesIfAuthenticatedUser() throws IOException {
    MatcherAssert.assertThat(
        new FkAuthenticated(new TkEmpty()).route(
            new RqFake("GET", "/hel?a=1")
        ).has(),
        Matchers.is(false)
    );
    MatcherAssert.assertThat(
        new FkAuthenticated(new TkEmpty()).route(
            new RqWithHeader(
                new RqFake("PUT", "/hello"),
                TkAuth.class.getSimpleName(),
                new String(
                    new CcPlain().encode(new Identity.Simple("urn:test:1"))
                )
            )
        ).has(),
        Matchers.is(true)
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:26,代码来源:FkAuthenticatedTest.java


示例2: auth

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * Authenticated.
 * @param take Take
 * @return Authenticated takes
 */
private static Take auth(final Take take) {
    final String key = Manifests.read("libre-FacebookId");
    return new TkAuth(
        take,
        new PsChain(
            new PsFake(key.startsWith("XXXX") || key.startsWith("${")),
            new PsByFlag(
                new PsByFlag.Pair(
                    PsFacebook.class.getSimpleName(),
                    new PsFacebook(
                        key,
                        Manifests.read("libre-FacebookSecret")
                    )
                ),
                new PsByFlag.Pair(
                    PsLogout.class.getSimpleName(),
                    new PsLogout()
                )
            ),
            new PsCookie(
                new CcSafe(
                    new CcHex(
                        new CcXOR(
                            new CcSalted(new CcCompact()),
                            Manifests.read("libre-SecurityKey")
                        )
                    )
                )
            )
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:38,代码来源:TkApp.java


示例3: returnsListOfDocsOfSingleUser

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * TkAdmin can return a list of docs of single user.
 * @throws Exception If fails.
 */
@Test
public void returnsListOfDocsOfSingleUser() throws Exception {
    final Base base = new MkBase();
    final String urn = "urn:test:1";
    final User user = base.user(urn);
    final String content = "hello, world!";
    user.docs().doc("test.txt").write(
        new ByteArrayInputStream(content.getBytes()), content.length()
    );
    final String second = "hello!";
    user.docs().doc("test-2.txt").write(
        new ByteArrayInputStream(second.getBytes()), second.length()
    );
    MatcherAssert.assertThat(
        new RsPrint(
            new TkAdmin(base).act(
                new RqWithHeader(
                    new RqFake(),
                    TkAuth.class.getSimpleName(),
                    new String(
                        new CcPlain().encode(new Identity.Simple(urn))
                    )
                )
            )
        ).printBody(),
        XhtmlMatchers.hasXPaths(
            "/page/docs[count(doc)=2]",
            "/page/docs/doc[path='urn:test:1/test.txt']",
            "/page/docs/doc[path='urn:test:1/test-2.txt']"
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:37,代码来源:TkAdminTest.java


示例4: returnsListOfDocs

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * TkDocs can return a list of docs.
 * @throws Exception If fails.
 */
@Test
public void returnsListOfDocs() throws Exception {
    final Base base = new MkBase();
    final User user = base.user(TkDocsTest.FAKE_URN);
    final byte[] helloworld = "hello, world!".getBytes();
    user.docs().doc("test.txt").write(
        new ByteArrayInputStream(helloworld), helloworld.length
    );
    final byte[] hello = "hello!".getBytes();
    user.docs().doc("test-2.txt").write(
        new ByteArrayInputStream(hello), hello.length
    );
    MatcherAssert.assertThat(
        new RsPrint(
            new TkDocs(base).act(
                new RqWithHeader(
                    new RqFake(),
                    TkAuth.class.getSimpleName(),
                    new String(
                        new CcPlain().encode(
                            new Identity.Simple(TkDocsTest.FAKE_URN)
                        )
                    )
                )
            )
        ).printBody(),
        XhtmlMatchers.hasXPaths(
            "/page/user[balance=0]",
            "/page/docs[count(doc)=2]",
            "/page/account/size",
            "/page/docs/doc[name='test.txt']",
            "/page/docs/doc/links/link[@rel='read']"
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:40,代码来源:TkDocsTest.java


示例5: addsShortLinkInHTML

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * TkDocs can add short link to document in HTML.
 * @throws IOException In case of error
 */
@Test
public void addsShortLinkInHTML() throws IOException {
    final Base base = new MkBase();
    final String file = "short.txt";
    final Doc doc = base.user(TkDocsTest.FAKE_URN).docs().doc(file);
    doc.write(new ByteArrayInputStream("hi".getBytes()), 2L);
    MatcherAssert.assertThat(
        IOUtils.toString(
            new RsXSLT(
                new TkDocs(base).act(
                    new RqWithHeader(
                        new RqFake(),
                        TkAuth.class.getSimpleName(),
                        new String(
                            new CcPlain().encode(
                                new Identity.Simple(TkDocsTest.FAKE_URN)
                            )
                        )
                    )
                )
            ).body()
        ),
        XhtmlMatchers.hasXPaths(
            String.format("//xhtml:a[@href='%s']", doc.shortUrl())
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:32,代码来源:TkDocsTest.java


示例6: formatsDate

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * TkDocs can format date.
 * @throws IOException In case of error
 */
@Test
public void formatsDate() throws IOException {
    final Base base = new MkBase();
    final String file = "test4.txt";
    final Doc doc = base.user(TkDocsTest.FAKE_URN).docs().doc(file);
    final byte[] bytes = "hey!".getBytes();
    doc.write(new ByteArrayInputStream(bytes), bytes.length);
    MatcherAssert.assertThat(
        IOUtils.toString(
            new RsXSLT(
                new TkDocs(base).act(
                    new RqWithHeader(
                        new RqFake(),
                        TkAuth.class.getSimpleName(),
                        new String(
                            new CcPlain().encode(
                                new Identity.Simple(TkDocsTest.FAKE_URN)
                            )
                        )
                    )
                )
            ).body()
        ),
        Matchers.containsString(
            String.format(
                "] %s",
                new SimpleDateFormat("yyyy-MM-dd", Locale.US)
                    .format(doc.attributes().created())
            )
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:37,代码来源:TkDocsTest.java


示例7: RqWithTester

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * Ctor.
 * @param req Original request
 * @throws IOException If fails
 */
public RqWithTester(final Request req) throws IOException {
    super(
        new RqWithHeader(
            req,
            TkAuth.class.getSimpleName(),
            new String(
                new CcPlain().encode(
                    new Identity.Simple("urn:test:1")
                )
        )
    )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:19,代码来源:RqWithTester.java


示例8: make

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * Authenticated.
 * @param take Take
 * @return Authenticated take
 */
private static Take make(final Take take) {
    return new TkAuth(
        take,
        new PsChain(
            new TkAppAuth.FakePass(),
            new PsByFlag(
                new PsByFlag.Pair(
                    PsGithub.class.getSimpleName(),
                    new PsGithub(
                        Manifests.read("Thindeck-GithubId"),
                        Manifests.read("Thindeck-GithubSecret")
                    )
                ),
                new PsByFlag.Pair(
                    "fake-user",
                    new TkAppAuth.FakePass()
                ),
                new PsByFlag.Pair(
                    PsLogout.class.getSimpleName(),
                    new PsLogout()
                )
            ),
            new PsCookie(
                new CcSafe(
                    new CcHex(
                        new CcXOR(
                            new CcSalted(new CcCompact()),
                            Manifests.read("Thindeck-SecurityKey")
                        )
                    )
                )
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:41,代码来源:TkAppAuth.java


示例9: auth

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * Auth.
 * @param take Takes
 * @return Authenticated takes
 */
private static Take auth(final Take take) {
    return new TkAuth(
        new TkFork(
            new FkParams(
                PsByFlag.class.getSimpleName(),
                Pattern.compile(".+"),
                new TkRedirect()
            ),
            new FkFixed(take)
        ),
        new PsChain(
            new PsFake(
                Manifests.read("ThreeCopies-DynamoKey").startsWith("AAAA")
            ),
            new PsByFlag(
                new PsByFlag.Pair(
                    PsGithub.class.getSimpleName(),
                    new PsGithub(
                        Manifests.read("ThreeCopies-GithubId"),
                        Manifests.read("ThreeCopies-GithubSecret")
                    )
                ),
                new PsByFlag.Pair(
                    PsLogout.class.getSimpleName(),
                    new PsLogout()
                )
            ),
            new PsCookie(
                new CcSafe(
                    new CcHex(
                        new CcXor(
                            new CcSalted(new CcCompact()),
                            Manifests.read("ThreeCopies-SecurityKey")
                        )
                    )
                )
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:46,代码来源:TkApp.java


示例10: make

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * Authenticated.
 * @param take Takes
 * @return Authenticated takes
 */
private static Take make(final Take take) {
    return new TkAuth(
        new TkFork(
            new FkParams(
                PsByFlag.class.getSimpleName(),
                Pattern.compile(".+"),
                new TkRedirect()
            ),
            new FkFixed(take)
        ),
        new PsChain(
            new PsFake(
                Manifests.read("Jare-DynamoKey").startsWith("AAAA")
            ),
            new PsByFlag(
                new PsByFlag.Pair(
                    PsGithub.class.getSimpleName(),
                    new PsGithub(
                        Manifests.read("Jare-GithubId"),
                        Manifests.read("Jare-GithubSecret")
                    )
                ),
                new PsByFlag.Pair(
                    PsLogout.class.getSimpleName(),
                    new PsLogout()
                )
            ),
            new PsCookie(
                new CcSafe(
                    new CcHex(
                        new CcXor(
                            new CcSalted(new CcCompact()),
                            Manifests.read("Jare-SecurityKey")
                        )
                    )
                )
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:jare,代码行数:46,代码来源:TkAppAuth.java


示例11: make

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * Authenticated.
 * @param take Takes
 * @return Authenticated takes
 */
private static Take make(final Take take) {
    return new TkAuth(
        new TkFork(
            new FkParams(
                PsByFlag.class.getSimpleName(),
                Pattern.compile(".+"),
                new TkRedirect()
            ),
            new FkFixed(take)
        ),
        new PsChain(
            new PsFake(
                Manifests.read("Wring-DynamoKey").startsWith("AAAA")
            ),
            new PsByFlag(
                new PsByFlag.Pair(
                    PsGithub.class.getSimpleName(),
                    new PsGithub(
                        Manifests.read("Wring-GithubId"),
                        Manifests.read("Wring-GithubSecret")
                    )
                ),
                new PsByFlag.Pair(
                    PsLogout.class.getSimpleName(),
                    new PsLogout()
                )
            ),
            new PsCookie(
                new CcSafe(
                    new CcHex(
                        new CcXor(
                            new CcSalted(new CcCompact()),
                            Manifests.read("Wring-SecurityKey")
                        )
                    )
                )
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:46,代码来源:TkAppAuth.java


示例12: returnsListOfDocsOfSeveralUsers

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * TkAdmin can return a list of docs of several users.
 * @throws Exception If fails.
 */
@Test
@Ignore
public void returnsListOfDocsOfSeveralUsers() throws Exception {
    final Base base = new MkBase();
    final String urn = "urn:test:2";
    final User user = base.user(urn);
    final String content = "User1. File1";
    user.docs().doc("test_u1.txt").write(
        new ByteArrayInputStream(content.getBytes()),
        content.length()
    );
    final String second = "User1. File2";
    user.docs().doc("test_u1_2.txt").write(
        new ByteArrayInputStream(second.getBytes()),
        second.length()
    );
    final String third = "User2. File1";
    final User another = base.user("urn:test:3");
    another.docs().doc("test_u2.txt").write(
        new ByteArrayInputStream(third.getBytes()),
        third.length()
    );
    final String fourth = "User2. File2";
    another.docs().doc("test_u2_2.txt").write(
        new ByteArrayInputStream(fourth.getBytes()),
        fourth.length()
    );
    MatcherAssert.assertThat(
        new RsPrint(
            new TkAdmin(base).act(
                new RqWithHeader(
                    new RqFake(),
                    TkAuth.class.getSimpleName(),
                    new String(
                        new CcPlain().encode(new Identity.Simple(urn))
                    )
                )
            )
        ).printBody(),
        XhtmlMatchers.hasXPaths(
            "/page/docs[count(doc)=4]",
            "/page/docs/doc[path='urn:test:1/test_u1.txt']",
            "/page/docs/doc[path='urn:test:1/test_u1_2.txt']",
            "/page/docs/doc[path='urn:test:2/test_u2.txt']",
            "/page/docs/doc[path='urn:test:2/test_u2_2.txt']"
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:53,代码来源:TkAdminTest.java


示例13: addsDocumentLinksInHTML

import org.takes.facets.auth.TkAuth; //导入依赖的package包/类
/**
 * TkDocs can add document links in HTML.
 * @throws IOException In case of error
 */
@Test
public void addsDocumentLinksInHTML() throws IOException {
    final Base base = new MkBase();
    final String file = "test3.txt";
    final byte[] bytes = "hi!".getBytes();
    base.user(TkDocsTest.FAKE_URN).docs()
        .doc(file).write(new ByteArrayInputStream(bytes), bytes.length);
    MatcherAssert.assertThat(
        IOUtils.toString(
            new RsXSLT(
                new TkDocs(base).act(
                    new RqWithHeader(
                        new RqFake(),
                        TkAuth.class.getSimpleName(),
                        new String(
                            new CcPlain().encode(
                                new Identity.Simple(TkDocsTest.FAKE_URN)
                            )
                        )
                    )
                )
            ).body()
        ),
        XhtmlMatchers.hasXPaths(
            String.format(
                // @checkstyle LineLength (1 line)
                "//xhtml:a[@href='http://www.example.com/doc/read?file=%s']",
                file
            ),
            String.format(
                // @checkstyle LineLength (1 line)
                "//xhtml:a[@href='http://www.example.com/doc/delete?file=%s']",
                file
            ),
            String.format(
                // @checkstyle LineLength (1 line)
                "//xhtml:form[@action='http://www.example.com/doc/set-visibility?file=%s']",
                file
            )
        )
    );
}
 
开发者ID:libreio,项目名称:libre,代码行数:47,代码来源:TkDocsTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleRobotRulesParser类代码示例发布时间:2022-05-22
下一篇:
Java TransactionReceipt类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap