Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.picketlink.idm.token.internal;
import org.picketlink.common.properties.Property;
import org.picketlink.common.properties.query.AnnotatedPropertyCriteria;
import org.picketlink.common.properties.query.NamedPropertyCriteria;
import org.picketlink.common.properties.query.PropertyQueries;
import org.picketlink.common.reflection.Reflections;
import org.picketlink.idm.IdentityManagementException;
import org.picketlink.idm.config.TokenStoreConfiguration;
import org.picketlink.idm.credential.Token;
import org.picketlink.idm.credential.TokenCredential;
import org.picketlink.idm.credential.handler.TokenCredentialHandler;
import org.picketlink.idm.credential.handler.annotations.CredentialHandlers;
import org.picketlink.idm.credential.storage.CredentialStorage;
import org.picketlink.idm.internal.AbstractIdentityStore;
import org.picketlink.idm.model.Account;
import org.picketlink.idm.model.AttributedType;
import org.picketlink.idm.model.IdentityType;
import org.picketlink.idm.model.Partition;
import org.picketlink.idm.model.Relationship;
import org.picketlink.idm.model.annotation.IdentityStereotype;
import org.picketlink.idm.model.annotation.RelationshipStereotype;
import org.picketlink.idm.model.annotation.StereotypeProperty;
import org.picketlink.idm.model.basic.Realm;
import org.picketlink.idm.query.AttributeParameter;
import org.picketlink.idm.query.Condition;
import org.picketlink.idm.query.IdentityQuery;
import org.picketlink.idm.query.QueryParameter;
import org.picketlink.idm.query.RelationshipQuery;
import org.picketlink.idm.query.RelationshipQueryParameter;
import org.picketlink.idm.query.internal.EqualCondition;
import org.picketlink.idm.spi.CredentialStore;
import org.picketlink.idm.spi.IdentityContext;
import org.picketlink.idm.spi.PartitionStore;
import java.util.ArrayList;
import java.util.List;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableList;
import static org.picketlink.idm.IDMMessages.MESSAGES;
import static org.picketlink.idm.credential.Token.Consumer;
import static org.picketlink.idm.spi.IdentityContext.CREDENTIALS;
/**
* @author Pedro Igor
*/
@CredentialHandlers({
TokenCredentialHandler.class})
public class TokenIdentityStore extends AbstractIdentityStore
implements CredentialStore,
PartitionStore {
private List tokenConsumers;
@Override
public void setup(TokenStoreConfiguration config) {
super.setup(config);
this.tokenConsumers = config.getTokenConsumer();
}
@Override
protected void removeFromRelationships(IdentityContext context, IdentityType identityType) {
}
@Override
protected void removeCredentials(IdentityContext context, Account account) {
}
@Override
protected void updateAttributedType(IdentityContext context, AttributedType attributedType) {
}
@Override
protected void removeAttributedType(IdentityContext context, AttributedType attributedType) {
}
@Override
public List fetchQueryResults(IdentityContext context, IdentityQuery query) {
List identityTypes = new ArrayList();
Class identityTypeType = query.getIdentityType();
IdentityStereotype stereotype = identityTypeType.getAnnotation(IdentityStereotype.class);
if (stereotype == null) {
throw new IdentityManagementException("Type [" + identityTypeType + "] does not define a " + IdentityStereotype.class + ".");
}
Token currentToken = getCurrentToken(context);
IdentityType identityType = null;
for (Condition condition : query.getConditions()) {
QueryParameter queryParameter = condition.getParameter();
String queryParameterName = ((AttributeParameter) queryParameter).getName();
if (IdentityType.PARTITION.equals(queryParameter)) {
continue;
}
if (EqualCondition.class.isInstance(condition)) {
EqualCondition equalCondition = (EqualCondition) condition;
Object queryParameterValue = equalCondition.getValue();
if (queryParameterValue == null) {
throw new IdentityManagementException("Query parameter [" + queryParameterName + "] does not have any value.");
}
if (IdentityType.ID.equals(queryParameter)) {
identityType = getTokenConsumer(currentToken)
.extractIdentity(currentToken, identityTypeType, StereotypeProperty.Property.IDENTITY_ID, queryParameterValue);
} else {
Property