blob: 22feaab866371828437d27b81dfb52c432a50a1c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Tue Feb 25 18:15:49 EST 2014 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
Realm (Apache Shiro 1.2.3 API)
</TITLE>
<META NAME="date" CONTENT="2014-02-25">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Realm (Apache Shiro 1.2.3 API)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Realm.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/apache/shiro/realm/CachingRealm.html" title="class in org.apache.shiro.realm"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/apache/shiro/realm/RealmFactory.html" title="interface in org.apache.shiro.realm"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/shiro/realm/Realm.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Realm.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.shiro.realm</FONT>
<BR>
Interface Realm</H2>
<DL>
<DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../org/apache/shiro/realm/ldap/AbstractLdapRealm.html" title="class in org.apache.shiro.realm.ldap">AbstractLdapRealm</A>, <A HREF="../../../../org/apache/shiro/realm/activedirectory/ActiveDirectoryRealm.html" title="class in org.apache.shiro.realm.activedirectory">ActiveDirectoryRealm</A>, <A HREF="../../../../org/apache/shiro/realm/AuthenticatingRealm.html" title="class in org.apache.shiro.realm">AuthenticatingRealm</A>, <A HREF="../../../../org/apache/shiro/realm/AuthorizingRealm.html" title="class in org.apache.shiro.realm">AuthorizingRealm</A>, <A HREF="../../../../org/apache/shiro/realm/CachingRealm.html" title="class in org.apache.shiro.realm">CachingRealm</A>, <A HREF="../../../../org/apache/shiro/cas/CasRealm.html" title="class in org.apache.shiro.cas">CasRealm</A>, <A HREF="../../../../org/apache/shiro/realm/text/IniRealm.html" title="class in org.apache.shiro.realm.text">IniRealm</A>, <A HREF="../../../../org/apache/shiro/realm/jdbc/JdbcRealm.html" title="class in org.apache.shiro.realm.jdbc">JdbcRealm</A>, <A HREF="../../../../org/apache/shiro/realm/ldap/JndiLdapRealm.html" title="class in org.apache.shiro.realm.ldap">JndiLdapRealm</A>, <A HREF="../../../../org/apache/shiro/realm/text/PropertiesRealm.html" title="class in org.apache.shiro.realm.text">PropertiesRealm</A>, <A HREF="../../../../org/apache/shiro/realm/SimpleAccountRealm.html" title="class in org.apache.shiro.realm">SimpleAccountRealm</A>, <A HREF="../../../../org/apache/shiro/realm/text/TextConfigurationRealm.html" title="class in org.apache.shiro.realm.text">TextConfigurationRealm</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public interface <A HREF="../../../../src-html/org/apache/shiro/realm/Realm.html#line.63"><B>Realm</B></A></DL>
</PRE>
<P>
A <tt>Realm</tt> is a security component that can access application-specific security entities
such as users, roles, and permissions to determine authentication and authorization operations.
<p><tt>Realm</tt>s usually have a 1-to-1 correspondance with a datasource such as a relational database,
file sysetem, or other similar resource. As such, implementations of this interface use datasource-specific APIs to
determine authorization data (roles, permissions, etc), such as JDBC, File IO, Hibernate or JPA, or any other
Data Access API. They are essentially security-specific
<a href="http://en.wikipedia.org/wiki/Data_Access_Object" target="_blank">DAO</a>s.
<p>Because most of these datasources usually contain Subject (a.k.a. User) information such as usernames and
passwords, a Realm can act as a pluggable authentication module in a
<a href="http://en.wikipedia.org/wiki/Pluggable_Authentication_Modules">PAM</a> configuration. This allows a Realm to
perform <i>both</i> authentication and authorization duties for a single datasource, which caters to the large
majority of applications. If for some reason you don't want your Realm implementation to perform authentication
duties, you should override the <A HREF="../../../../org/apache/shiro/realm/Realm.html#supports(org.apache.shiro.authc.AuthenticationToken)"><CODE>supports(org.apache.shiro.authc.AuthenticationToken)</CODE></A> method to always
return <tt>false</tt>.
<p>Because every application is different, security data such as users and roles can be
represented in any number of ways. Shiro tries to maintain a non-intrusive development philosophy whenever
possible - it does not require you to implement or extend any <tt>User</tt>, <tt>Group</tt> or <tt>Role</tt>
interfaces or classes.
<p>Instead, Shiro allows applications to implement this interface to access environment-specific datasources
and data model objects. The implementation can then be plugged in to the application's Shiro configuration.
This modular technique abstracts away any environment/modeling details and allows Shiro to be deployed in
practically any application environment.
<p>Most users will not implement the <tt>Realm</tt> interface directly, but will extend one of the subclasses,
<A HREF="../../../../org/apache/shiro/realm/AuthenticatingRealm.html" title="class in org.apache.shiro.realm"><CODE>AuthenticatingRealm</CODE></A> or <A HREF="../../../../org/apache/shiro/realm/AuthorizingRealm.html" title="class in org.apache.shiro.realm"><CODE>AuthorizingRealm</CODE></A>, greatly reducing the effort requird
to implement a <tt>Realm</tt> from scratch.</p>
<P>
<P>
<DL>
<DT><B>Since:</B></DT>
<DD>0.1</DD>
<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/shiro/realm/CachingRealm.html" title="class in org.apache.shiro.realm"><CODE>CachingRealm</CODE></A>,
<A HREF="../../../../org/apache/shiro/realm/AuthenticatingRealm.html" title="class in org.apache.shiro.realm"><CODE>AuthenticatingRealm</CODE></A>,
<A HREF="../../../../org/apache/shiro/realm/AuthorizingRealm.html" title="class in org.apache.shiro.realm"><CODE>AuthorizingRealm</CODE></A>,
<A HREF="../../../../org/apache/shiro/authc/pam/ModularRealmAuthenticator.html" title="class in org.apache.shiro.authc.pam"><CODE>ModularRealmAuthenticator</CODE></A></DL>
<HR>
<P>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/authc/AuthenticationInfo.html" title="interface in org.apache.shiro.authc">AuthenticationInfo</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/realm/Realm.html#getAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken)">getAuthenticationInfo</A></B>(<A HREF="../../../../org/apache/shiro/authc/AuthenticationToken.html" title="interface in org.apache.shiro.authc">AuthenticationToken</A>&nbsp;token)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an account's authentication-specific information for the specified <tt>token</tt>,
or <tt>null</tt> if no account could be found based on the <tt>token</tt>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/realm/Realm.html#getName()">getName</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the (application-unique) name assigned to this <code>Realm</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/realm/Realm.html#supports(org.apache.shiro.authc.AuthenticationToken)">supports</A></B>(<A HREF="../../../../org/apache/shiro/authc/AuthenticationToken.html" title="interface in org.apache.shiro.authc">AuthenticationToken</A>&nbsp;token)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns <tt>true</tt> if this realm wishes to authenticate the Subject represented by the given
<A HREF="../../../../org/apache/shiro/authc/AuthenticationToken.html" title="interface in org.apache.shiro.authc"><CODE>AuthenticationToken</CODE></A> instance, <tt>false</tt> otherwise.</TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="getName()"><!-- --></A><H3>
getName</H3>
<PRE>
<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <A HREF="../../../../src-html/org/apache/shiro/realm/Realm.html#line.71"><B>getName</B></A>()</PRE>
<DL>
<DD>Returns the (application-unique) name assigned to this <code>Realm</code>. All realms configured for a single
application must have a unique name.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the (application-unique) name assigned to this <code>Realm</code>.</DL>
</DD>
</DL>
<HR>
<A NAME="supports(org.apache.shiro.authc.AuthenticationToken)"><!-- --></A><H3>
supports</H3>
<PRE>
boolean <A HREF="../../../../src-html/org/apache/shiro/realm/Realm.html#line.85"><B>supports</B></A>(<A HREF="../../../../org/apache/shiro/authc/AuthenticationToken.html" title="interface in org.apache.shiro.authc">AuthenticationToken</A>&nbsp;token)</PRE>
<DL>
<DD>Returns <tt>true</tt> if this realm wishes to authenticate the Subject represented by the given
<A HREF="../../../../org/apache/shiro/authc/AuthenticationToken.html" title="interface in org.apache.shiro.authc"><CODE>AuthenticationToken</CODE></A> instance, <tt>false</tt> otherwise.
<p>If this method returns <tt>false</tt>, it will not be called to authenticate the Subject represented by
the token - more specifically, a <tt>false</tt> return value means this Realm instance's
<A HREF="../../../../org/apache/shiro/realm/Realm.html#getAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken)"><CODE>getAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken)</CODE></A> method will not be invoked for that token.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>token</CODE> - the AuthenticationToken submitted for the authentication attempt
<DT><B>Returns:</B><DD><tt>true</tt> if this realm can/will authenticate Subjects represented by specified token,
<tt>false</tt> otherwise.</DL>
</DD>
</DL>
<HR>
<A NAME="getAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken)"><!-- --></A><H3>
getAuthenticationInfo</H3>
<PRE>
<A HREF="../../../../org/apache/shiro/authc/AuthenticationInfo.html" title="interface in org.apache.shiro.authc">AuthenticationInfo</A> <A HREF="../../../../src-html/org/apache/shiro/realm/Realm.html#line.103"><B>getAuthenticationInfo</B></A>(<A HREF="../../../../org/apache/shiro/authc/AuthenticationToken.html" title="interface in org.apache.shiro.authc">AuthenticationToken</A>&nbsp;token)
throws <A HREF="../../../../org/apache/shiro/authc/AuthenticationException.html" title="class in org.apache.shiro.authc">AuthenticationException</A></PRE>
<DL>
<DD>Returns an account's authentication-specific information for the specified <tt>token</tt>,
or <tt>null</tt> if no account could be found based on the <tt>token</tt>.
<p>This method effectively represents a login attempt for the corresponding user with the underlying EIS datasource.
Most implementations merely just need to lookup and return the account data only (as the method name implies)
and let Shiro do the rest, but implementations may of course perform eis specific login operations if so
desired.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>token</CODE> - the application-specific representation of an account principal and credentials.
<DT><B>Returns:</B><DD>the authentication information for the account associated with the specified <tt>token</tt>,
or <tt>null</tt> if no account could be found.
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../../../org/apache/shiro/authc/AuthenticationException.html" title="class in org.apache.shiro.authc">AuthenticationException</A></CODE> - if there is an error obtaining or constructing an AuthenticationInfo object based on the
specified <tt>token</tt> or implementation-specifc login behavior fails.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Realm.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/apache/shiro/realm/CachingRealm.html" title="class in org.apache.shiro.realm"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/apache/shiro/realm/RealmFactory.html" title="interface in org.apache.shiro.realm"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/shiro/realm/Realm.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Realm.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright &#169; 2004-2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.
</BODY>
</HTML>