OpenAm 如何在回调中重定向到模板(处理方法)

我正在编写应用程序身份验证逻辑。在处理方法的某个时刻,我需要要求用户选择收到的值。


如何将其重定向到我在 OpenAm 中创建的选择页面?另外这个页面应该位于 openAM 中的什么位置?如何向该页面传递必要的值供用户选择?



这是我的模块:


<ModuleProperties moduleName="MyAuth" version="1.0" >

    <Callbacks length="0" order="1" timeout="600" header="#NOT SHOWN#" template="readme.html"/>


    <Callbacks length="2" order="2" timeout="600" header="#TO BE SUBSTITUTED#" template="readme.html">

        <NameCallback isRequired="true" >

            <Prompt>Username</Prompt>

        </NameCallback>

        <PasswordCallback echoPassword="false" >

            <Prompt>Password</Prompt>

        </PasswordCallback>

    </Callbacks>


</ModuleProperties>

这是我的类 MyAuth:


public class MyAuth extends AMLoginModule {

// same code here


     @Override

        public int process(Callback[] callbacks, int state) throws LoginException {


//same code logic here 

 switch (state) {

//...

case GET_TEMPLATE:

// in this place i try redirect to templete readme.html

 Callback[] callback = getCallback(1);

        try {

            getCallbackHandler().handle(callback);

        } catch (IOException e) {

            e.printStackTrace();

        } catch (UnsupportedCallbackException e) {

            e.printStackTrace();

        }

}

}



萧十郎
浏览 100回答 1
1回答

繁花如伊

要检索其他输入,请向模块添加另一个状态。<ModuleProperties moduleName="MyAuth" version="1.0" >&nbsp; &nbsp; <Callbacks length="0" order="1" timeout="600" header="#NOT SHOWN#" template="readme.html"/>&nbsp; &nbsp; <Callbacks length="2" order="2" timeout="600" header="#TO BE SUBSTITUTED#">&nbsp; &nbsp; &nbsp; &nbsp; <NameCallback isRequired="true" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Prompt>Username</Prompt>&nbsp; &nbsp; &nbsp; &nbsp; </NameCallback>&nbsp; &nbsp; &nbsp; &nbsp; <PasswordCallback echoPassword="false" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Prompt>Password</Prompt>&nbsp; &nbsp; &nbsp; &nbsp; </PasswordCallback>&nbsp; &nbsp; </Callbacks>&nbsp; &nbsp; <Callbacks length="1 order="3" timeout="600" header="#TO BE SUBSTITUTED#">&nbsp; &nbsp; &nbsp; &nbsp; <NameCallback isRequired="true" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Prompt>Additional Input</Prompt>&nbsp; &nbsp; &nbsp; &nbsp; </NameCallback>&nbsp; &nbsp; </Callbacks>&nbsp; &nbsp;&nbsp;</ModuleProperties>处理auth模块代码中的状态public class MyAuth extends AMLoginModule {// same code here&nbsp; &nbsp; &nbsp;@Override&nbsp; &nbsp; &nbsp; &nbsp; public int process(Callback[] callbacks, int state) throws LoginException {//same code logic here&nbsp;&nbsp;switch (state) {case AUTHENTICATE:return GET_ADDITIONAL_DATA;//...case GET_ADDITIONAL_DATA:&nbsp; final String additionalData = ((NameCallback) callbacks[0]).getName();&nbsp; // handle additional data}}}&nbsp;
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java