⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acuserentry.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
字号:
/*
* Copyright (c) 2006, University of Kent
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without 
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this 
* list of conditions and the following disclaimer.
* 
* Redistributions in binary form must reproduce the above copyright notice, 
* this list of conditions and the following disclaimer in the documentation 
* and/or other materials provided with the distribution. 
*
* 1. Neither the name of the University of Kent nor the names of its 
* contributors may be used to endorse or promote products derived from this 
* software without specific prior written permission. 
*
* 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS  
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
* PURPOSE ARE DISCLAIMED. 
*
* 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
* POSSIBILITY OF SUCH DAMAGE.
*
* 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE
* IN THE CIRCUMSTANCES.  IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS
* SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS
* SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH
* GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH
* TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY
* IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE
* SERIOUS FAULTS, IN THIS SOFTWARE.
*
* 5. This license is governed, except to the extent that local laws
* necessarily apply, by the laws of England and Wales.
*/

package issrg.pba.rbac.x509;

import issrg.pba.repository.UserEntry;
import issrg.pba.rbac.LDAPDNPrincipal;
import issrg.utils.repository.Entry;

/**
 *
 * @author rl59
 */
public class ACUserEntry extends UserEntry{
    
    protected void _init_(issrg.ac.AttributeCertificate user){
        try{
            super._init_(user.getACInfo().getHolder().getEntityName()!=null
                    ?new LDAPDNPrincipal(
                    issrg.ac.Util.generalNamesToString(user.getACInfo().getHolder().getEntityName())
                    )
                    :null,
                    user.getACInfo().getHolder().getBaseCertificateID()!=null
                    ?new LDAPDNPrincipal(
                    issrg.ac.Util.generalNamesToString(user.getACInfo().getHolder().getBaseCertificateID().getIssuer())
                    )
                    :null,
                    user.getACInfo().getHolder().getBaseCertificateID()!=null
                    ?user.getACInfo().getHolder().getBaseCertificateID().getSerial()
                    :null
                    );
        }catch (issrg.utils.RFC2253ParsingException rpe){
            throw new java.lang.IllegalArgumentException(rpe.getMessage());
        }
    }
    
    /**
     * This constructor builds an object from the given Principal.
     */
    public ACUserEntry(java.security.Principal subject){
        super(subject);
    }
    
    /**
     * This constructor builds an object assuming that the object is an encoding of an AC.
     */
    public ACUserEntry(Object ac) {
        try{
            _init_(issrg.ac.AttributeCertificate.guessEncoding((byte[])ac));
        }catch (Exception e){
            throw new IllegalArgumentException(e.getMessage());
        }
    }
    
    /**
     * This constructor builds an object from the given V2Form object, containing
     * all the necessary information about the user.
     *
     * @param user is the V2Form object with the fields filled in as appropriate;
     *    the issuerName reference is treated as the subjectName, baseCertificateID
     *    field is used as the reference to the alternative entry
     */
    public ACUserEntry(issrg.ac.V2Form user){
        try{
            _init_(user.getIssuerName()!=null
                    ?new LDAPDNPrincipal(
                    issrg.ac.Util.generalNamesToString(user.getIssuerName())
                    )
                    :null,
                    user.getBaseCertificateID()!=null
                    ?new LDAPDNPrincipal(
                    issrg.ac.Util.generalNamesToString(user.getBaseCertificateID().getIssuer())
                    )
                    :null,
                    user.getBaseCertificateID()!=null
                    ?user.getBaseCertificateID().getSerial()
                    :null
                    );
        }catch (issrg.utils.RFC2253ParsingException rpe){
            throw new java.lang.IllegalArgumentException(rpe.getMessage());
        }
    }
    
    /**
     * This constructor builds an object from the AttributeCertificate
     * information. The holder field is used to retrieve all the necessary data.
     *
     * @param user is the valid X.509 AC
     */
    public ACUserEntry(issrg.ac.AttributeCertificate user){
        _init_(user);
    }
    
    /**
     * This constructor builds an object out of the data contained in the given
     * X509 PKC.
     *
     * @param cert is the valid X509 certificate of the holder
     */
    public ACUserEntry(java.security.cert.X509Certificate cert){
        _init_(cert.getSubjectDN(), cert.getIssuerDN(), cert.getSerialNumber());
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -