class RoleToken extends Token {

    private RoleToken(Builder builder) {

        this.version = builder.version;
        this.domain = builder.domain;
        this.roles = builder.roles;
        this.host = builder.host;
        this.salt = builder.salt;
        this.keyId = builder.keyId;
        this.ip = builder.ip;
        this.principal = builder.principal;
        this.proxyUser = builder.proxyUser;
        this.domainCompleteRoleSet = builder.domainCompleteRoleSet;
        
        super.setTimeStamp(builder.issueTime, builder.expirationWindow);
        
        StringBuilder strBuilder = new StringBuilder(defaultBuilderBufSize);
        
        strBuilder.append("v=");
        strBuilder.append(version);
        strBuilder.append(";d=");
        strBuilder.append(domain);
        strBuilder.append(";r=");

        int i = 0;
        for (String role : roles) {
            strBuilder.append(role);
            if (++i != roles.size()) {
                strBuilder.append(",");
            }
        }
        
        if (domainCompleteRoleSet) {
            strBuilder.append(";c=1");
        }
        
        if (principal != null && !principal.isEmpty()) {
            strBuilder.append(";p=");
            strBuilder.append(principal);
        }
        
        if (host != null && !host.isEmpty()) {
            strBuilder.append(";h=");
            strBuilder.append(host);
        }
        
        if (proxyUser != null && !proxyUser.isEmpty()) {
            strBuilder.append(";proxy=");
            strBuilder.append(proxyUser);
        }
        
        strBuilder.append(";a=");
        strBuilder.append(salt);
        strBuilder.append(";t=");
        strBuilder.append(timestamp);
        strBuilder.append(";e=");
        strBuilder.append(expiryTime);
        strBuilder.append(";k=");
        strBuilder.append(keyId);
        if (ip != null && !ip.isEmpty()) {
            strBuilder.append(";i=");
            strBuilder.append(ip);
        }
        
        unsignedToken = strBuilder.toString();
        
        if (LOG.isDebugEnabled()) {
            LOG.debug("RoleToken created: " + unsignedToken);
        }
    }

    private  RoleToken(Builder builder);
    public  RoleToken(String signedToken);

}