OpenAm 如何在回调中重定向到模板(处理方法)
OpenAm how to redirect to template in callback (proceess method)
我正在编写应用程序身份验证逻辑。在处理方法的某个时刻,我需要让用户 select 接收到的值。
如何将它重定向到我在 OpenAm 中创建的 selection 页面?
另外,此页面应位于 openAM 中的什么位置?
我怎样才能向这个页面传递用户需要的值select?
太
这是我的模块:
<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>
这是我的 class 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();
}
}
}
}
要检索其他输入,请向模块添加另一个状态。
<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#">
<NameCallback isRequired="true" >
<Prompt>Username</Prompt>
</NameCallback>
<PasswordCallback echoPassword="false" >
<Prompt>Password</Prompt>
</PasswordCallback>
</Callbacks>
<Callbacks length="1 order="3" timeout="600" header="#TO BE SUBSTITUTED#">
<NameCallback isRequired="true" >
<Prompt>Additional Input</Prompt>
</NameCallback>
</Callbacks>
</ModuleProperties>
在auth模块代码中处理状态
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 AUTHENTICATE:
return GET_ADDITIONAL_DATA;
//...
case GET_ADDITIONAL_DATA:
final String additionalData = ((NameCallback) callbacks[0]).getName();
// handle additional data
}
}
}
我正在编写应用程序身份验证逻辑。在处理方法的某个时刻,我需要让用户 select 接收到的值。
如何将它重定向到我在 OpenAm 中创建的 selection 页面? 另外,此页面应位于 openAM 中的什么位置? 我怎样才能向这个页面传递用户需要的值select?
太
这是我的模块:
<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>
这是我的 class 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();
}
}
}
}
要检索其他输入,请向模块添加另一个状态。
<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#">
<NameCallback isRequired="true" >
<Prompt>Username</Prompt>
</NameCallback>
<PasswordCallback echoPassword="false" >
<Prompt>Password</Prompt>
</PasswordCallback>
</Callbacks>
<Callbacks length="1 order="3" timeout="600" header="#TO BE SUBSTITUTED#">
<NameCallback isRequired="true" >
<Prompt>Additional Input</Prompt>
</NameCallback>
</Callbacks>
</ModuleProperties>
在auth模块代码中处理状态
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 AUTHENTICATE:
return GET_ADDITIONAL_DATA;
//...
case GET_ADDITIONAL_DATA:
final String additionalData = ((NameCallback) callbacks[0]).getName();
// handle additional data
}
}
}